Skip to content

Commit

Permalink
Merge tag '2023-09-20_validate_owner_publishercsv' into develop
Browse files Browse the repository at this point in the history
updates to publishercsv ingest
  • Loading branch information
Steven-Eardley committed Sep 21, 2023
2 parents f704067 + 2a104fd commit c820c85
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
10 changes: 5 additions & 5 deletions portality/forms/application_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,11 @@ def _patch_target_note_id(self):
for note in self.target.notes:
note_date = dates.parse(note['date'])
if not note.get('author_id') and note_date > dates.before_now(60):
note['author_id'] = current_user.id

try:
note['author_id'] = current_user.id
except AttributeError:
# Skip if we don't have a current_user
pass


class NewApplication(ApplicationProcessor):
Expand Down Expand Up @@ -307,7 +310,6 @@ def patch_target(self):
if (self.target.owner is None or self.target.owner == "") and (self.source.owner is not None):
self.target.set_owner(self.source.owner)


def finalise(self, account, save_target=True, email_alert=True):
"""
account is the administrator account carrying out the action
Expand All @@ -326,7 +328,6 @@ def finalise(self, account, save_target=True, email_alert=True):
elif not j.is_in_doaj():
raise Exception(Messages.EXCEPTION_EDITING_WITHDRAWN_JOURNAL)


# if we are allowed to finalise, kick this up to the superclass
super(AdminApplication, self).finalise()

Expand Down Expand Up @@ -813,7 +814,6 @@ def patch_target(self):
if (self.target.owner is None or self.target.owner == "") and (self.source.owner is not None):
self.target.set_owner(self.source.owner)


def finalise(self):
# FIXME: this first one, we ought to deal with outside the form context, but for the time being this
# can be carried over from the old implementation
Expand Down
11 changes: 10 additions & 1 deletion portality/scripts/journals_update_via_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
reader = csv.DictReader(g, fieldnames=header_row)

# verify header row with current CSV headers, report errors
# TODO: Include 'Owner' field - but we should probably base this process off the AdminCSV too.
expected_headers = JournalFixtureFactory.csv_headers()

# Always perform a match check on supplied headers, not counting order
Expand Down Expand Up @@ -155,6 +156,14 @@
if len(updates) > 0:
[print(upd) for upd in updates]

# Check we have the expected owner (if supplied) before proceeding to create an update request
own = row.get('Owner')
if own is not None:
if own.strip().lower() != j.owner.strip().lower():
print('ABORTING - supplied owner {0} mismatches journal owner {1}.'.format(own, j.owner))
writer.writerow([j.id, ' | '.join(updates), 'COULD NOT UPDATE - Owner mismatch. Expected {0} Got {1}'.format(own, j.owner)])
continue

# Create an update request for this journal
update_req = None
jlock = None
Expand Down Expand Up @@ -204,7 +213,7 @@

# Add note to UR if supplied
if note:
fc.target.add_note(note)
fc.target.add_note(note, author_id=sys_acc.id)

if not args.manual_review:
# This is the update request, in 'update request' state
Expand Down
2 changes: 1 addition & 1 deletion portality/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@
HUEY_SCHEDULE = {
"sitemap": {"month": "*", "day": "*", "day_of_week": "*", "hour": "8", "minute": "0"},
"reporting": {"month": "*", "day": "1", "day_of_week": "*", "hour": "0", "minute": "0"},
"journal_csv": {"month": "*", "day": "*", "day_of_week": "*", "hour": "*", "minute": "35"},
"journal_csv": {"month": "*", "day": "*", "day_of_week": "*", "hour": "*/2", "minute": "20"},
"read_news": {"month": "*", "day": "*", "day_of_week": "*", "hour": "*", "minute": "30"},
"article_cleanup_sync": {"month": "*", "day": "2", "day_of_week": "*", "hour": "0", "minute": "0"},
"async_workflow_notifications": {"month": "*", "day": "*", "day_of_week": "1", "hour": "5", "minute": "0"},
Expand Down

0 comments on commit c820c85

Please sign in to comment.