diff --git a/opentech/apply/funds/models.py b/opentech/apply/funds/models.py index b4dd88d38ee20e51f7d252b8e7dab6fef5dc3a0e..c17609a09054b3779f5ea50bd0d2c5cbce94290c 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 08724c9683c266b28a37be59be85a966b1fd4cfd..5300f860a48032bbc2bceb38a2d69968cbb60c89 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, )