Skip to content

Commit

Permalink
add testing support and administrative area support for new notificat…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
richard-jones committed Jan 22, 2025
1 parent 65adf10 commit a71ec65
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 20 deletions.
72 changes: 71 additions & 1 deletion doajtest/functional/make_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from doajtest.fixtures.v2.applications import ApplicationFixtureFactory
from doajtest.fixtures.v2.journals import JournalFixtureFactory
from doajtest.mocks.mock_mail import MockMail
from events.consumers.application_assed_acceptreject_notify import ApplicationAssedAcceptRejectNotify
from portality import constants
from portality import models, app_email
from portality.core import app
Expand All @@ -26,6 +27,8 @@
update_request_publisher_assigned_notify, \
update_request_publisher_rejected_notify
from portality.events.consumers.update_request_publisher_submitted_notify import UpdateRequestPublisherSubmittedNotify
from portality.events.consumers.application_editor_acceptreject_notify import ApplicationEditorAcceptRejectNotify
from portality.events.consumers.update_request_maned_editor_group_assigned_notify import UpdateRequestManedEditorGroupAssignedNotify
from portality.models import EditorGroup
from portality.models.event import Event

Expand Down Expand Up @@ -58,6 +61,23 @@
app.config["ENABLE_EMAIL"] = True
app_email.Mail = MockMail


##############################################
## ApplicationAssedAcceptRejectNotify
if "application:assed:acceptreject:notify" in NOTIFICATIONS:
aaan_application = ApplicationFixtureFactory.make_application_source()
aaan_application["admin"]["editor"] = USER
aaan_application["bibjson"]["title"] = "Application Assed Accept/Reject Notify"
aaan_application["id"] = "application_assed_acceptreject_notify"
aaan_application["admin"]["application_status"] = constants.APPLICATION_STATUS_ACCEPTED

event = Event(constants.EVENT_APPLICATION_STATUS, context={
"application": aaan_application,
"new_status": constants.APPLICATION_STATUS_ACCEPTED
})
aaan = ApplicationAssedAcceptRejectNotify()
aaan.consume(event)

##############################################
## ApplicationAssedAssignedNotify
if "application:assed:assigned:notify" in NOTIFICATIONS:
Expand Down Expand Up @@ -86,6 +106,32 @@
aain = application_assed_inprogress_notify.ApplicationAssedInprogressNotify()
aain.consume(event)

##############################################
## ApplicationEditorAcceptRejectNotify
if "application:editor:acceptreject:notify" in NOTIFICATIONS:
def editor_group_mock_pull(*args, **kwargs):
return EditorGroup(**{
"editor": USER
})

eg_pull = EditorGroup.pull_by_key
EditorGroup.pull_by_key = editor_group_mock_pull

aaan_application = ApplicationFixtureFactory.make_application_source()
aaan_application["admin"]["editor"] = USER
aaan_application["bibjson"]["title"] = "Application Editor Accept/Reject Notify"
aaan_application["id"] = "application_editor_acceptreject_notify"
aaan_application["admin"]["application_status"] = constants.APPLICATION_STATUS_REJECTED

event = Event(constants.EVENT_APPLICATION_STATUS, context={
"application": aaan_application,
"new_status": constants.APPLICATION_STATUS_REJECTED
})
aaan = ApplicationEditorAcceptRejectNotify()
aaan.consume(event)

EditorGroup.pull_by_key = eg_pull

##############################################
## ApplicationEditorCompletedNotify
if "application:editor:completed:notify" in NOTIFICATIONS:
Expand All @@ -94,7 +140,6 @@ def editor_group_mock_pull(editor_group_id):
"editor": USER
})


eg_pull = EditorGroup.pull
EditorGroup.pull = editor_group_mock_pull

Expand Down Expand Up @@ -321,6 +366,31 @@ def editor_group_mock_pull(key, value):

EditorGroup.pull_by_key = eg_pull

##############################################
## UpdateRequestManedEditorGroupAssignedNotify
if "application:editor_group:assigned:notify" in NOTIFICATIONS:
def editor_group_mock_pull(key, value):
return EditorGroup(**{
"maned": USER
})


eg_pull = EditorGroup.pull_by_key
EditorGroup.pull_by_key = editor_group_mock_pull

