It's better to delete an object in delete

This commit is contained in:
Antoine Bartuccio 2017-12-12 14:52:08 +01:00
parent 73bd8b0fd3
commit 5915de9603
Signed by: klmp200
GPG Key ID: E7245548C53F904B

View File

@ -158,6 +158,7 @@ class Candidature(models.Model):
def delete(self):
for vote in self.votes.all():
vote.delete()
super(Candidature, self).delete()
def can_be_edited_by(self, user):
return (user == self.user) or user.can_edit(self.role.election)