Skip to content

Commit

Permalink
Merge pull request #2983 from HyphaApp/enhancement/implement_SUBMISSI…
Browse files Browse the repository at this point in the history
…ONS_DRAFT_ACCESS_STAFF

Add a SUBMISSIONS_DRAFT_ACCESS_STAFF to control if staff can see application draft or not
  • Loading branch information
frjo authored Sep 20, 2022
2 parents f4fdc09 + dd769cd commit 7968687
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions hypha/apply/funds/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,11 @@ def get_filterset_kwargs(self, filterset_class, **kwargs):
return new_kwargs

def get_queryset(self):
return self.filterset_class._meta.model.objects.exclude_draft().current().for_table(self.request.user)
submissions = self.filterset_class._meta.model.objects.current().for_table(self.request.user)
if settings.SUBMISSIONS_DRAFT_ACCESS_STAFF:
return submissions
else:
return submissions.exclude_draft()

def get_context_data(self, **kwargs):
search_term = self.request.GET.get('query')
Expand Down Expand Up @@ -765,7 +769,7 @@ class AdminSubmissionDetailView(ReviewContextMixin, ActivityContextMixin, Delega

def dispatch(self, request, *args, **kwargs):
submission = self.get_object()
if submission.status == DRAFT_STATE and not request.user == submission.user:
if submission.status == DRAFT_STATE and not request.user == submission.user and not settings.SUBMISSIONS_DRAFT_ACCESS_STAFF:
raise Http404
redirect = SubmissionSealedView.should_redirect(request, submission)
return redirect or super().dispatch(request, *args, **kwargs)
Expand Down
3 changes: 3 additions & 0 deletions hypha/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,9 @@
# Possible values are: fund, round, status, lead, reviewers, screening_statuses, category_options, meta_terms
SUBMISSIONS_TABLE_EXCLUDED_FIELDS = env.list('SUBMISSIONS_TABLE_EXCLUDED_FIELDS', [])

# Draft submissions access.
SUBMISSIONS_DRAFT_ACCESS_STAFF = env.bool('SUBMISSIONS_DRAFT_ACCESS_STAFF', False)

# Celery config
if env.str('REDIS_URL', None):
CELERY_BROKER_URL = env.str('REDIS_URL')
Expand Down

0 comments on commit 7968687

Please sign in to comment.