def update_watchers(issue, created, comment=None):    
    site = Site.objects.get(id=settings.SITE_ID)
    context = Context({'issue': issue, 'project': issue.project, 'site': site})
    
    if comment:
        # issue commented
        context['comment'] = comment
        context['user_name'] = comment.user_name
        template = utils.MailTemplate('djtracker/mail/issue_commented.mail')
    elif created:
        template = utils.MailTemplate('djtracker/mail/issue_created.mail')
        try:
            issue.watched_by.add(issue.created)
        except:
            ## Anon user
            pass
    else:
        template = utils.MailTemplate('djtracker/mail/issue_updated.mail')
        
    # we send email to: all watchers, the creator and the current processor...
    email_addresses = list(issue.watched_by.all().values_list('user__email', flat=True))
    for addy in issue.project.watched_by.all().values_list('user__email', flat=True):
        if addy not in email_addresses:
            email_addresses.append(addy)
    if issue.created_by:
        try:
            email_addresses.append(issue.created_by.user.email)
        except __HOLE__:
            pass
    if issue.assigned_to:
        try: 
            email_addresses.append(issue.assigned_to.user.email)
        except ObjectDoesNotExist:
            pass
    # remove commenter from the list. Issue 13
    try:
        if email_addresses.index(comment.user_email):
            email_index = email_addresses.index(comment.user_email)
            email_addresses.pop(email_index)
    except:
        # user email doesn't exist, so we're not removing it.
        pass
    # make list unique
    email_addresses = {}.fromkeys(email_addresses).keys()
    
    # send mails seperately to protect privacy
    for recipient in email_addresses:
        msg = template.render_to_mail(context)
        msg.from_address = settings.ISSUE_ADDRESS
        msg.to = [recipient,]
        msg.send(fail_silently=True)
dataset/ETHPy150Open f4nt/djtracker/djtracker/__init__.py/update_watchers