From f811230c25cb77febaf5de9a698f9682d01f250c Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Fri, 28 Aug 2020 16:00:20 +0200 Subject: [PATCH 1/6] Add comment field --- bds/migrations/0006_bdsprofile_comments.py | 23 ++++++++++++++++++++++ bds/models.py | 9 +++++++++ bds/templates/bds/forms/textarea.html | 2 ++ 3 files changed, 34 insertions(+) create mode 100644 bds/migrations/0006_bdsprofile_comments.py diff --git a/bds/migrations/0006_bdsprofile_comments.py b/bds/migrations/0006_bdsprofile_comments.py new file mode 100644 index 00000000..7950955f --- /dev/null +++ b/bds/migrations/0006_bdsprofile_comments.py @@ -0,0 +1,23 @@ +# Generated by Django 2.2.12 on 2020-08-28 12:14 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("bds", "0005_remove_bdsprofile_certificate_file"), + ] + + operations = [ + migrations.AddField( + model_name="bdsprofile", + name="comments", + field=models.TextField( + blank=True, + help_text="Attention : l'utilisateur·ice dispose d'un droit d'accès" + " aux données le/la concernant, dont le contenu de ce champ !", + verbose_name="commentaires", + ), + ), + ] diff --git a/bds/models.py b/bds/models.py index 1b9ca6bc..0ea46466 100644 --- a/bds/models.py +++ b/bds/models.py @@ -84,6 +84,15 @@ class BDSProfile(models.Model): _("type de cotisation"), choices=TYPE_COTIZ_CHOICES, max_length=9 ) + comments = models.TextField( + _("commentaires"), + blank=True, + help_text=_( + "Attention : l'utilisateur·ice dispose d'un droit d'accès aux données " + "le/la concernant, dont le contenu de ce champ !" + ), + ) + class Meta: verbose_name = _("Profil BDS") verbose_name_plural = _("Profils BDS") diff --git a/bds/templates/bds/forms/textarea.html b/bds/templates/bds/forms/textarea.html index 541c63c7..c5bc50f4 100644 --- a/bds/templates/bds/forms/textarea.html +++ b/bds/templates/bds/forms/textarea.html @@ -1,3 +1,5 @@ +{% load bulma_utils %} + From 1ac3e0f976667199ce17f378e26714a7f1852337 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Fri, 28 Aug 2020 16:11:20 +0200 Subject: [PATCH 2/6] Plug logout link --- bds/templates/bds/nav.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bds/templates/bds/nav.html b/bds/templates/bds/nav.html index 7baa3414..ff167189 100644 --- a/bds/templates/bds/nav.html +++ b/bds/templates/bds/nav.html @@ -12,7 +12,7 @@
- + logout
@@ -31,7 +31,7 @@
- + logout
From 8fa635773c301f695f13e1248c4aa146d59a1c11 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Fri, 28 Aug 2020 16:11:50 +0200 Subject: [PATCH 3/6] Notifications are closable --- bds/static/bds/js/bds.js | 7 +++++++ bds/templates/bds/base.html | 40 ++++++++++++++++++++----------------- 2 files changed, 29 insertions(+), 18 deletions(-) create mode 100644 bds/static/bds/js/bds.js diff --git a/bds/static/bds/js/bds.js b/bds/static/bds/js/bds.js new file mode 100644 index 00000000..3c2fb49b --- /dev/null +++ b/bds/static/bds/js/bds.js @@ -0,0 +1,7 @@ +$(function () { + // Close notifications when delete button is pressed + $(".notification .delete").on("click", function () { + $(this).parent().remove(); + }); + +}); \ No newline at end of file diff --git a/bds/templates/bds/base.html b/bds/templates/bds/base.html index ac2b4875..f456f6dc 100644 --- a/bds/templates/bds/base.html +++ b/bds/templates/bds/base.html @@ -16,31 +16,35 @@ {# Javascript #} + {% block extra_head %}{% endblock extra_head %} {% include "bds/nav.html" %} + {% block layout %} +
+
+
-
-
-
- {% if messages %} - {% for message in messages %} -
- {% if 'safe' in message.tags %} - {{ message|safe }} - {% else %} - {{ message }} - {% endif %} -
- {% endfor %} - {% endif %} + {% if messages %} + {% for message in messages %} +
+ {% if 'safe' in message.tags %} + {{ message|safe }} + {% else %} + {{ message }} + {% endif %} + +
+ {% endfor %} + {% endif %} - {% block content %} - {% endblock content %} -
+ {% block content %} + {% endblock content %} +
- +
+ {% endblock layout %} From e7cc705350ad67b273dcd2adccd288e657bcd035 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Fri, 28 Aug 2020 16:12:03 +0200 Subject: [PATCH 4/6] 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 From d3384dc5fcd333d329e5350935cbbec4676b1e26 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Fri, 28 Aug 2020 18:18:54 +0200 Subject: [PATCH 5/6] Remove context processor --- bds/context_processors.py | 5 ----- bds/views.py | 6 ++++++ cof/settings/bds_prod.py | 8 +------- cof/settings/local.py | 6 +----- 4 files changed, 8 insertions(+), 17 deletions(-) delete mode 100644 bds/context_processors.py diff --git a/bds/context_processors.py b/bds/context_processors.py deleted file mode 100644 index c1d81bc6..00000000 --- a/bds/context_processors.py +++ /dev/null @@ -1,5 +0,0 @@ -from bds.models import BDSProfile - - -def member_count(request): - return {"member_count": BDSProfile.objects.filter(is_member=True).count()} diff --git a/bds/views.py b/bds/views.py index e12185f7..0318d1e6 100644 --- a/bds/views.py +++ b/bds/views.py @@ -8,6 +8,7 @@ from django.views.generic import DeleteView, TemplateView from bds.autocomplete import bds_search from bds.forms import ProfileForm, UserForm, UserFromClipperForm, UserFromScratchForm from bds.mixins import MultipleFormView, StaffRequiredMixin +from bds.models import BDSProfile from shared.views import AutocompleteView User = get_user_model() @@ -21,6 +22,11 @@ class BDSAutocompleteView(StaffRequiredMixin, AutocompleteView): class Home(StaffRequiredMixin, TemplateView): template_name = "bds/home.html" + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context["member_count"] = BDSProfile.objects.filter(is_member=True).count() + return context + class UserUpdateView(StaffRequiredMixin, MultipleFormView): template_name = "bds/user_update.html" diff --git a/cof/settings/bds_prod.py b/cof/settings/bds_prod.py index 9379d44d..12f5a552 100644 --- a/cof/settings/bds_prod.py +++ b/cof/settings/bds_prod.py @@ -2,10 +2,8 @@ Django development settings for the cof project. The settings that are not listed here are imported from .common """ -import os - from .common import * # NOQA -from .common import BASE_DIR, INSTALLED_APPS, TEMPLATES +from .common import INSTALLED_APPS # --- # BDS-only Django settings @@ -20,10 +18,6 @@ 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 27acf74b..c3607d7f 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, TEMPLATES, TESTING +from .cof_prod import BASE_DIR, INSTALLED_APPS, MIDDLEWARE, TESTING # --- # Merge COF and BDS configs @@ -13,10 +13,6 @@ 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 # --- From 2d59565f61cbe462b2666682809e1be50112ba4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 28 Aug 2020 18:22:06 +0200 Subject: [PATCH 6/6] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e85917a..35757b79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ adhérents ni des cotisations. ### GestioBDS - Ajout d'un bouton pour supprimer un compte +- Le nombre d'adhérent⋅es est affiché sur la page d'accueil ### Site du COF