def comment_post_save(sender, instance, created=False, **kwargs): # who should receive notification of this comment? # - the issue's contact # - the issue assignee if the issue has one # - if issue has no assignee, all operators send_to = [ instance.issue.contact.email, ] if instance.issue.assignee: send_to.append(instance.issue.assignee.email) else: operators = [op.email for op in Operator.objects.all()] send_to.extend(operators) to_addr = ", ".join(send_to) if created: notify( "comment_added", { "issue": instance.issue, "comment": instance }, settings.DEFAULT_FROM_ADDR, to_addr, ) # trigger save on issue, to reindex instance.issue.save()
def comment_post_save(sender, instance, created=False, **kwargs): # who should receive notification of this comment? # - the issue's contact # - the issue assignee if the issue has one # - if issue has no assignee, all operators send_to = [instance.issue.contact.email, ] if instance.issue.assignee: send_to.append(instance.issue.assignee.email) else: operators = [op.email for op in Operator.objects.all()] send_to.extend(operators) to_addr = ", ".join(send_to) if created: notify("comment_added", {"issue": instance.issue, "comment": instance}, settings.DEFAULT_FROM_ADDR, to_addr, ) # trigger save on issue, to reindex instance.issue.save()
def issue_post_save(sender, instance, created=False, **kwargs): if created: operators = [op.email for op in Operator.objects.all()] if operators: notify("issue_created", {"issue": instance}, settings.DEFAULT_FROM_ADDR, ", ".join(operators))
def issue_post_save(sender, instance, created=False, **kwargs): if created: operators = [op.user.email for op in Operator.objects.all()] if operators: notify("issue_created", {"issue": instance}, settings.DEFAULT_FROM_ADDR, ", ".join(operators))
def status_post_save(sender, instance, created=False, **kwargs): if not created: return instance.issue.status = instance.name instance.issue.save() if instance.name == settings.ISSUE_STATUS_CLOSED: notify("issue_closed", {"issue": instance.issue, "comment": instance.comment}, instance.issue.email_from, instance.issue.contact.email) else: notify("issue_status", {"issue": instance.issue, "comment": instance.comment}, instance.issue.email_from, instance.issue.contact.email)
def status_post_save(sender, instance, created=False, **kwargs): if not created: return instance.issue.status = instance.name instance.issue.save() if instance.name == settings.ISSUE_STATUS_CLOSED: notify("issue_closed", { "issue": instance.issue, "comment": instance.comment }, instance.issue.email_from, instance.issue.contact.email) else: notify("issue_status", { "issue": instance.issue, "comment": instance.comment }, instance.issue.email_from, instance.issue.contact.email)
def test_notify(self): settings.NOTIFICATION_BLACKLIST = [ "*****@*****.**", "*****@*****.**" ] context = { "from": "*****@*****.**", "to": "*****@*****.**", "issue": TestIssue() } notify("issue_created", context, "*****@*****.**", "*****@*****.**") try: notification = NotificationsBin.receive() self.fail("We should not have mail!") except: pass notify("issue_created", context, "*****@*****.**", "[email protected], [email protected]") try: notification = NotificationsBin.receive() self.fail("We should not have mail!") except: pass notify("issue_created", context, "*****@*****.**", "[email protected], [email protected]") try: notification = NotificationsBin.receive() except: self.fail("We should have mail!") # reset... settings.NOTIFICATION_BLACKLIST = []
def test_notify(self): settings.NOTIFICATION_BLACKLIST = ["*****@*****.**", "*****@*****.**"] context = {"from": "*****@*****.**", "to": "*****@*****.**", "issue": TestIssue()} notify("issue_created", context, "*****@*****.**", "*****@*****.**") try: notification = NotificationsBin.receive() self.fail("We should not have mail!") except: pass notify("issue_created", context, "*****@*****.**", "[email protected], [email protected]") try: notification = NotificationsBin.receive() self.fail("We should not have mail!") except: pass notify("issue_created", context, "*****@*****.**", "[email protected], [email protected]") try: notification = NotificationsBin.receive() except: self.fail("We should have mail!") # reset... settings.NOTIFICATION_BLACKLIST = []