Automatically email all members of the applicable committee when a comment is left on an endorsed budget
This commit is contained in:
parent
4f84e8a99f
commit
e098ed4f01
@ -380,13 +380,29 @@ def budget_action(request, budget, revision):
|
||||
comment.content = request.POST['comment']
|
||||
comment.save()
|
||||
|
||||
emailer = Emailer()
|
||||
# Get users to email about the comment
|
||||
users_to_email = set()
|
||||
|
||||
# Email Treasury
|
||||
for user in User.objects.filter(groups__name='Treasury'):
|
||||
if user != request.user:
|
||||
emailer.send_mail([user.email], 'New comment on budget: {} (BU-{})'.format(revision.name, budget.id), 'sstreasury/email/budget_commented.md', {'revision': revision, 'comment': comment})
|
||||
users_to_email.add(user.email)
|
||||
|
||||
# Email contributors
|
||||
for user in revision.contributors.all():
|
||||
if user != request.user:
|
||||
emailer.send_mail([user.email], 'New comment on budget: {} (BU-{})'.format(revision.name, budget.id), 'sstreasury/email/budget_commented.md', {'revision': revision, 'comment': comment})
|
||||
users_to_email.add(user.email)
|
||||
|
||||
# If endorsed budget, email committee
|
||||
if revision.state == models.BudgetState.ENDORSED.value:
|
||||
for user in User.objects.filter(groups__name=revision.approver):
|
||||
if user != request.user:
|
||||
users_to_email.add(user.email)
|
||||
|
||||
# Send emails
|
||||
emailer = Emailer()
|
||||
for email in users_to_email:
|
||||
emailer.send_mail([email], 'New comment on budget: {} (BU-{})'.format(revision.name, budget.id), 'sstreasury/email/budget_commented.md', {'revision': revision, 'comment': comment})
|
||||
|
||||
if 'Submit' in actions:
|
||||
if not revision.can_submit(request.user):
|
||||
|
Loading…
Reference in New Issue
Block a user