Fix withdraw permission logic

This commit is contained in:
Yingtong Li 2020-06-07 21:36:10 +10:00
parent 74d4c7b333
commit a1aa2423ad
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -160,8 +160,11 @@ class BudgetRevision(models.Model):
return False return False
def can_withdraw(self, user): def can_withdraw(self, user):
if not self.can_edit(user): if not self.can_view(user):
return False return False
if user != self.author and user not in self.contributors.all() and not user.groups.filter(name='Treasury').exists():
return False
if self.state == BudgetState.AWAIT_REVIEW.value or self.state == BudgetState.ENDORSED.value: if self.state == BudgetState.AWAIT_REVIEW.value or self.state == BudgetState.ENDORSED.value:
return True return True
return False return False