From e7cc705350ad67b273dcd2adccd288e657bcd035 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Fri, 28 Aug 2020 16:12:03 +0200 Subject: [PATCH] Add member count to home --- bds/context_processors.py | 5 +++ bds/templates/bds/home.html | 67 +++++++++++++++++++++++++++---------- cof/settings/bds_prod.py | 6 +++- cof/settings/local.py | 5 ++- 4 files changed, 64 insertions(+), 19 deletions(-) create mode 100644 bds/context_processors.py diff --git a/bds/context_processors.py b/bds/context_processors.py new file mode 100644 index 00000000..c1d81bc6 --- /dev/null +++ b/bds/context_processors.py @@ -0,0 +1,5 @@ +from bds.models import BDSProfile + + +def member_count(request): + return {"member_count": BDSProfile.objects.filter(is_member=True).count()} diff --git a/bds/templates/bds/home.html b/bds/templates/bds/home.html index 65a67743..4a3e95f6 100644 --- a/bds/templates/bds/home.html +++ b/bds/templates/bds/home.html @@ -1,22 +1,55 @@ {% extends "bds/base.html" %} +{% load bulma_utils %} -{% block content %} -
- Bienvenue sur GestioBDS ! +{% block layout %} +
+
+
+
+
+

{{ member_count }}

+ adhérent·e·s +
+
+
+
+
+
-
-
+ {% if messages %} + {% for message in messages %} +
+ {% if 'safe' in message.tags %} + {{ message|safe }} + {% else %} + {{ message }} + {% endif %} + +
+ {% endfor %} + {% endif %} +
+ Bienvenue sur GestioBDS ! - Le site est encore en développement. -
- Suivez notre avancement sur - - cette milestone sur le gitlab de l'ENS. -
- Faites vos remarques par mail à - klub-dev@ens.fr - ou en ouvrant une - - issue. +
+
+ + Le site est encore en développement. +
+ Suivez notre avancement sur + + cette milestone sur le gitlab de l'ENS. +
+ Faites vos remarques par mail à + klub-dev@ens.fr + ou en ouvrant une + + issue. +
+
+
-{% endblock %} +{% endblock layout %} + + + diff --git a/cof/settings/bds_prod.py b/cof/settings/bds_prod.py index 31e986f8..9379d44d 100644 --- a/cof/settings/bds_prod.py +++ b/cof/settings/bds_prod.py @@ -5,7 +5,7 @@ The settings that are not listed here are imported from .common import os from .common import * # NOQA -from .common import BASE_DIR, INSTALLED_APPS +from .common import BASE_DIR, INSTALLED_APPS, TEMPLATES # --- # BDS-only Django settings @@ -20,6 +20,10 @@ STATIC_URL = "/gestion2/static/" MEDIA_ROOT = "/srv/bds.ens.fr/gestion2/media" MEDIA_URL = "/gestion2/media/" +TEMPLATES[0]["OPTIONS"]["context_processors"] += [ + "bds.context_processors.member_count", +] + # --- # Auth-related stuff diff --git a/cof/settings/local.py b/cof/settings/local.py index c34ffd76..27acf74b 100644 --- a/cof/settings/local.py +++ b/cof/settings/local.py @@ -3,7 +3,7 @@ import os from . import bds_prod from .cof_prod import * # NOQA -from .cof_prod import BASE_DIR, INSTALLED_APPS, MIDDLEWARE, TESTING +from .cof_prod import BASE_DIR, INSTALLED_APPS, MIDDLEWARE, TEMPLATES, TESTING # --- # Merge COF and BDS configs @@ -13,6 +13,9 @@ for app in bds_prod.INSTALLED_APPS: if app not in INSTALLED_APPS: INSTALLED_APPS.append(app) +TEMPLATES[0]["OPTIONS"]["context_processors"] += [ + "bds.context_processors.member_count", +] # --- # Tweaks for debug/local development