From 8d3a7b7ed08fb0e8f93b774878caa8d65280d3cb Mon Sep 17 00:00:00 2001 From: Yingtong Li Date: Mon, 1 May 2023 20:53:44 +1000 Subject: [PATCH] Tag budgets by cost centre, and allow filtering budgets by cost centre --- sstreasury/jinja2/sstreasury/budget_edit.html | 12 +++++++++++- sstreasury/jinja2/sstreasury/budget_list.html | 17 +++++++++++++---- sstreasury/jinja2/sstreasury/budget_view.html | 4 ++++ sstreasury/models.py | 3 ++- sstreasury/views.py | 7 +++++++ 5 files changed, 37 insertions(+), 6 deletions(-) diff --git a/sstreasury/jinja2/sstreasury/budget_edit.html b/sstreasury/jinja2/sstreasury/budget_edit.html index 0b3f3e2..4c84fc4 100644 --- a/sstreasury/jinja2/sstreasury/budget_edit.html +++ b/sstreasury/jinja2/sstreasury/budget_edit.html @@ -79,9 +79,19 @@ +
+ +
+ +
+
-
+
@@ -58,7 +58,16 @@ {% endfor %}
-
+
+ + +
+
@@ -94,11 +103,11 @@
diff --git a/sstreasury/jinja2/sstreasury/budget_view.html b/sstreasury/jinja2/sstreasury/budget_view.html index 4a279c6..6569877 100644 --- a/sstreasury/jinja2/sstreasury/budget_view.html +++ b/sstreasury/jinja2/sstreasury/budget_view.html @@ -113,6 +113,10 @@
+ + Cost centre + {{ revision.cost_centre }} + Responsible committee {{ dict(settings.AVAILABLE_APPROVERS)[revision.approver][0] }} diff --git a/sstreasury/models.py b/sstreasury/models.py index 3ab704d..706e21a 100644 --- a/sstreasury/models.py +++ b/sstreasury/models.py @@ -64,11 +64,12 @@ class BudgetRevision(models.Model): name = models.CharField(max_length=100) date = models.DateField() contributors = models.ManyToManyField(User, related_name='+') + cost_centre = models.CharField(max_length=100) + approver = models.CharField(max_length=100) comments = models.TextField() author = models.ForeignKey(User, on_delete=models.PROTECT, related_name='+') time = models.DateTimeField() - approver = models.CharField(max_length=100) event_dt = models.DateTimeField(null=True) event_attendees = models.CharField(max_length=20, null=True) diff --git a/sstreasury/views.py b/sstreasury/views.py index 9ddd274..cc5531c 100644 --- a/sstreasury/views.py +++ b/sstreasury/views.py @@ -148,6 +148,11 @@ def revision_from_form(budget, revision, form): else: contributors = [] + if form['cost_centre'] in settings.BUDGET_COST_CENTRES: + revision.cost_centre = form['cost_centre'] + else: + errors.append('Cost centre is invalid') + if form['approver'] in dict(settings.AVAILABLE_APPROVERS): revision.approver = form['approver'] else: @@ -219,6 +224,8 @@ def budget_list(request): if request.GET.get('state', 'all') != 'all' and str(revision.state) != request.GET.get('state', 'all'): continue + if request.GET.get('cost_centre', 'all') != 'all' and revision.cost_centre != request.GET.get('cost_centre', 'all'): + continue if request.GET.get('year', '') != '' and str(revision.time.year) != request.GET.get('year', ''): continue