From bfb14e516a39db2e4b81b3273f642a4a360e0061 Mon Sep 17 00:00:00 2001 From: Todd Dembrey <todd.dembrey@torchbox.com> Date: Thu, 6 Sep 2018 12:14:58 +0100 Subject: [PATCH] Make sure we dont show links where we shouldnt --- opentech/apply/activity/messaging.py | 6 +++--- .../templates/activity/include/listing_base.html | 10 +++++++--- opentech/apply/activity/templatetags/activity_tags.py | 10 ++++++++-- opentech/apply/funds/views.py | 2 +- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/opentech/apply/activity/messaging.py b/opentech/apply/activity/messaging.py index 5191e8cf1..442be98b2 100644 --- a/opentech/apply/activity/messaging.py +++ b/opentech/apply/activity/messaging.py @@ -15,7 +15,7 @@ def link_to(target, request): neat_related = { MESSAGES.DETERMINATION_OUTCOME: 'determination', - MESSAGES.UPDATE_LEAD: 'old', + MESSAGES.UPDATE_LEAD: 'old_lead', MESSAGES.NEW_REVIEW: 'review', MESSAGES.TRANSITION: 'old_phase', MESSAGES.APPLICANT_EDIT: 'revision', @@ -118,7 +118,7 @@ class ActivityAdapter(AdapterBase): MESSAGES.NEW_SUBMISSION: 'Submitted {submission.title} for {submission.page.title}', MESSAGES.EDIT: 'Edited', MESSAGES.APPLICANT_EDIT: 'Edited', - MESSAGES.UPDATE_LEAD: 'Lead changed from {old.lead} to {submission.lead}', + MESSAGES.UPDATE_LEAD: 'Lead changed from {old_lead} to {submission.lead}', MESSAGES.DETERMINATION_OUTCOME: 'Sent a determination. Outcome: {determination.clean_outcome}', MESSAGES.INVITED_TO_PROPOSAL: 'Invited to submit a proposal', MESSAGES.REVIEWERS_UPDATED: 'reviewers_updated', @@ -171,7 +171,7 @@ class SlackAdapter(AdapterBase): always_send = True messages = { MESSAGES.NEW_SUBMISSION: 'A new submission has been submitted for {submission.page.title}: <{link}|{submission.title}>', - MESSAGES.UPDATE_LEAD: 'The lead of <{link}|{submission.title}> has been updated from {old.lead} to {submission.lead} by {user}', + MESSAGES.UPDATE_LEAD: 'The lead of <{link}|{submission.title}> has been updated from {old_lead} to {submission.lead} by {user}', MESSAGES.COMMENT: 'A new comment has been posted on <{link}|{submission.title}>', MESSAGES.EDIT: '{user} has edited <{link}|{submission.title}>', MESSAGES.APPLICANT_EDIT: '{user} has edited <{link}|{submission.title}>', diff --git a/opentech/apply/activity/templates/activity/include/listing_base.html b/opentech/apply/activity/templates/activity/include/listing_base.html index 106343a02..4c9cc090c 100644 --- a/opentech/apply/activity/templates/activity/include/listing_base.html +++ b/opentech/apply/activity/templates/activity/include/listing_base.html @@ -24,9 +24,13 @@ - {{ activity.message }} {% if not submission_title and activity.related_object %} - <a href="{{ activity.related_object.get_absolute_url }}" class="feed__related-item"> - <svg><use xlink:href="#arrow-head-pixels--solid"></use></svg> - </a> + {% with url=activity.related_object.get_absolute_url %} + {% if url %} + <a href="{{ url }}" class="feed__related-item"> + <svg><use xlink:href="#arrow-head-pixels--solid"></use></svg> + </a> + {% endif %} + {% endwith %} {% endif %} </p> </div> diff --git a/opentech/apply/activity/templatetags/activity_tags.py b/opentech/apply/activity/templatetags/activity_tags.py index 62043d012..a16d91342 100644 --- a/opentech/apply/activity/templatetags/activity_tags.py +++ b/opentech/apply/activity/templatetags/activity_tags.py @@ -1,10 +1,16 @@ from django import template +from opentech.apply.review.models import Review + register = template.Library() @register.filter def display_author(activity, user): - if user.is_applicant: - return None + if ( + user.is_applicant and + isinstance(activity.related_object, Review) and + not activity.user.is_apply_staff + ): + return 'Reviewer' return activity.user diff --git a/opentech/apply/funds/views.py b/opentech/apply/funds/views.py index 1e469d9ec..8e614ba85 100644 --- a/opentech/apply/funds/views.py +++ b/opentech/apply/funds/views.py @@ -104,7 +104,7 @@ class UpdateLeadView(DelegatedViewMixin, UpdateView): request=self.request, user=self.request.user, submission=form.instance, - related=old, + related=old.lead, ) return response -- GitLab