Skip to content
Snippets Groups Projects
Commit 08b22b2a authored by sandeepsajan0's avatar sandeepsajan0 Committed by Fredrik Jonsson
Browse files

Add support for different type of users, and update template and template tags

parent 879b8cf5
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
{% block content %} {% block content %}
<div class="admin-bar"> <div class="admin-bar">
<div class="admin-bar__inner"> <div class="admin-bar__inner">
<h1 class="gamma heading heading--no-margin heading--bold">{% trans "Notifications" %}</h1>
<div class="tabs js-tabs"> <div class="tabs js-tabs">
<div class="tabs__container"> <div class="tabs__container">
<a class="tab__item" href="#comments" data-tab="tab-1"> <a class="tab__item" href="#comments" data-tab="tab-1">
...@@ -24,7 +25,7 @@ ...@@ -24,7 +25,7 @@
{% for comment in object_list %} {% for comment in object_list %}
{% if comment.type == 'comment' %} {% 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> <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> : {{ comment.user }} made a comment</p>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
...@@ -33,7 +34,7 @@ ...@@ -33,7 +34,7 @@
<div class="tabs__content" id="tab-2"> <div class="tabs__content" id="tab-2">
<div class="feed"> <div class="feed">
{% for action in actions %} {% 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> <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> : {{ action.message }} <a href="{{ action.related_object.get_absolute_url }}">{{ action.related_object.title }}</a>
</p> </p>
{% endfor %} {% endfor %}
......
...@@ -61,4 +61,4 @@ def visibility_options(activity, user): ...@@ -61,4 +61,4 @@ def visibility_options(activity, user):
def source_type(value): def source_type(value):
if value and "submission" in value: if value and "submission" in value:
return "Submission" return "Submission"
return value.capitalize() return str(value).capitalize()
...@@ -2,7 +2,8 @@ from django.utils import timezone ...@@ -2,7 +2,8 @@ from django.utils import timezone
from django.utils.decorators import method_decorator from django.utils.decorators import method_decorator
from django.views.generic import CreateView, ListView from django.views.generic import CreateView, ListView
from hypha.apply.users.decorators import staff_required from hypha.apply.funds.models.submissions import ApplicationSubmission
from hypha.apply.users.decorators import login_required
from hypha.apply.utils.views import DelegatedViewMixin from hypha.apply.utils.views import DelegatedViewMixin
from .forms import CommentForm from .forms import CommentForm
...@@ -61,13 +62,25 @@ class CommentFormView(DelegatedViewMixin, CreateView): ...@@ -61,13 +62,25 @@ class CommentFormView(DelegatedViewMixin, CreateView):
return kwargs return kwargs
@method_decorator(staff_required, name='dispatch') @method_decorator(login_required, name='dispatch')
class NotificationsView(ListView): class NotificationsView(ListView):
model = Activity model = Activity
template_name = 'activity/notifications.html' template_name = 'activity/notifications.html'
def get_context_data(self, *, object_list=None, **kwargs): def get_context_data(self, *, object_list=None, **kwargs):
context = super(NotificationsView, self).get_context_data() context = super(NotificationsView, self).get_context_data()
context['comments'] = Activity.comments.all().order_by('-timestamp') user = self.request.user
context['actions'] = Activity.actions.all().order_by('-timestamp') if user.is_applicant or user.is_partner:
context['comments'] = Activity.comments.filter(source__user=user).order_by('-timestamp')
context['actions'] = Activity.actions.filter(source__user=user).order_by('-timestamp')
elif user.is_reviewer:
reviewer_submissions = ApplicationSubmission.objects.filter(reviewers=user).values_list("id", flat=True)
context['comments'] = Activity.comments.filter(source_object_id__in=reviewer_submissions).order_by('-timestamp')
context['actions'] = Activity.actions.filter(source_object_id__in=reviewer_submissions).order_by('-timestamp')
elif user.is_apply_staff or user.is_apply_staff_admin:
context['comments'] = Activity.comments.all().order_by('-timestamp')
context['actions'] = Activity.actions.all().order_by('-timestamp')
else:
context['comments'] = Activity.comments.filter(user=user).order_by('-timestamp')
context['actions'] = Activity.actions.filter(user=user).order_by('-timestamp')
return context return context
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment