summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYingtong Li <runassudo@yingtongli.me>2020-07-15 17:03:52 +1000
committerYingtong Li <runassudo@yingtongli.me>2020-07-15 17:03:52 +1000
commiteb46c82ae1370d5fcc8f80e5dd799af5dc8312a4 (patch)
tree0af8fbd6e4f756859e093489196e0074556fb98f
parent1344f612f8cb5b9c190ddf276557b8485d768ccc (diff)
Add withdrawn reimbursement claim state
-rw-r--r--sstreasury/models.py9
-rw-r--r--sstreasury/views.py7
2 files changed, 10 insertions, 6 deletions
diff --git a/sstreasury/models.py b/sstreasury/models.py
index 6e2342b..02f2a01 100644
--- a/sstreasury/models.py
+++ b/sstreasury/models.py
@@ -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
diff --git a/sstreasury/views.py b/sstreasury/views.py
index 67b5a7d..2c993bf 100644
--- a/sstreasury/views.py
+++ b/sstreasury/views.py
@@ -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):
Contact (issues, pull requests, etc.) at git@yingtongli.me. Generated by cgit.