verb=PenaltyVerb, object=penalty, target=penalty.user, time=penalty.created_at, extra_context={ 'reason': penalty.reason, 'weight': penalty.weight, }) def handle_create(self, penalty): activity = self.get_activity(penalty) self.manager.add_activity(activity, [penalty.user.pk], [NotificationFeed]) # Send Notification notification = PenaltyNotification(penalty.user, penalty=penalty) notification.notify() def handle_update(self, penalty): activity = self.get_activity(penalty) self.manager.add_activity(activity, [penalty.user.pk], [NotificationFeed]) def handle_delete(self, penalty): activity = self.get_activity(penalty) self.manager.remove_activity(activity, [penalty.user.pk], [NotificationFeed]) register_handler(PenaltyHandler)
activity = Activity(actor=restricted_mail.created_by, verb=RestrictedMailSent, object=restricted_mail, time=restricted_mail.used, extra_context={}) self.manager.add_activity(activity, [restricted_mail.created_by.pk], [NotificationFeed]) # Send notification notification = RestrictedMailSentNotification( restricted_mail.created_by) notification.notify() def handle_failure(self, sender, reason): """ Notify about restricted mail failure. This action is not connected to a specific user. We sends a message to the sender instead of a user. We use the send_mail task directly because of this. """ send_email.delay( to_email=sender, context={'reason': reason}, subject=f'Kunne ikke sende ut begrenset epost', plain_template='restricted/email/process_failure.txt', html_template='restricted/email/process_failure.html', ) register_handler(RestrictedHandler)
group = membership.abakus_group if group.type not in (GROUP_COMMITTEE, GROUP_INTEREST): return activity = self.get_activity(membership) # Add activity to feed on the user profile site. self.manager.add_activity(activity, [membership.user_id], [UserFeed]) # Add activity to followers timeline. followers = membership.user.followers\ .exclude(follower_id=membership.user_id)\ .values_list('follower_id', flat=True) self.manager.add_activity(activity, followers, [PersonalFeed]) def handle_update(self, membership): pass def handle_delete(self, membership): pass def get_activity(self, membership): return Activity(verb=GroupJoinVerb, actor=membership.user, target=membership.abakus_group, object=membership, time=membership.created_at, extra_context={}) register_handler(MembershipHandler)
pass def handle_update(self, announcement): pass def handle_delete(self, announcement): pass def handle_send(self, announcement): if not announcement.created_by: return activity = Activity( actor=announcement.created_by, verb=AnnouncementVerb, object=announcement, time=announcement.created_at, extra_context={} ) recipients = announcement.lookup_recipients() self.manager.add_activity( activity, [recipient.pk for recipient in recipients], [NotificationFeed, PersonalFeed] ) # Send notifications for recipient in recipients: notification = AnnouncementNotification(recipient, announcement=announcement) notification.notify() register_handler(AnnouncementHandler)
] self.manager.add_activity(activity, [recipient.pk for recipient in recipients], [NotificationFeed]) for recipient in recipients: notification = CompanyInterestNotification( recipient, company_interest=company_interest) notification.notify() send_email.delay( to_email=f'bedriftskontakt@{settings.GSUITE_DOMAIN}', context=company_interest.generate_mail_context(), subject='En ny bedrift har meldt sin interesse', plain_template='companies/email/company_interest.txt', html_template='companies/email/company_interest.html', ) def handle_create(self, company_interest): pass def handle_update(self, company_interest): pass def handle_delete(self, company_interest): pass register_handler(CompanyInterestHandler)
self.manager.add_activity(activity, recipients, feeds) def handle_update(self, event): pass def handle_delete(self, event): activity = self.get_activity(event) for feeds, recipients in self.get_feeds_and_recipients(event): self.manager.remove_activity(activity, recipients, feeds) def get_feeds_and_recipients(self, event): result = [] if event.company_id: result.append( ([PersonalFeed], list( event.company.followers.values_list('follower__id', flat=True)))) result.append(([CompanyFeed], [event.company_id])) return result def get_activity(self, event): return Activity(actor=event.company, verb=EventCreateVerb, object=event, time=event.created_at, extra_context={'title': event.title}) register_handler(EventHandler)
def handle_update(self, comment): """ No support for comment updates... """ pass def handle_delete(self, comment): activity = self.get_activity(comment) for feeds, recipients in self.get_feeds_and_recipients(comment): self.manager.remove_activity( activity, [recipient.pk for recipient in recipients], feeds) def get_feeds_and_recipients(self, comment): result = [] if hasattr(comment.content_object, 'followers'): author = comment.created_by followers = comment.content_object.followers.all().select_related( 'follower') result.append(([PersonalFeed, NotificationFeed], [ follow.follower for follow in followers if not follow.follower == author ])) if comment.created_by: result.append(([UserFeed], [comment.created_by])) return result register_handler(CommentHandler)
object=registration, target=registration.user) self.manager.add_activity(activity, [registration.user_id], [NotificationFeed]) # Send Notification notification = EventAdminRegistrationNotification( registration.user, event=registration.event, reason=registration.admin_registration_reason) notification.notify() def handle_admin_unregistration(self, registration): activity = Activity(actor=registration.event, verb=AdminUnregistrationVerb, object=registration, target=registration.user) self.manager.add_activity(activity, [registration.user_id], [NotificationFeed]) # Send Notification notification = EventAdminUnregistrationNotification( registration.user, event=registration.event, reason=registration.admin_unregistration_reason, creator=registration.event.created_by) notification.notify() register_handler(RegistrationHandler)
def get_activity(self, meeting_invitation): return Activity(actor=meeting_invitation.created_by, verb=MeetingInvitationVerb, object=meeting_invitation, target=meeting_invitation.user, time=meeting_invitation.created_at) def handle_create(self, meeting_invitation): activity = self.get_activity(meeting_invitation) self.manager.add_activity(activity, [meeting_invitation.user.pk], [NotificationFeed]) # Send notification notification = MeetingInvitationNotification( meeting_invitation.user, meeting_invitation=meeting_invitation) notification.notify() def handle_update(self, meeting_invitation): activity = self.get_activity(meeting_invitation) self.manager.add_activity(activity, [meeting_invitation.user.pk], [NotificationFeed]) def handle_delete(self, meeting_invitation): activity = self.get_activity(meeting_invitation) self.manager.remove_activity(activity, [meeting_invitation.user.pk], [NotificationFeed]) register_handler(MeetingInvitationHandler)