diff --git a/CHANGELOG.md b/CHANGELOG.md index 01eca5b261..b951374847 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,24 +1,19 @@ # CHANGELOG -## unreleased version -- v0.12.4 -## Added -- New /fulfill endpoint with ability to check for NYPL login in Bearer authorization header -- Fulfill endpoint returns pre-signed URLs for objects in private buckets when user is logged in -- Change default development port to 5050 due to macOS Monterey and higher occupying port 5000 by default -# Removed -- Deleted Tugboat configuration as Tugboat is no longer used and no longer builds ## unreleased version -- v0.12.4 ## Added - New script to add nypl_login flag to Links objects -- Added nypl_login flag to nypl mapping +- Added nypl_login flags to NYPL and University of Michigan mapping and process - New APIUtils method to generate a presigned url for S3 actions - New /fulfill endpoint with ability to check for NYPL login in Bearer authorization header - Fulfill endpoint returns pre-signed URLs for objects in private buckets when user is logged in +- Change default development port to 5050 due to macOS Monterey and higher occupying port 5000 by default - Added new University of Michigan process and mapping for ingestion - New directory for test JSON files that will be ingested ## Fixed - NYPL records not being added due to SQLAlchemy error - Bardo CCE API and Hathi DataFiles URL updated +- Deleted Tugboat configuration as Tugboat is no longer used and no longer builds ## 2023-09-05 version -- v0.12.3 ## Removed diff --git a/processes/UofM.py b/processes/UofM.py index 45d0c73353..c4d2a3f4d7 100644 --- a/processes/UofM.py +++ b/processes/UofM.py @@ -45,7 +45,7 @@ def processUofMRecord(self, record): UofMRec = UofMMapping(record) UofMRec.applyMapping() self.addHasPartMapping(record, UofMRec.record) - self.storePDFManifest(UofMRec.record) + #self.storePDFManifest(UofMRec.record) self.addDCDWToUpdateList(UofMRec) except (MappingError, HTTPError, ConnectionError, IndexError, TypeError) as e: @@ -67,7 +67,7 @@ def addHasPartMapping(self, resultsRecord, record): urlPDFObject, 'UofM', 'application/pdf', - '{"catalog": false, "download": true, "reader": false, "embed": false}' + '{"catalog": false, "download": true, "reader": false, "embed": false, "nypl_login": true}' ]) record.has_part.append(linkString) diff --git a/scripts/nyplLoginFlags.py b/scripts/nyplLoginFlags.py index a356d991c8..9e731cf8c9 100644 --- a/scripts/nyplLoginFlags.py +++ b/scripts/nyplLoginFlags.py @@ -1,13 +1,12 @@ import os -from model import Link +from model import Link, Item +from model.postgres.item import ITEM_LINKS from managers import DBManager -from sqlalchemy import or_ -import json def main(): - '''Updating NYPL Link flags with a new nypl_login flag''' + '''Updating Link flags with a new nypl_login flag''' dbManager = DBManager( user= os.environ.get('POSTGRES_USER', None), @@ -21,13 +20,18 @@ def main(): dbManager.createSession() - for link in dbManager.session.query(Link) \ - .filter(or_(Link.media_type == 'application/html+edd', Link.media_type == 'application/x.html+edd')).all(): - if link.flags and 'edd' in link.flags and link.flags['edd'] == True: - #The link.flags doesn't update if the dict method isn't called on it - newLinkFlag = dict(link.flags) - newLinkFlag['nypl_login'] = True - link.flags = newLinkFlag + + for item in dbManager.session.query(Item) \ + .filter(Item.source == 'UofM'): + for link in dbManager.session.query(Link) \ + .join(ITEM_LINKS) \ + .filter(ITEM_LINKS.c.item_id == item.id) \ + .filter(Link.media_type == 'application/pdf').all(): + if link.flags: + #The link.flags doesn't update if the dict method isn't called on it + newLinkFlag = dict(link.flags) + newLinkFlag['nypl_login'] = True + link.flags = newLinkFlag dbManager.commitChanges() diff --git a/tests/unit/test_UofM_process.py b/tests/unit/test_UofM_process.py index c21d86101c..bbde72e3f3 100644 --- a/tests/unit/test_UofM_process.py +++ b/tests/unit/test_UofM_process.py @@ -55,7 +55,7 @@ def test_processUofMRecord_success(self, testProcess, mocker): mockMapping.applyMapping.assert_called_once() processMocks['addHasPartMapping'].assert_called_once_with(mockMapping, 'testRecord') - processMocks['storePDFManifest'].assert_called_once_with('testRecord') + #processMocks['storePDFManifest'].assert_called_once_with('testRecord') processMocks['addDCDWToUpdateList'].assert_called_once_with(mockMapping) def test_processUofMRecord_error(self, mocker): @@ -65,23 +65,23 @@ def test_processUofMRecord_error(self, mocker): assert pytest.raises(MappingError) - def test_storePDFManifest(self, testProcess, mocker): - mockRecord = mocker.MagicMock(identifiers=['1|UofM']) - mockRecord.has_part = [ - '1|testURI|UofM|application/pdf|{}', - ] + # def test_storePDFManifest(self, testProcess, mocker): + # mockRecord = mocker.MagicMock(identifiers=['1|UofM']) + # mockRecord.has_part = [ + # '1|testURI|UofM|application/pdf|{}', + # ] - mockGenerateMan = mocker.patch.object(UofMProcess, 'generateManifest') - mockGenerateMan.return_value = 'testJSON' - mockCreateMan = mocker.patch.object(UofMProcess, 'createManifestInS3') + # mockGenerateMan = mocker.patch.object(UofMProcess, 'generateManifest') + # mockGenerateMan.return_value = 'testJSON' + # mockCreateMan = mocker.patch.object(UofMProcess, 'createManifestInS3') - testProcess.storePDFManifest(mockRecord) + # testProcess.storePDFManifest(mockRecord) - testManifestURI = 'https://test_aws_bucket.s3.amazonaws.com/manifests/UofM/1.json' - assert mockRecord.has_part[0] == '1|{}|UofM|application/webpub+json|{{"catalog": false, "download": false, "reader": true, "embed": false}}'.format(testManifestURI) + # testManifestURI = 'https://test_aws_bucket.s3.amazonaws.com/manifests/UofM/1.json' + # assert mockRecord.has_part[0] == '1|{}|UofM|application/webpub+json|{{"catalog": false, "download": false, "reader": true, "embed": false}}'.format(testManifestURI) - mockGenerateMan.assert_called_once_with(mockRecord, 'testURI', testManifestURI) - mockCreateMan.assert_called_once_with('manifests/UofM/1.json', 'testJSON') + # mockGenerateMan.assert_called_once_with(mockRecord, 'testURI', testManifestURI) + # mockCreateMan.assert_called_once_with('manifests/UofM/1.json', 'testJSON') def test_createManifestInS3(self, testProcess, mocker): mockPut = mocker.patch.object(UofMProcess, 'putObjectInBucket')