diff --git a/opentech/apply/dashboard/templates/dashboard/applicant_dashboard.html b/opentech/apply/dashboard/templates/dashboard/applicant_dashboard.html index 68b7dffa4277eb3d7bbf2fae22ca23bd75a50b5c..3330c4ebc5440d7ff490cdb8038b7d420c23635b 100644 --- a/opentech/apply/dashboard/templates/dashboard/applicant_dashboard.html +++ b/opentech/apply/dashboard/templates/dashboard/applicant_dashboard.html @@ -27,7 +27,7 @@ <h6 class="heading heading--no-margin heading--submission-meta"><span>Submitted:</span> {{ submission.submit_time.date }} by {{ submission.user.get_full_name }}</h6> </div> {% include "funds/includes/status_bar.html" with phases=submission.workflow status=submission.phase class="status-bar--small" %} - {% if request.user|can_edit:submission %} + {% if request.user|has_edit_perm:submission %} <a href="{% url 'funds:edit_submission' submission.id %}">Edit your submission</a> {% endif %} </div> diff --git a/opentech/apply/funds/models.py b/opentech/apply/funds/models.py index 41ee9b7bf1f51de5978123ecf8428bdcf00bf1b9..23a431b7a8282a6d26e8bf7ee2bf4f634c683b21 100644 --- a/opentech/apply/funds/models.py +++ b/opentech/apply/funds/models.py @@ -668,6 +668,18 @@ class ApplicationSubmission(WorkflowHelpers, BaseStreamForm, AbstractFormSubmiss def reviewed_by(self, user): return self.reviews.filter(author=user).exists() + def can_review(self, user): + if self.reviewed_by(user): + return False + + if user.is_apply_staff: + return True + + if user in self.missing_reviewer_reviews: + return True + + return False + def data_and_fields(self): for stream_value in self.form_fields: try: diff --git a/opentech/apply/funds/templates/funds/applicationsubmission_admin_detail.html b/opentech/apply/funds/templates/funds/applicationsubmission_admin_detail.html index c93706166fa8c7efb11cbaa632268b1c1cec06dd..61d32e9f726f34e9e82587f56ed852b8d602ff76 100644 --- a/opentech/apply/funds/templates/funds/applicationsubmission_admin_detail.html +++ b/opentech/apply/funds/templates/funds/applicationsubmission_admin_detail.html @@ -14,7 +14,7 @@ {% include 'funds/includes/review_table.html' %} - {% if request.user|can_review:object and not request.user|has_reviewed:object%} + {% if request.user|has_review_perm:object and request.user|can_review:object%} <a href="{% url 'apply:reviews:create' submission_pk=object.id %}" class="button button--primary">Create review</a> {% endif %} diff --git a/opentech/apply/funds/templates/funds/applicationsubmission_detail.html b/opentech/apply/funds/templates/funds/applicationsubmission_detail.html index 8c4e677836f4b3897d84a9a5df67ad80d614d0f8..4b02f221bd972f9dcd1488ca3e123f887380367c 100644 --- a/opentech/apply/funds/templates/funds/applicationsubmission_detail.html +++ b/opentech/apply/funds/templates/funds/applicationsubmission_detail.html @@ -40,7 +40,7 @@ <div> <h6 class="heading heading--submission-meta"> <span>Submitted: </span>{{ object.submit_time.date }} by {{ object.user.get_full_name }} - {% if request.user|can_edit:submission %} + {% if request.user|has_edit_perm:submission %} <a href="{% url 'funds:edit_submission' object.id %}">Edit</a> {% endif %} </h6> diff --git a/opentech/apply/funds/templatetags/workflow_tags.py b/opentech/apply/funds/templatetags/workflow_tags.py index 727101c2bba80205270ca4f25f72065e191aee65..87adb9ad8d8edc74fa0e3766e09d03adbd3b7505 100644 --- a/opentech/apply/funds/templatetags/workflow_tags.py +++ b/opentech/apply/funds/templatetags/workflow_tags.py @@ -8,10 +8,10 @@ def check_permission(user, perm, submission): @register.filter -def can_edit(user, submission): +def has_edit_perm(user, submission): return check_permission(user, 'edit', submission) @register.filter -def can_review(user, submission): +def has_review_perm(user, submission): return check_permission(user, 'review', submission) diff --git a/opentech/apply/review/templatetags/review_tags.py b/opentech/apply/review/templatetags/review_tags.py index 631b00b703a28e8e71a9482c788547b1178a7a13..5b6194c6aa0f31622f08ed527911c22b94f19319 100644 --- a/opentech/apply/review/templatetags/review_tags.py +++ b/opentech/apply/review/templatetags/review_tags.py @@ -33,5 +33,5 @@ def traffic_light(value): @register.filter -def has_reviewed(user, submission): - return submission.reviewed_by(user) +def can_review(user, submission): + return submission.can_review(user)