-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #277 from NYPL/SFR-1826_NYPLLoginFlag
SFR_1826_NYPLLoginFlag
- Loading branch information
Showing
5 changed files
with
45 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import os | ||
|
||
from model import Link | ||
from managers import DBManager | ||
from sqlalchemy import or_ | ||
import json | ||
|
||
def main(): | ||
|
||
'''Updating NYPL Link flags with a new nypl_login flag''' | ||
|
||
dbManager = DBManager( | ||
user= os.environ.get('POSTGRES_USER', None), | ||
pswd= os.environ.get('POSTGRES_PSWD', None), | ||
host= os.environ.get('POSTGRES_HOST', None), | ||
port= os.environ.get('POSTGRES_PORT', None), | ||
db= os.environ.get('POSTGRES_NAME', None) | ||
) | ||
|
||
dbManager.generateEngine() | ||
|
||
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['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 | ||
|
||
dbManager.commitChanges() | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters