def comment_signal_handler(sender, **kwargs): """ All watchers of a decision will get a notification informing them of new comment. All watchers become observers of the comment. """ instance = kwargs.get('instance') headers = { 'Message-ID': "comment-%s@%s" % (instance.id, Site.objects.get_current().domain), 'In-Reply-To': instance.content_object.get_message_id(), 'References': ' '.join(( instance.content_object.decision.get_message_id(), instance.content_object.get_message_id())) } headers.update(STANDARD_SENDING_HEADERS) instance.content_object.decision.note_external_modification() if kwargs.get('created', True): # Creator gets notified if the comment is edited. notification.observe(instance, instance.user, 'comment_change') #All watchers of parent get notified of new comment. all_observed_items_but_author = list(instance.content_object.decision.watchers.exclude(user=instance.user)) observer_list = [x.user for x in all_observed_items_but_author] extra_context = dict({"observed": instance}) notification.send(observer_list, "comment_new", extra_context, headers, from_email=instance.content_object.decision.get_email()) else: send_observation_notices_for(instance, headers=headers, from_email=instance.content_object.decision.get_email())
def feedback_signal_handler(sender, **kwargs): """ All watchers of a decision will get a notification informing them of new feedback. All watchers become observers of the feedback. """ instance = kwargs.get('instance') headers = { 'Message-ID': instance.get_message_id(), 'In-Reply-To': instance.decision.get_message_id(), 'References': instance.decision.get_message_id() } headers.update(STANDARD_SENDING_HEADERS) instance.decision.note_external_modification() if kwargs.get('created', True): #author gets notified if the feedback is edited. notification.observe(instance, instance.author, 'feedback_change') #All watchers of parent get notified of new feedback. all_observed_items_but_authors = list(instance.decision.watchers.exclude(user=instance.author)) observer_list = [x.user for x in all_observed_items_but_authors] extra_context = dict({"observed": instance}) notification.send(observer_list, "feedback_new", extra_context, headers, from_email=instance.decision.get_email()) else: # An edit by someone other than the author never counts as minor if instance.author != instance.editor or not instance.minor_edit: send_observation_notices_for(instance, headers=headers, from_email=instance.decision.get_email())
def comment_signal_handler(sender, **kwargs): """ All watchers of a decision will get a notification informing them of new comment. All watchers become observers of the comment. """ instance = kwargs.get('instance') headers = { 'Message-ID': "comment-%s@%s" % (instance.id, Site.objects.get_current().domain) } headers.update( {'In-Reply-To': instance.content_object.get_message_id()}) if kwargs.get('created', True): # Creator gets notified if the comment is edited. notification.observe(instance, instance.user, 'comment_change') #All watchers of parent get notified of new comment. all_observed_items_but_author = list( instance.content_object.decision.watchers.exclude( user=instance.user)) observer_list = [x.user for x in all_observed_items_but_author] extra_context = dict({"observed": instance}) notification.send( observer_list, "comment_new", extra_context, headers, from_email=instance.content_object.decision.get_email()) else: send_observation_notices_for( instance, headers=headers, from_email=instance.content_object.decision.get_email())
def feedback_signal_handler(sender, **kwargs): """ All watchers of a decision will get a notification informing them of new feedback. All watchers become observers of the feedback. """ instance = kwargs.get('instance') headers = {'Message-ID': instance.get_message_id()} headers.update({'In-Reply-To': instance.decision.get_message_id()}) if kwargs.get('created', True): #author gets notified if the feedback is edited. notification.observe(instance, instance.author, 'feedback_change') #All watchers of parent get notified of new feedback. all_observed_items_but_authors = list( instance.decision.watchers.exclude(user=instance.author)) observer_list = [x.user for x in all_observed_items_but_authors] extra_context = dict({"observed": instance}) notification.send(observer_list, "feedback_new", extra_context, headers, from_email=instance.decision.get_email()) else: if instance.author != instance.editor: send_observation_notices_for( instance, headers=headers, from_email=instance.decision.get_email())
def decision_signal_handler(sender, **kwargs): """ All users except the author will get a notification informing them of new content. All users are made observers of the decision. Notices are sent for observed decisions when feedback changes. """ instance = kwargs.get('instance') headers = {'Message-ID': instance.get_message_id()} if kwargs.get('created', True): active_users = instance.organization.users.filter(is_active=True) all_but_author = active_users.exclude(username=instance.author) for user in active_users: notification.observe(instance, user, 'decision_change') extra_context = {} extra_context.update({"observed": instance}) notification.send(all_but_author, "decision_new", extra_context, headers, from_email=instance.get_email()) else: send_observation_notices_for(instance, headers=headers, from_email=instance.get_email())
def decision_signal_handler(sender, **kwargs): """ All users except the author will get a notification informing them of new content. All users are made observers of the decision. Notices are sent for observed decisions when feedback changes. """ instance = kwargs.get('instance') headers = {'Message-ID' : instance.get_message_id()} if kwargs.get('created', True): all_users = instance.organization.users.all() all_but_author = all_users.exclude(username=instance.author) for user in all_users: notification.observe(instance, user, 'decision_change') extra_context = {} extra_context.update({"observed": instance}) notification.send(all_but_author, "decision_new", extra_context, headers, from_email=instance.get_email()) else: send_observation_notices_for(instance, headers=headers, from_email=instance.get_email())
def feedback_signal_handler(sender, **kwargs): """ All watchers of a decision will get a notification informing them of new feedback. All watchers become observers of the feedback. """ instance = kwargs.get('instance') headers = {'Message-ID' : instance.get_message_id()} headers.update({'In-Reply-To' : instance.decision.get_message_id()}) if kwargs.get('created', True): #author gets notified if the feedback is edited. notification.observe(instance, instance.author, 'feedback_change') #All watchers of parent get notified of new feedback. all_observed_items_but_authors = list(instance.decision.watchers.exclude(user=instance.author)) observer_list = [x.user for x in all_observed_items_but_authors] extra_context = dict({"observed": instance}) notification.send(observer_list, "feedback_new", extra_context, headers, from_email=instance.decision.get_email()) else: if instance.author != instance.editor: send_observation_notices_for(instance, headers=headers, from_email=instance.decision.get_email())
def feedback_signal_handler(sender, **kwargs): """ All watchers of a decision will get a notification informing them of new feedback. All watchers become observers of the feedback. """ instance = kwargs.get('instance') headers = { 'Message-ID': instance.get_message_id(), 'In-Reply-To': instance.decision.get_message_id(), 'References': instance.decision.get_message_id() } headers.update(STANDARD_SENDING_HEADERS) instance.decision.note_external_modification() if kwargs.get('created', True): #author gets notified if the feedback is edited. notification.observe(instance, instance.author, 'feedback_change') #All watchers of parent get notified of new feedback. all_observed_items_but_authors = list( instance.decision.watchers.exclude(user=instance.author)) observer_list = [x.user for x in all_observed_items_but_authors] extra_context = dict({"observed": instance}) notification.send(observer_list, "feedback_new", extra_context, headers, from_email=instance.decision.get_email()) else: # An edit by someone other than the author never counts as minor if instance.author != instance.editor or not instance.minor_edit: send_observation_notices_for( instance, headers=headers, from_email=instance.decision.get_email())
def _send_change_notifications(self): headers = {'Message-ID': self.get_message_id()} headers.update(STANDARD_SENDING_HEADERS) send_observation_notices_for(self, headers=headers, from_email=self.get_email())
def _send_change_notifications(self): headers = {'Message-ID': self.get_message_id()} headers.update(STANDARD_SENDING_HEADERS) send_observation_notices_for( self, headers=headers, from_email=self.get_email())