aegan_application = ApplicationFixtureFactory.make_application_source()
aegan_application["admin"]["application_type"] = constants.APPLICATION_TYPE_UPDATE_REQUEST
aegan_application["bibjson"]["title"] = "Application ManEd Editor Group Assigned Notify"
aegan_application["id"] = "application_maned_editor_group_assigned_notify"

event = Event(constants.EVENT_APPLICATION_EDITOR_GROUP_ASSIGNED, context={
"application": aegan_application
})
aegan = UpdateRequestManedEditorGroupAssignedNotify()
aegan.consume(event)

EditorGroup.pull_by_key = eg_pull

##############################################
## UpdateRequestPublisherAcceptedNotify
if "update_request:publisher:accepted:notify" in NOTIFICATIONS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def consume(cls, event):
app_source = event.context.get("application")

application = consumer_utils.parse_application(app_source)

if application.application_type != constants.APPLICATION_TYPE_NEW_APPLICATION:
return

if not application.editor_group:
return

Expand Down
42 changes: 23 additions & 19 deletions portality/static/js/edges/admin.notifications.edge.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,29 @@ $.extend(true, doaj, {
activeEdges : {},

createdByMap : {
"application:assed:assigned:notify" : "AssEd: Assigned Application",
"application:assed:inprogress:notify" : "AssEd: Application referred back",
"application:editor:completed:notify" : "Editor: AssEd Completes Application",
"application:editor_group:assigned:notify" : "Editor: Group assigned Application",
"application:editor:inprogress:notify" : "Editor: Application referred back",
"application:maned:ready:notify" : "ManEd: Editor Sets Application Ready",
"application:publisher:accepted:notify" : "Publisher: Application Accepted",
"application:publisher:assigned:notify" : "Publisher: Application assigned Editor",
"application:publisher:created:notify" : "Publisher: Application received",
"application:publisher:inprogress:notify" : "Publisher: Application in progress",
"application:publisher:rejected:notify" : "Publisher: Application rejected",
"application:publisher:quickreject:notify" : "Publisher: Application quick-rejected",
"application:publisher:revision:notify" : "Publisher: Application requires revisions",
"bg:job_finished:notify" : "Admin: Background Job finished",
"journal:assed:assigned:notify" : "AssEd: Assigned Journal",
"journal:editor_group:assigned:notify": "Editor: Group assigned Journal",
"update_request:publisher:accepted:notify": "Publisher: UR accepted",
"update_request:publisher:assigned:notify": "Publisher: UR assigned Editor",
"update_request:publisher:rejected:notify": "Publisher: UR rejected"
"application:assed:acceptreject:notify": "Application: AssEd: Accepted/Rejected",
"application:assed:assigned:notify" : "Application: AssEd: Assigned",
"application:assed:inprogress:notify" : "Application: AssEd: Referred back",
"application:editor:acceptreject:notify": "Application: Editor: Accepted/Rejected",
"application:editor:completed:notify" : "Application: Editor: Completed",
"application:editor_group:assigned:notify" : "Application: Editor: Group assigned",
"application:editor:inprogress:notify" : "Application: Editor: Referred back",
"application:maned:ready:notify" : "Application: ManEd: Editor Sets Ready",
"application:publisher:accepted:notify" : "Application: Publisher: Accepted",
"application:publisher:assigned:notify" : "Application: Publisher: Assigned Editor",
"application:publisher:created:notify" : "Application: Publisher: Received",
"application:publisher:inprogress:notify" : "Application: Publisher: In progress",
"application:publisher:rejected:notify" : "Application: Publisher: Rejected",
"application:publisher:quickreject:notify" : "Application: Publisher: Quick-rejected",
"application:publisher:revision:notify" : "Application: Publisher: Requires revisions",
"bg:job_finished:notify" : "Background Job: Admin: Finished",
"journal:assed:assigned:notify" : "Journal: AssEd: Assigned",
"journal:editor_group:assigned:notify": "Journal: Editor: Group assigned",
"update_request:maned:editor_group_assigned:notify": "UR: ManEd: Assigned",
"update_request:publisher:accepted:notify": "UR: Publisher: Accepted",
"update_request:publisher:assigned:notify": "UR: Publisher: Assigned Editor",
"update_request:publisher:rejected:notify": "UR: Publisher: Rejected",
"update_request:publisher:submitted:notify": "UR: Publisher: Submitted"
},

init : function(params) {
Expand Down

0 comments on commit a71ec65

Please sign in to comment.