Browse Source

Add context processor to get the current date

set_password
Maël Kervella 8 years ago
parent
commit
08157c4565
  1. 13
      re2o/context_processors.py
  2. 1
      re2o/settings.py
  3. 4
      users/templates/users/aff_listright.html

13
re2o/context_processors.py

@ -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()
}

1
re2o/settings.py

@ -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',
],
},
},

4
users/templates/users/aff_listright.html

@ -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>

Loading…
Cancel
Save