Coverage for portality / bll / services / events.py: 100%
42 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-05-04 09:41 +0100
« prev ^ index » next coverage.py v7.13.5, created at 2026-05-04 09:41 +0100
1from portality.core import app
2from portality.events.consumers.update_request_publisher_submitted_notify import UpdateRequestPublisherSubmittedNotify
3from portality.lib import plugin
5from portality.events.consumers.account_created_email import AccountCreatedEmail
6from portality.events.consumers.application_assed_inprogress_notify import ApplicationAssedInprogressNotify
7from portality.events.consumers.application_assed_assigned_notify import ApplicationAssedAssignedNotify
8from portality.events.consumers.application_assed_acceptreject_notify import ApplicationAssedAcceptRejectNotify
9from portality.events.consumers.bg_job_finished_notify import BGJobFinishedNotify
10from portality.events.consumers.application_maned_ready_notify import ApplicationManedReadyNotify
11from portality.events.consumers.application_publisher_created_notify import ApplicationPublisherCreatedNotify
12from portality.events.consumers.application_publisher_revision_notify import ApplicationPublisherRevisionNotify
13from portality.events.consumers.application_editor_completed_notify import ApplicationEditorCompletedNotify
14from portality.events.consumers.application_editor_inprogress_notify import ApplicationEditorInProgressNotify
15from portality.events.consumers.account_passwordreset_email import AccountPasswordResetEmail
16from portality.events.consumers.application_editor_group_assigned_notify import ApplicationEditorGroupAssignedNotify
17from portality.events.consumers.application_publisher_quickreject_notify import ApplicationPublisherQuickRejectNotify
18from portality.events.consumers.application_publisher_accepted_notify import ApplicationPublisherAcceptedNotify
19from portality.events.consumers.update_request_publisher_accepted_notify import UpdateRequestPublisherAcceptedNotify
20from portality.events.consumers.application_publisher_assigned_notify import ApplicationPublisherAssignedNotify
21from portality.events.consumers.update_request_publisher_assigned_notify import UpdateRequestPublisherAssignedNotify
22from portality.events.consumers.journal_assed_assigned_notify import JournalAssedAssignedNotify
23from portality.events.consumers.journal_editor_group_assigned_notify import JournalEditorGroupAssignedNotify
24from portality.events.consumers.application_publisher_inprogress_notify import ApplicationPublisherInprogressNotify
25from portality.events.consumers.update_request_publisher_rejected_notify import UpdateRequestPublisherRejectedNotify
26from portality.events.consumers.journal_discontinuing_soon_notify import JournalDiscontinuingSoonNotify
27from portality.events.consumers.application_editor_acceptreject_notify import ApplicationEditorAcceptRejectNotify
28from portality.events.consumers.update_request_maned_editor_group_assigned_notify import UpdateRequestManedEditorGroupAssignedNotify
29from portality.events.consumers.article_ris_generator import ArticleRISGenerator
33class EventsService(object):
34 # disabled events - to enable move the event to EVENT_CONSUMERS array
35 DISABLED_EVENTS = [
36 ApplicationPublisherAssignedNotify, # https://github.com/DOAJ/doajPM/issues/3974
37 ApplicationPublisherInprogressNotify, # https://github.com/DOAJ/doajPM/issues/3974
38 ApplicationPublisherRevisionNotify,
39 JournalEditorGroupAssignedNotify, # https://github.com/DOAJ/doajPM/issues/3974
40 JournalAssedAssignedNotify, # https://github.com/DOAJ/doajPM/issues/3974
41 UpdateRequestPublisherAssignedNotify, # https://github.com/DOAJ/doajPM/issues/3974
42 ]
43 EVENT_CONSUMERS = [
44 AccountCreatedEmail,
45 AccountPasswordResetEmail,
46 ApplicationAssedAcceptRejectNotify,
47 ApplicationAssedAssignedNotify,
48 ApplicationAssedInprogressNotify,
49 ApplicationEditorAcceptRejectNotify,
50 ApplicationEditorCompletedNotify,
51 ApplicationEditorGroupAssignedNotify,
52 ApplicationEditorInProgressNotify,
53 ApplicationManedReadyNotify,
54 ApplicationPublisherAcceptedNotify,
55 ApplicationPublisherCreatedNotify,
56 ApplicationPublisherQuickRejectNotify,
57 ArticleRISGenerator,
58 BGJobFinishedNotify,
59 JournalDiscontinuingSoonNotify,
60 UpdateRequestManedEditorGroupAssignedNotify,
61 UpdateRequestPublisherAcceptedNotify,
62 UpdateRequestPublisherRejectedNotify,
63 UpdateRequestPublisherSubmittedNotify
64 ]
66 def __init__(self):
67 self.trigger_function = plugin.load_function(app.config.get("EVENT_SEND_FUNCTION"))
69 def trigger(self, event):
70 self.trigger_function(event)
72 def consume(self, event):
73 for consumer in self.EVENT_CONSUMERS:
74 try:
75 if consumer.should_consume(event):
76 consumer.consume(event)
77 except Exception as e:
78 app.logger.error("Error in consumer {x}: {e}".format(e=str(e), x=consumer.ID))