Hide election detail parts when user cannot candidate or edit.

This commit is contained in:
Jean-Baptiste Lenglet
2016-12-22 22:00:02 +01:00
committed by klmp200
parent a3a5a0446d
commit dfcddbd1fa
3 changed files with 57 additions and 17 deletions

View File

@ -39,6 +39,12 @@ class Election(models.Model):
def has_voted(self, user):
return hasattr(user, 'has_voted') and user.has_voted.all() == list(self.role.all())
def can_candidate(self, user):
for group in self.candidature_groups.all():
if user.is_in_group(group):
return True
return False
# Permissions