diff --git a/opentech/apply/dashboard/templates/dashboard/community_dashboard.html b/opentech/apply/dashboard/templates/dashboard/community_dashboard.html index 27d49cb7d291e6ab53e0e9cfd8dd4021cdcd3cb8..54d510d4fc8295c50a067bec3656ab0e8ac3e747 100644 --- a/opentech/apply/dashboard/templates/dashboard/community_dashboard.html +++ b/opentech/apply/dashboard/templates/dashboard/community_dashboard.html @@ -66,10 +66,10 @@ {% endfor %} </div> - {% if my_inactive_submissions_table.data %} + {% if my_inactive_submissions.data %} <div class="wrapper wrapper--bottom-space"> <h4 class="heading heading--normal">Submission history</h4> - {% render_table my_inactive_submissions_table %} + {% render_table my_inactive_submissions %} </div> {% endif %} </div> diff --git a/opentech/apply/dashboard/templates/dashboard/partner_dashboard.html b/opentech/apply/dashboard/templates/dashboard/partner_dashboard.html index 7bbd5c51461d7a5a46ea27b3e49b6ab361863e34..ad7443b2f15021d89810c5697d96e5056914e173 100644 --- a/opentech/apply/dashboard/templates/dashboard/partner_dashboard.html +++ b/opentech/apply/dashboard/templates/dashboard/partner_dashboard.html @@ -60,10 +60,10 @@ {% endfor %} </div> - {% if my_inactive_submissions_table.data %} + {% if my_inactive_submissions.data %} <div class="wrapper wrapper--bottom-space"> <h4 class="heading heading--normal">Submission history</h4> - {% render_table my_inactive_submissions_table %} + {% render_table my_inactive_submissions %} </div> {% endif %} </div> diff --git a/opentech/apply/dashboard/templates/dashboard/reviewer_dashboard.html b/opentech/apply/dashboard/templates/dashboard/reviewer_dashboard.html index 70d41e53cb4308ad38bab2dcddbcdc8f43025894..e95f835c120404c61c0e978fc9f23a14b3c4a3eb 100644 --- a/opentech/apply/dashboard/templates/dashboard/reviewer_dashboard.html +++ b/opentech/apply/dashboard/templates/dashboard/reviewer_dashboard.html @@ -63,10 +63,10 @@ {% endfor %} </div> - {% if my_inactive_submissions_table.data %} + {% if my_inactive_submissions.data %} <div class="wrapper wrapper--bottom-space"> <h4 class="heading heading--normal">Submission history</h4> - {% render_table my_inactive_submissions_table %} + {% render_table my_inactive_submissions %} </div> {% endif %} </div> diff --git a/opentech/apply/dashboard/views.py b/opentech/apply/dashboard/views.py index 91a41a7edaae9395f8d073ca20f4c0922f82cf4f..098a172cf4953be16aed6e54867244893a3ecaa1 100644 --- a/opentech/apply/dashboard/views.py +++ b/opentech/apply/dashboard/views.py @@ -109,7 +109,7 @@ class ReviewerDashboardView(TemplateView): active_statuses_filter = ''.join(f'&status={status}' for status in review_filter_for_user(request.user)) # Applications by reviewer - my_submissions, my_inactive_submissions_table = self.get_my_submissions(request, qs) + my_submissions, my_inactive_submissions = self.get_my_submissions(request, qs) context = { 'my_review': my_review, @@ -120,7 +120,7 @@ class ReviewerDashboardView(TemplateView): 'filter': filterset, 'active_statuses_filter': active_statuses_filter, 'my_submissions': my_submissions, - 'my_inactive_submissions_table': my_inactive_submissions_table, + 'my_inactive_submissions': my_inactive_submissions, } return render(request, 'dashboard/reviewer_dashboard.html', context) @@ -213,14 +213,14 @@ class PartnerDashboardView(TemplateView): my_reviewed_qs, my_reviewed = self.get_my_reviewed(self.request, qs) # Applications by partner - my_submissions, my_inactive_submissions_table = self.get_my_submissions(self.request, qs) + my_submissions, my_inactive_submissions = self.get_my_submissions(self.request, qs) context.update({ 'partner_submissions': partner_submissions, 'partner_submissions_count': partner_submissions_qs.count(), 'my_reviewed': my_reviewed, 'my_submissions': my_submissions, - 'my_inactive_submissions_table': my_inactive_submissions_table, + 'my_inactive_submissions': my_inactive_submissions, }) return context @@ -266,14 +266,14 @@ class CommunityDashboardView(TemplateView): my_reviewed_qs, my_reviewed = self.get_my_reviewed(self.request, qs) # Applications by partner - my_submissions, my_inactive_submissions_table = self.get_my_submissions(self.request, qs) + my_submissions, my_inactive_submissions = self.get_my_submissions(self.request, qs) context.update({ 'my_community_review': my_community_review, 'my_community_review_count': my_community_review_qs.count(), 'my_reviewed': my_reviewed, 'my_submissions': my_submissions, - 'my_inactive_submissions_table': my_inactive_submissions_table, + 'my_inactive_submissions': my_inactive_submissions, }) return context diff --git a/opentech/apply/funds/models/submissions.py b/opentech/apply/funds/models/submissions.py index 9744ff26cf9802cae23d476b2862366ca3b6faed..4eaf78a927948548b00cf7ce14334b62e59dceba 100644 --- a/opentech/apply/funds/models/submissions.py +++ b/opentech/apply/funds/models/submissions.py @@ -34,6 +34,7 @@ from ..workflow import ( active_statuses, DETERMINATION_RESPONSE_PHASES, get_review_active_statuses, + get_edit_or_review_active_statuses, INITIAL_STATE, PHASES, review_statuses, @@ -102,7 +103,8 @@ class ApplicationSubmissionQueryset(JSONOrderable): return self.filter(reviews__author=user) def partner_for(self, user): - return self.filter(partners=user) + user_edit_review_statuses = get_edit_or_review_active_statuses(user) + return self.filter(partners=user, status__in=user_edit_review_statuses) def awaiting_determination_for(self, user): return self.filter(status__in=DETERMINATION_RESPONSE_PHASES).filter(lead=user) diff --git a/opentech/apply/funds/workflow.py b/opentech/apply/funds/workflow.py index 76958755c06ec00360f7d7accdd61c8a29703bb0..ece64e35acf61ea41463fc7e5fa7910dfa028c8f 100644 --- a/opentech/apply/funds/workflow.py +++ b/opentech/apply/funds/workflow.py @@ -871,6 +871,18 @@ def get_review_active_statuses(user=None): return reviews +def get_edit_or_review_active_statuses(user=None): + statuses = set() + + for phase_name, phase in PHASES: + if phase_name in active_statuses: + if user is None: + statuses.add(phase_name) + elif phase.permissions.can_review(user) or phase.permissions.can_edit(user): + statuses.add(phase_name) + return statuses + + def get_review_statuses(user=None): reviews = set()