diff --git a/opentech/apply/activity/templates/activity/include/listing_base.html b/opentech/apply/activity/templates/activity/include/listing_base.html index 4c9cc090c6cb739399f3b26a1ce8db780b8246f7..5f567ffe2f11e8ad7aba371ce7a75983009e8d4d 100644 --- a/opentech/apply/activity/templates/activity/include/listing_base.html +++ b/opentech/apply/activity/templates/activity/include/listing_base.html @@ -23,7 +23,7 @@ - {{ activity.message }} - {% if not submission_title and activity.related_object %} + {% if not submission_title and activity|user_can_see_related:request.user %} {% with url=activity.related_object.get_absolute_url %} {% if url %} <a href="{{ url }}" class="feed__related-item"> diff --git a/opentech/apply/activity/templatetags/activity_tags.py b/opentech/apply/activity/templatetags/activity_tags.py index a16d9134248e55cb77f1eb2889485ccbe5e7258c..bb73ac11f002bc9e1d492a342c7a9eb9e57b8867 100644 --- a/opentech/apply/activity/templatetags/activity_tags.py +++ b/opentech/apply/activity/templatetags/activity_tags.py @@ -1,5 +1,6 @@ from django import template +from opentech.apply.determinations.models import Determination from opentech.apply.review.models import Review register = template.Library() @@ -14,3 +15,17 @@ def display_author(activity, user): ): return 'Reviewer' return activity.user + + +@register.filter +def user_can_see_related(activity, user): + if not activity.related_object: + return False + + if user.is_apply_staff: + return True + + if isinstance(activity.related_object, Determination): + return True + + return False diff --git a/opentech/apply/activity/views.py b/opentech/apply/activity/views.py index ad90ea369daa8c50cb1d9b69468ea598887f894c..6a801ea77dcf9569468abb1b4946fd293a42a27c 100644 --- a/opentech/apply/activity/views.py +++ b/opentech/apply/activity/views.py @@ -34,9 +34,13 @@ class ActivityContextMixin: extra = { 'actions': Activity.actions.filter(submission=self.object).select_related( 'user', + ).prefetch_related( + 'related_object', ).visible_to(self.request.user), 'comments': Activity.comments.filter(submission=self.object).select_related( 'user', + ).prefetch_related( + 'related_object', ).visible_to(self.request.user), } diff --git a/opentech/static_src/src/sass/apply/components/_feed.scss b/opentech/static_src/src/sass/apply/components/_feed.scss index 246f10e3b24a4e85c4d17349657b8b83aa4441aa..8852c1926aa1ee515f7c210ff68fdecb2591e394 100644 --- a/opentech/static_src/src/sass/apply/components/_feed.scss +++ b/opentech/static_src/src/sass/apply/components/_feed.scss @@ -115,7 +115,7 @@ width: 10px; height: 14px; margin-left: 10px; - margin-top: 0.25em; + margin-top: 0.35em; fill: $color--dark-blue; } }