From f4c4d952165b514fea0b10d4f4e727eb46667f2b Mon Sep 17 00:00:00 2001 From: Todd Dembrey <todd.dembrey@torchbox.com> Date: Wed, 14 Mar 2018 14:31:52 +0000 Subject: [PATCH] Exclude previous stages from the submission dashboard --- opentech/apply/funds/models.py | 4 ++++ opentech/apply/funds/views.py | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/opentech/apply/funds/models.py b/opentech/apply/funds/models.py index b4dd88d38..c17609a09 100644 --- a/opentech/apply/funds/models.py +++ b/opentech/apply/funds/models.py @@ -465,6 +465,10 @@ class ApplicationSubmissionQueryset(JSONOrderable): def inactive(self): return self.exclude(status__in=active_statuses) + def current(self): + # Applications which have the current stage active (have not been progressed) + return self.exclude(next__isnull=False) + class ApplicationSubmission(WorkflowHelpers, AbstractFormSubmission): field_template = 'funds/includes/submission_field.html' diff --git a/opentech/apply/funds/views.py b/opentech/apply/funds/views.py index 08724c968..5300f860a 100644 --- a/opentech/apply/funds/views.py +++ b/opentech/apply/funds/views.py @@ -30,6 +30,9 @@ class SubmissionListView(AllActivityContextMixin, SingleTableMixin, FilterView): filterset_class = SubmissionFilter + def get_queryset(self): + return self.filterset_class._meta.model.objects.current() + def get_context_data(self, **kwargs): active_filters = self.filterset.data return super().get_context_data(active_filters=active_filters, **kwargs) @@ -42,6 +45,9 @@ class SubmissionSearchView(SingleTableMixin, FilterView): filterset_class = SubmissionFilterAndSearch + def get_queryset(self): + return self.filterset_class._meta.model.objects.current() + def get_context_data(self, **kwargs): search_term = self.request.GET.get('query') @@ -103,7 +109,7 @@ class AdminSubmissionDetailView(ActivityContextMixin, DelegateableView): def get_context_data(self, **kwargs): return super().get_context_data( - other_submissions=self.model.objects.filter(user=self.object.user).exclude(id=self.object.id), + other_submissions=self.model.objects.filter(user=self.object.user).current().exclude(id=self.object.id), **kwargs, ) -- GitLab