Coverage for portality/bll/services/events.py: 100%
35 statements
« prev ^ index » next coverage.py v6.4.2, created at 2022-07-22 15:59 +0100
« prev ^ index » next coverage.py v6.4.2, created at 2022-07-22 15:59 +0100
1from portality.core import app
2from portality.lib import plugin
4from portality.events.consumers.account_created_email import AccountCreatedEmail
5from portality.events.consumers.application_assed_inprogress_notify import ApplicationAssedInprogressNotify
6from portality.events.consumers.application_assed_assigned_notify import ApplicationAssedAssignedNotify
7from portality.events.consumers.bg_job_finished_notify import BGJobFinishedNotify
8from portality.events.consumers.application_maned_ready_notify import ApplicationManedReadyNotify
9from portality.events.consumers.application_publisher_created_notify import ApplicationPublisherCreatedNotify
10from portality.events.consumers.application_publisher_revision_notify import ApplicationPublisherRevisionNotify
11from portality.events.consumers.application_editor_completed_notify import ApplicationEditorCompletedNotify
12from portality.events.consumers.application_editor_inprogress_notify import ApplicationEditorInProgressNotify
13from portality.events.consumers.account_passwordreset_email import AccountPasswordResetEmail
14from portality.events.consumers.application_editor_group_assigned_notify import ApplicationEditorGroupAssignedNotify
15from portality.events.consumers.application_publisher_quickreject_notify import ApplicationPublisherQuickRejectNotify
16from portality.events.consumers.application_publisher_accepted_notify import ApplicationPublisherAcceptedNotify
17from portality.events.consumers.update_request_publisher_accepted_notify import UpdateRequestPublisherAcceptedNotify
18from portality.events.consumers.application_publisher_assigned_notify import ApplicationPublisherAssignedNotify
19from portality.events.consumers.update_request_publisher_assigned_notify import UpdateRequestPublisherAssignedNotify
20from portality.events.consumers.journal_assed_assigned_notify import JournalAssedAssignedNotify
21from portality.events.consumers.journal_editor_group_assigned_notify import JournalEditorGroupAssignedNotify
22from portality.events.consumers.application_publisher_inprogress_notify import ApplicationPublisherInprogressNotify
23from portality.events.consumers.update_request_publisher_rejected_notify import UpdateRequestPublisherRejectedNotify
26class EventsService(object):
27 EVENT_CONSUMERS = [
28 ApplicationPublisherQuickRejectNotify,
29 AccountCreatedEmail,
30 AccountPasswordResetEmail,
31 ApplicationAssedInprogressNotify,
32 ApplicationAssedAssignedNotify,
33 ApplicationEditorCompletedNotify,
34 ApplicationEditorInProgressNotify,
35 ApplicationEditorGroupAssignedNotify,
36 ApplicationManedReadyNotify,
37 ApplicationPublisherCreatedNotify,
38 ApplicationPublisherInprogressNotify,
39 ApplicationPublisherAcceptedNotify,
40 ApplicationPublisherAssignedNotify,
41 ApplicationPublisherRevisionNotify,
42 BGJobFinishedNotify,
43 JournalAssedAssignedNotify,
44 JournalEditorGroupAssignedNotify,
45 UpdateRequestPublisherAcceptedNotify,
46 UpdateRequestPublisherAssignedNotify,
47 UpdateRequestPublisherRejectedNotify
48 ]
50 def __init__(self):
51 self.trigger_function = plugin.load_function(app.config.get("EVENT_SEND_FUNCTION"))
53 def trigger(self, event):
54 self.trigger_function(event)
56 def consume(self, event):
57 for consumer in self.EVENT_CONSUMERS:
58 try:
59 if consumer.consumes(event):
60 consumer.consume(event)
61 except Exception as e:
62 app.logger.error("Error in consumer {x}: {e}".format(e=str(e), x=consumer.ID))