From 64975243ccfd4684e95206ca83ee7ac3e0b5aa0d Mon Sep 17 00:00:00 2001 From: sandeepsajan0 <sandeepsajan0@gmail.com> Date: Thu, 16 Jun 2022 18:36:18 +0530 Subject: [PATCH] Update notifications list UI,add related object link and date --- hypha/apply/activity/filters.py | 13 ++++++ .../templates/activity/notifications.html | 41 +++++++++++++------ hypha/apply/activity/views.py | 1 + 3 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 hypha/apply/activity/filters.py diff --git a/hypha/apply/activity/filters.py b/hypha/apply/activity/filters.py new file mode 100644 index 000000000..73391af45 --- /dev/null +++ b/hypha/apply/activity/filters.py @@ -0,0 +1,13 @@ +import django_filters + +from .models import Activity + + +class NotificationFilter(django_filters.FilterSet): + + class Meta: + model = Activity + fields = { + 'timestamp', + 'source_content_type', + } diff --git a/hypha/apply/activity/templates/activity/notifications.html b/hypha/apply/activity/templates/activity/notifications.html index 0f20cb70c..c6bc4e573 100644 --- a/hypha/apply/activity/templates/activity/notifications.html +++ b/hypha/apply/activity/templates/activity/notifications.html @@ -1,5 +1,5 @@ {% extends "base-apply.html" %} -{% load i18n static activity_tags %} +{% load i18n static activity_tags apply_tags %} {% block content %} <div class="admin-bar"> @@ -22,23 +22,40 @@ <div class="wrapper wrapper--large wrapper--tabs js-tabs-content"> {# Tab 1 #} <div class="tabs__content" id="tab-1"> - {% for comment in object_list %} - {% if comment.type == 'comment' %} - - <p><a href="{{ comment.source.get_absolute_url }}">{{ comment.source_content_type.name|source_type }} ({{ comment.source.title|truncatechars:15 }})</a> - : {{ comment.user }} made a comment</p> - {% endif %} +<!-- <form action="" method="get">--> +<!-- {{ filter.form.as_p }}--> +<!-- <input type="submit" />--> +<!-- </form>--> + {% for comment in comments %} + <div class="feed__item feed__item--comment"> + <div class="feed__pre-content"> + <p class="feed__label feed__label--comment">{{ comment.source_content_type.name|source_type }}</p> + </div> + <div class="feed__content js-feed-content"> + <div class="feed__meta js-feed-meta"> + <p class="feed__meta-item"><a href="{{ comment.source.get_absolute_url }}">{{ comment.source.title|capfirst|truncatechars:15 }}</a> + : {{ comment.user }} made a comment – {{ comment.timestamp|date:"SHORT_DATETIME_FORMAT" }}</p> + </div> + </div> + </div> {% endfor %} </div> {# Tab 2 #} <div class="tabs__content" id="tab-2"> - <div class="feed"> {% for action in actions %} - <p><a href="{{ action.source.get_absolute_url }}">{{ action.source_content_type.name|source_type }} ({{ action.source.title|truncatechars:15 }})</a> - : {{ action.message }} <a href="{{ action.related_object.get_absolute_url }}">{{ action.related_object.title }}</a> - </p> + <div class="feed__item feed__item--action"> + <div class="feed__pre-content"> + <p class="feed__label feed__label--action">{{ action.source_content_type.name|source_type }}</p> + </div> + <div class="feed__content js-feed-content"> + <div class="feed__meta js-feed-meta"> + <p class="feed__meta-item"><a href="{{ action.source.get_absolute_url }}">{{ action.source.title|capfirst|truncatechars:15 }}</a> + : {{ action.message }} {% if action.related_object %}<a href="{{ action.related_object.get_absolute_url }}">{{ action.related_object|model_verbose_name }}</a>{% endif %} + – {{ action.timestamp|date:"SHORT_DATETIME_FORMAT" }}</p> + </div> + </div> + </div> {% endfor %} - </div> </div> </div> diff --git a/hypha/apply/activity/views.py b/hypha/apply/activity/views.py index 197e042f5..407d0a67a 100644 --- a/hypha/apply/activity/views.py +++ b/hypha/apply/activity/views.py @@ -83,4 +83,5 @@ class NotificationsView(ListView): else: context['comments'] = Activity.comments.filter(user=user).order_by('-timestamp') context['actions'] = Activity.actions.filter(user=user).order_by('-timestamp') + # context['filter'] = NotificationFilter(self.request.GET, queryset=self.get_queryset()) return context -- GitLab