-
Notifications
You must be signed in to change notification settings - Fork 16
/
events.py
67 lines (61 loc) · 3.75 KB
/
events.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from portality.core import app
from portality.lib import plugin
from portality.events.consumers.account_created_email import AccountCreatedEmail
from portality.events.consumers.application_assed_inprogress_notify import ApplicationAssedInprogressNotify
from portality.events.consumers.application_assed_assigned_notify import ApplicationAssedAssignedNotify
from portality.events.consumers.bg_job_finished_notify import BGJobFinishedNotify
from portality.events.consumers.application_maned_ready_notify import ApplicationManedReadyNotify
from portality.events.consumers.application_publisher_created_notify import ApplicationPublisherCreatedNotify
from portality.events.consumers.application_publisher_revision_notify import ApplicationPublisherRevisionNotify
from portality.events.consumers.application_editor_completed_notify import ApplicationEditorCompletedNotify
from portality.events.consumers.application_editor_inprogress_notify import ApplicationEditorInProgressNotify
from portality.events.consumers.account_passwordreset_email import AccountPasswordResetEmail
from portality.events.consumers.application_editor_group_assigned_notify import ApplicationEditorGroupAssignedNotify
from portality.events.consumers.application_publisher_quickreject_notify import ApplicationPublisherQuickRejectNotify
from portality.events.consumers.application_publisher_accepted_notify import ApplicationPublisherAcceptedNotify
from portality.events.consumers.update_request_publisher_accepted_notify import UpdateRequestPublisherAcceptedNotify
from portality.events.consumers.application_publisher_assigned_notify import ApplicationPublisherAssignedNotify
from portality.events.consumers.update_request_publisher_assigned_notify import UpdateRequestPublisherAssignedNotify
from portality.events.consumers.journal_assed_assigned_notify import JournalAssedAssignedNotify
from portality.events.consumers.journal_editor_group_assigned_notify import JournalEditorGroupAssignedNotify
from portality.events.consumers.application_publisher_inprogress_notify import ApplicationPublisherInprogressNotify
from portality.events.consumers.update_request_publisher_rejected_notify import UpdateRequestPublisherRejectedNotify
from portality.events.consumers.journal_discontinuing_soon_notify import JournalDiscontinuingSoonNotify
class EventsService(object):
# disabled events - to enable move the event to EVENT_CONSUMENRS array
DISABLED_EVENTS = [
ApplicationPublisherRevisionNotify
]
EVENT_CONSUMERS = [
ApplicationPublisherQuickRejectNotify,
AccountCreatedEmail,
AccountPasswordResetEmail,
ApplicationAssedInprogressNotify,
ApplicationAssedAssignedNotify,
ApplicationEditorCompletedNotify,
ApplicationEditorInProgressNotify,
ApplicationEditorGroupAssignedNotify,
ApplicationManedReadyNotify,
ApplicationPublisherCreatedNotify,
ApplicationPublisherInprogressNotify,
ApplicationPublisherAcceptedNotify,
ApplicationPublisherAssignedNotify,
BGJobFinishedNotify,
JournalAssedAssignedNotify,
JournalEditorGroupAssignedNotify,
UpdateRequestPublisherAcceptedNotify,
UpdateRequestPublisherAssignedNotify,
UpdateRequestPublisherRejectedNotify,
JournalDiscontinuingSoonNotify
]
def __init__(self):
self.trigger_function = plugin.load_function(app.config.get("EVENT_SEND_FUNCTION"))
def trigger(self, event):
self.trigger_function(event)
def consume(self, event):
for consumer in self.EVENT_CONSUMERS:
try:
if consumer.consumes(event):
consumer.consume(event)
except Exception as e:
app.logger.error("Error in consumer {x}: {e}".format(e=str(e), x=consumer.ID))