diff --git a/amadeus/static/css/base/amadeus.css b/amadeus/static/css/base/amadeus.css index 1b31e02..bf82432 100755 --- a/amadeus/static/css/base/amadeus.css +++ b/amadeus/static/css/base/amadeus.css @@ -914,4 +914,14 @@ li.item .notify_badge { .no_button:focus, .no_button:active:focus, .no_button.active:focus, .no_button.focus, .no_button:active.focus, .no_button.active.focus { outline: none; +} + +.history-header { + line-height: 1.8; +} + +.history-control-label { + padding-right: 0px; + font-size: 16px !important; + margin: 7px 0 0 0 !important; } \ No newline at end of file diff --git a/notifications/templates/notifications/_history.html b/notifications/templates/notifications/_history.html new file mode 100644 index 0000000..94e40a1 --- /dev/null +++ b/notifications/templates/notifications/_history.html @@ -0,0 +1,47 @@ +{% load i18n notification_filters pagination %} + +
+
+
+

{{ rows }} {% trans 'rows' %}

+
+
+
+
+ +
+ +
+
+
+
+ + + + + + + + + + + {% if rows > 0 %} + {% for notification in notifications %} + + + + + + + + + {% endfor %} + {% else %} + {% endif %} + +
{% trans 'Date' %}{% trans 'Resource' %}{% trans 'Task' %}{% trans 'Final Date' %}{% trans 'Notification' %}{% trans 'Observation' %}
{{ notification.creation_date|date:"SHORT_DATE_FORMAT" }}{{ notification.task.resource }}{{ notification.task.get_action_display }}{{ notification.task.end_date|date:"SHORT_DATE_FORMAT"|default:_('Not Informed') }}{{ notification.level|warning_msg }} +
+ + {% pagination request paginator page_obj %} +
+
\ No newline at end of file diff --git a/notifications/templates/notifications/subject.html b/notifications/templates/notifications/subject.html index d081a19..8e2e8ba 100644 --- a/notifications/templates/notifications/subject.html +++ b/notifications/templates/notifications/subject.html @@ -28,23 +28,27 @@
- {% if notifications.count > 0 %} - {% for notification in notifications %} - {% include 'notifications/_view.html' %} - {% endfor %} + {% if not history %} + {% if notifications.count > 0 %} + {% for notification in notifications %} + {% include 'notifications/_view.html' %} + {% endfor %} - {% pagination request paginator page_obj %} - {% else %} -
- -

{% trans 'You do not posses any pendency in this subject' %}

-
- {% endif %} + {% pagination request paginator page_obj %} + {% else %} +
+ +

{% trans 'You do not posses any pendency in this subject' %}

+
+ {% endif %} + {% else %} + {% include 'notifications/_history.html' %} + {% endif %}
{% endblock %} \ No newline at end of file diff --git a/notifications/urls.py b/notifications/urls.py index 953f6b3..c021cb6 100644 --- a/notifications/urls.py +++ b/notifications/urls.py @@ -3,4 +3,5 @@ from . import views urlpatterns = [ url(r'^(?P[\w_-]+)/$', views.SubjectNotifications.as_view(), name='view'), + url(r'^(?P[\w_-]+)/history/$', views.SubjectHistory.as_view(), name='history'), ] \ No newline at end of file diff --git a/notifications/views.py b/notifications/views.py index 2ca992d..84fc594 100644 --- a/notifications/views.py +++ b/notifications/views.py @@ -20,6 +20,7 @@ class SubjectNotifications(LoginRequiredMixin, generic.ListView): context_object_name = 'notifications' template_name = 'notifications/subject.html' paginate_by = 10 + total = 0 def dispatch(self, request, *args, **kwargs): slug = self.kwargs.get('slug', '') @@ -36,6 +37,8 @@ class SubjectNotifications(LoginRequiredMixin, generic.ListView): notifications = Notification.objects.filter(user = self.request.user, task__resource__topic__subject = subject, creation_date = datetime.now()) + self.total = notifications.count() + return notifications def get_context_data(self, **kwargs): @@ -46,5 +49,50 @@ class SubjectNotifications(LoginRequiredMixin, generic.ListView): context['title'] = _('%s - Pendencies')%(subject.name) context['subject'] = subject + context['total'] = self.total return context + +class SubjectHistory(LoginRequiredMixin, generic.ListView): + login_url = reverse_lazy("users:login") + redirect_field_name = 'next' + + context_object_name = 'notifications' + template_name = 'notifications/subject.html' + paginate_by = 10 + total = 0 + num_rows = 0 + + def dispatch(self, request, *args, **kwargs): + slug = self.kwargs.get('slug', '') + subject = get_object_or_404(Subject, slug = slug) + + if not has_subject_view_permissions(request.user, subject): + return redirect(reverse_lazy('subjects:home')) + + return super(SubjectHistory, self).dispatch(request, *args, **kwargs) + + def get_queryset(self): + slug = self.kwargs.get('slug', '') + subject = get_object_or_404(Subject, slug = slug) + + notifications = Notification.objects.filter(user = self.request.user, task__resource__topic__subject = subject).order_by("-creation_date") + + self.total = notifications.filter(creation_date = datetime.now()).count() + self.num_rows = notifications.count() + + return notifications + + def get_context_data(self, **kwargs): + context = super(SubjectHistory, self).get_context_data(**kwargs) + + slug = self.kwargs.get('slug', '') + subject = get_object_or_404(Subject, slug = slug) + + context['title'] = _('%s - Pendencies')%(subject.name) + context['subject'] = subject + context['history'] = True + context['total'] = self.total + context['rows'] = self.num_rows + + return context \ No newline at end of file -- libgit2 0.21.2