Coverage for portality/bll/services/events.py: 100%

43 statements  

« prev     ^ index     » next       coverage.py v7.17.3, created at 2026-11-20 13:43 +0000

1from portality.core import app 

2from portality.events.consumers.update_request_publisher_submitted_notify import UpdateRequestPublisherSubmittedNotify 

3from portality.lib import plugin 

4 

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 

30from portality.events.consumers.flag_assigned import FlagAssigned 

31 

32 

33 

34class EventsService(object): 

35 # disabled events - to enable move the event to EVENT_CONSUMERS array 

36 DISABLED_EVENTS = [ 

37 ApplicationPublisherAssignedNotify, # https://github.com/DOAJ/doajPM/issues/3974 

38 ApplicationPublisherInprogressNotify, # https://github.com/DOAJ/doajPM/issues/3974 

39 ApplicationPublisherRevisionNotify, 

40 JournalEditorGroupAssignedNotify, # https://github.com/DOAJ/doajPM/issues/3974 

41 JournalAssedAssignedNotify, # https://github.com/DOAJ/doajPM/issues/3974 

42 UpdateRequestPublisherAssignedNotify, # https://github.com/DOAJ/doajPM/issues/3974 

43 ] 

44 EVENT_CONSUMERS = [ 

45 AccountCreatedEmail, 

46 AccountPasswordResetEmail, 

47 ApplicationAssedAcceptRejectNotify, 

48 ApplicationAssedAssignedNotify, 

49 ApplicationAssedInprogressNotify, 

50 ApplicationEditorAcceptRejectNotify, 

51 ApplicationEditorCompletedNotify, 

52 ApplicationEditorGroupAssignedNotify, 

53 ApplicationEditorInProgressNotify, 

54 ApplicationManedReadyNotify, 

55 ApplicationPublisherAcceptedNotify, 

56 ApplicationPublisherCreatedNotify, 

57 ApplicationPublisherQuickRejectNotify, 

58 ArticleRISGenerator, 

59 FlagAssigned, 

60 BGJobFinishedNotify, 

61 JournalDiscontinuingSoonNotify, 

62 UpdateRequestManedEditorGroupAssignedNotify, 

63 UpdateRequestPublisherAcceptedNotify, 

64 UpdateRequestPublisherRejectedNotify, 

65 UpdateRequestPublisherSubmittedNotify 

66 ] 

67 

68 def __init__(self): 

69 self.trigger_function = plugin.load_function(app.config.get("EVENT_SEND_FUNCTION")) 

70 

71 def trigger(self, event): 

72 self.trigger_function(event) 

73 

74 def consume(self, event): 

75 for consumer in self.EVENT_CONSUMERS: 

76 try: 

77 if consumer.should_consume(event): 

78 consumer.consume(event) 

79 except Exception as e: 

80 app.logger.error("Error in consumer {x}: {e}".format(e=str(e), x=consumer.ID))