mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
Merge branch 'performances' into 'master'
Improve overall performances on notifications, news pages and navbar See merge request ae/Sith!232
This commit is contained in:
commit
f899e32fb0
@ -42,6 +42,8 @@
|
|||||||
<div id="birthdays_title">{% trans %}Birthdays{% endtrans %}</div>
|
<div id="birthdays_title">{% trans %}Birthdays{% endtrans %}</div>
|
||||||
<div id="birthdays_content">
|
<div id="birthdays_content">
|
||||||
{% if user.is_subscribed %}
|
{% if user.is_subscribed %}
|
||||||
|
{# Cache request for 1 hour #}
|
||||||
|
{% cache 3600 birthdays %}
|
||||||
<ul class="birthdays_year">
|
<ul class="birthdays_year">
|
||||||
{% for d in birthdays.dates('date_of_birth', 'year', 'DESC') %}
|
{% for d in birthdays.dates('date_of_birth', 'year', 'DESC') %}
|
||||||
<li>
|
<li>
|
||||||
@ -54,6 +56,7 @@
|
|||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
{% endcache %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>{% trans %}You need an up to date subscription to access this content{% endtrans %}</p>
|
<p>{% trans %}You need an up to date subscription to access this content{% endtrans %}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
20
core/migrations/0032_auto_20190909_0043.py
Normal file
20
core/migrations/0032_auto_20190909_0043.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.24 on 2019-09-08 22:43
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [("core", "0031_auto_20190906_1615")]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="notification",
|
||||||
|
name="viewed",
|
||||||
|
field=models.BooleanField(
|
||||||
|
db_index=True, default=False, verbose_name="viewed"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
]
|
@ -1393,7 +1393,7 @@ class Notification(models.Model):
|
|||||||
_("type"), max_length=32, choices=settings.SITH_NOTIFICATIONS, default="GENERIC"
|
_("type"), max_length=32, choices=settings.SITH_NOTIFICATIONS, default="GENERIC"
|
||||||
)
|
)
|
||||||
date = models.DateTimeField(_("date"), default=timezone.now)
|
date = models.DateTimeField(_("date"), default=timezone.now)
|
||||||
viewed = models.BooleanField(_("viewed"), default=False)
|
viewed = models.BooleanField(_("viewed"), default=False, db_index=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.param:
|
if self.param:
|
||||||
|
@ -60,21 +60,23 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="header_bar">
|
<div id="header_bar">
|
||||||
<ul id="header_bars_infos">
|
<ul id="header_bars_infos">
|
||||||
{% for bar in Counter.objects.filter(type="BAR").all() %}
|
{% cache 100 counters_activity %}
|
||||||
<li>
|
{% for bar in Counter.objects.filter(type="BAR").all() %}
|
||||||
<a href="{{ url('counter:activity', counter_id=bar.id) }}" style="padding: 0px">
|
<li>
|
||||||
{% if bar.is_inactive(): %}
|
<a href="{{ url('counter:activity', counter_id=bar.id) }}" style="padding: 0px">
|
||||||
<i class="fa fa-question" style="color: #f39c12"></i>
|
{% if bar.is_inactive(): %}
|
||||||
{% elif bar.is_open(): %}
|
<i class="fa fa-question" style="color: #f39c12"></i>
|
||||||
<i class="fa fa-check" style="color: #2ecc71"></i>
|
{% elif bar.is_open(): %}
|
||||||
{% else %}
|
<i class="fa fa-check" style="color: #2ecc71"></i>
|
||||||
<i class="fa fa-times" style="color: #eb2f06"></i>
|
{% else %}
|
||||||
{% endif %}
|
<i class="fa fa-times" style="color: #eb2f06"></i>
|
||||||
{{ bar }}
|
{% endif %}
|
||||||
</a>
|
{{ bar }}
|
||||||
</li>
|
</a>
|
||||||
{% endfor %}
|
</li>
|
||||||
</ul>
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endcache %}
|
||||||
<form action="{{ url('core:search') }}" method="GET" id="header_search">
|
<form action="{{ url('core:search') }}" method="GET" id="header_search">
|
||||||
<input type="text" placeholder="{% trans %}Search{% endtrans %}" name="query" id="search" />
|
<input type="text" placeholder="{% trans %}Search{% endtrans %}" name="query" id="search" />
|
||||||
<input type="submit" value="{% trans %}Search{% endtrans %}" style="display: none;" />
|
<input type="submit" value="{% trans %}Search{% endtrans %}" style="display: none;" />
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright 2016,2017
|
# Copyright 2016,2017
|
||||||
# - Skia <skia@libskia.so>
|
# - Skia <skia@libskia.so>
|
||||||
|
# - Sli <antoine@bartuccio.fr>
|
||||||
#
|
#
|
||||||
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
# http://ae.utbm.fr.
|
# http://ae.utbm.fr.
|
||||||
@ -50,8 +51,9 @@ class NotificationList(ListView):
|
|||||||
template_name = "core/notification_list.jinja"
|
template_name = "core/notification_list.jinja"
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
|
# TODO: Bulk update in django 2.2
|
||||||
if "see_all" in self.request.GET.keys():
|
if "see_all" in self.request.GET.keys():
|
||||||
for n in self.request.user.notifications.all():
|
for n in self.request.user.notifications.filter(viewed=False):
|
||||||
n.viewed = True
|
n.viewed = True
|
||||||
n.save()
|
n.save()
|
||||||
return self.request.user.notifications.order_by("-date")[:20]
|
return self.request.user.notifications.order_by("-date")[:20]
|
||||||
|
Loading…
Reference in New Issue
Block a user