Add withdrawn reimbursement claim state
This commit is contained in:
parent
1344f612f8
commit
eb46c82ae1
@ -209,6 +209,7 @@ class BudgetRevision(models.Model):
|
||||
|
||||
class ClaimState(DescriptionEnum):
|
||||
DRAFT = 10, 'Draft'
|
||||
WITHDRAWN = 15, 'Withdrawn'
|
||||
RESUBMIT = 20, 'Returned for redrafting'
|
||||
AWAIT_REVIEW = 30, 'Awaiting Treasury approval'
|
||||
APPROVED = 40, 'Approved by Treasury, awaiting payment'
|
||||
@ -273,7 +274,7 @@ class ReimbursementClaim(models.Model):
|
||||
return False
|
||||
|
||||
# Only Treasurer may edit if submitted
|
||||
if self.state != ClaimState.DRAFT.value and self.state != ClaimState.RESUBMIT.value:
|
||||
if self.state not in (ClaimState.DRAFT.value, ClaimState.RESUBMIT.value, ClaimState.WITHDRAWN.value):
|
||||
if user.groups.filter(name='Treasury').exists():
|
||||
return True
|
||||
return False
|
||||
@ -290,7 +291,7 @@ class ReimbursementClaim(models.Model):
|
||||
def can_submit(self, user):
|
||||
if not self.can_edit(user):
|
||||
return False
|
||||
if self.state == ClaimState.DRAFT.value or self.state == ClaimState.RESUBMIT.value:
|
||||
if self.state in (ClaimState.DRAFT.value, ClaimState.RESUBMIT.value, ClaimState.WITHDRAWN.value):
|
||||
return True
|
||||
return False
|
||||
|
||||
@ -300,7 +301,7 @@ class ReimbursementClaim(models.Model):
|
||||
if user != self.author and not user.groups.filter(name='Treasury').exists():
|
||||
return False
|
||||
|
||||
if self.state == ClaimState.AWAIT_REVIEW.value or self.state == ClaimState.APPROVED.value:
|
||||
if self.state in (ClaimState.AWAIT_REVIEW.value, ClaimState.APPROVED.value, ClaimState.DRAFT.value, ClaimState.RESUBMIT.value):
|
||||
return True
|
||||
return False
|
||||
|
||||
@ -309,7 +310,7 @@ class ReimbursementClaim(models.Model):
|
||||
return False
|
||||
if not user.groups.filter(name='Treasury').exists():
|
||||
return False
|
||||
if self.state == ClaimState.DRAFT.value or self.state == ClaimState.RESUBMIT.value or self.state == ClaimState.AWAIT_REVIEW.value:
|
||||
if self.state in (ClaimState.DRAFT.value, ClaimState.RESUBMIT.value, ClaimState.AWAIT_REVIEW.value, ClaimState.WITHDRAWN.value):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -459,6 +459,9 @@ def claim_list(request):
|
||||
for claim in models.ReimbursementClaim.objects.all():
|
||||
state = models.ClaimState(claim.state)
|
||||
|
||||
if not claim.can_view(request.user):
|
||||
continue
|
||||
|
||||
group = None
|
||||
|
||||
if request.user.groups.filter(name='Treasury').exists() and state in [models.ClaimState.AWAIT_REVIEW, models.ClaimState.APPROVED]:
|
||||
@ -471,7 +474,7 @@ def claim_list(request):
|
||||
else:
|
||||
group = claims_closed
|
||||
elif request.user.groups.filter(name='Treasury').exists():
|
||||
if state == models.ClaimState.PAID:
|
||||
if state in [models.ClaimState.PAID, models.ClaimState.WITHDRAWN]:
|
||||
group = claims_closed
|
||||
else:
|
||||
group = claims_open
|
||||
@ -641,7 +644,7 @@ def claim_action(request, claim):
|
||||
raise PermissionDenied
|
||||
|
||||
with transaction.atomic():
|
||||
claim.update_state(request.user, models.ClaimState.DRAFT)
|
||||
claim.update_state(request.user, models.ClaimState.WITHDRAWN)
|
||||
|
||||
if 'Approve' in actions:
|
||||
if not claim.can_approve(request.user):
|
||||
|
Loading…
Reference in New Issue
Block a user