Commit 08157c45 authored by Maël Kervella's avatar Maël Kervella

Add context processor to get the current date

parent 6a08e141
......@@ -21,8 +21,10 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""Fonction de context, variables renvoyées à toutes les vues"""
from __future__ import unicode_literals
import datetime
from django.contrib import messages
from preferences.models import GeneralOption, OptionalMachine
......@@ -47,3 +49,12 @@ def context_user(request):
'name_website': GeneralOption.get_cached_value('site_name'),
'ipv6_enabled': OptionalMachine.get_cached_value('ipv6'),
}
def date_now(request):
"""Add the current date in the context for quick informations and
comparisons"""
return {
'now_aware': datetime.datetime.now(datetime.timezone.utc),
'now_naive': datetime.datetime.now()
}
......@@ -125,6 +125,7 @@ TEMPLATES = [
'django.contrib.messages.context_processors.messages',
'django.template.context_processors.request',
're2o.context_processors.context_user',
're2o.context_processors.date_now',
],
},
},
......
......@@ -70,7 +70,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% for user in superusers %}
<tr>
<td>{{ user.pseudo }}</td>
{% if user.end_adhesion is not None and user.end_adhesion >= now %}
{% if user.end_adhesion is not None and user.end_adhesion >= now_aware %}
<td class="text-success">{% trans "Member" %}</td>
{% elif not user.end_adhesion %}
<td class="text-warning">{% trans "No membership records" %}</td>
......@@ -175,7 +175,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% for user in users %}
<tr>
<td>{{ user.pseudo }}</td>
{% if user.end_adhesion is not None and user.end_adhesion >= now %}
{% if user.end_adhesion is not None and user.end_adhesion >= now_aware %}
<td class="text-success">{% trans "Member" %}</td>
{% elif not user.end_adhesion %}
<td class="text-warning">{% trans "No membership records" %}</td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment