Skip to content

Commit

Permalink
Merge branch 'feature/admin-in-notif' into 'develop'
Browse files Browse the repository at this point in the history
Fix Issue #9

Add admin info in email notifications

See merge request !8
  • Loading branch information
vinilios committed Mar 23, 2015
2 parents a2746c0 + ce29ad9 commit 5f834e4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions helios/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,11 +615,13 @@ def notify_admins(self, msg='', subject='', send_anyway=False):
if send_anyway or (not self.trial):
election_type = self.get_module().module_id
trustees = self.trustees.all()
admins = self.admins.all()
context = {
'election': self,
'msg': msg,
'election_type': election_type,
'trustees': trustees,
'admins': admins,
'subject': subject,
}

Expand Down
4 changes: 4 additions & 0 deletions helios/templates/email/admin_mail.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@
* {{trustee.name}} {{trustee.email}}
{% endfor %}

- Election Admins
{% for admin in admins %}
* {{admin.id}} {{admin.user_id}} {{admin.institution.name}}
{% endfor %}
7 changes: 0 additions & 7 deletions zeus/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,6 @@ def save(self, *args, **kwargs):
saved.save()
if saved.feature_edit_trustees:
saved.update_trustees(trustees)

if self.creating:
saved.logger.info("Election created")
msg = "New election created"
subject = "New Zeus election"
saved.notify_admins(msg=msg, subject=subject)

else:
saved.logger.info("Election updated %r", self.changed_data)
self.log_changed_fields(saved)
Expand Down
5 changes: 5 additions & 0 deletions zeus/views/election.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ def add_or_update(request, election=None):
election = election_form.save()
if not election.admins.filter(pk=user.pk).count():
election.admins.add(user)
if election_form.creating:
election.logger.info("Election created")
msg = "New election created"
subject = "New Zeus election"
election.notify_admins(msg=msg, subject=subject)
# TODO, make this optional ?
if not election.has_helios_trustee():
election.generate_trustee()
Expand Down

0 comments on commit 5f834e4

Please sign in to comment.