From 8700144dea6dfb820450add7158168a719609efd Mon Sep 17 00:00:00 2001 From: Ehouarn Date: Wed, 24 Sep 2025 21:48:56 +0200 Subject: [PATCH 1/6] Permissions --- apps/permission/fixtures/initial.json | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/permission/fixtures/initial.json b/apps/permission/fixtures/initial.json index e642c4e6..f3d4cf33 100644 --- a/apps/permission/fixtures/initial.json +++ b/apps/permission/fixtures/initial.json @@ -4833,7 +4833,10 @@ 221, 247, 258, - 259 + 259, + 260, + 263, + 265 ] } }, @@ -4845,7 +4848,6 @@ "name": "Pr\u00e9sident\u22c5e de club", "permissions": [ 62, - 135, 142 ] } @@ -5122,7 +5124,8 @@ 289, 290, 291, - 293 + 293, + 298 ] } }, @@ -5233,7 +5236,9 @@ 168, 176, 177, - 197 + 197, + 311, + 319 ] } }, @@ -5313,7 +5318,8 @@ 289, 290, 291, - 293 + 293, + 298 ] } }, From 5d8720cf462ac91fdcb7c83b337e0e9e7f41885a Mon Sep 17 00:00:00 2001 From: Ehouarn Date: Wed, 24 Sep 2025 22:22:23 +0200 Subject: [PATCH 2/6] Phone input without permission fixed --- apps/member/templates/member/profile_update.html | 4 ++-- apps/wei/templates/wei/weiregistration_form.html | 4 ++-- note_kfet/templates/registration/signup.html | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/member/templates/member/profile_update.html b/apps/member/templates/member/profile_update.html index e0975c22..36029cb3 100644 --- a/apps/member/templates/member/profile_update.html +++ b/apps/member/templates/member/profile_update.html @@ -29,8 +29,8 @@ SPDX-License-Identifier: GPL-3.0-or-later const input = document.querySelector("input[name='phone_number']"); const form = document.querySelector("#profile-form"); - if (!input || !form) { - console.error("Input phone_number ou form introuvable."); + if (!input || !form || input.type === "hidden" || input.disabled || input.readOnly) { + return; } const iti = window.intlTelInput(input, { diff --git a/apps/wei/templates/wei/weiregistration_form.html b/apps/wei/templates/wei/weiregistration_form.html index 4964814d..dc5f66e5 100644 --- a/apps/wei/templates/wei/weiregistration_form.html +++ b/apps/wei/templates/wei/weiregistration_form.html @@ -28,8 +28,8 @@ SPDX-License-Identifier: GPL-3.0-or-later const input = document.querySelector("input[name='emergency_contact_phone']"); const form = document.querySelector("#registration-form"); - if (!input || !form) { - console.error("Input phone_number ou form introuvable."); + if (!input || !form || input.type === "hidden" || input.disabled || input.readOnly) { + return; } const iti = window.intlTelInput(input, { diff --git a/note_kfet/templates/registration/signup.html b/note_kfet/templates/registration/signup.html index 5428ff95..71fe2511 100644 --- a/note_kfet/templates/registration/signup.html +++ b/note_kfet/templates/registration/signup.html @@ -39,8 +39,8 @@ SPDX-License-Identifier: GPL-3.0-or-later const input = document.querySelector("input[name='phone_number']"); const form = document.querySelector("#profile_form"); - if (!input || !form) { - console.error("Input phone_number ou form introuvable."); + if (!input || !form || input.type === "hidden" || input.disabled || input.readOnly) { + return; } const iti = window.intlTelInput(input, { From 47d2476b51c6a10f4e95230c14d657a3af5227f0 Mon Sep 17 00:00:00 2001 From: Ehouarn Date: Thu, 25 Sep 2025 00:08:56 +0200 Subject: [PATCH 3/6] Allow to view activity entries on Activity tab --- .../activity/includes/activity_info.html | 8 +++++++- apps/activity/templatetags/__init__.py | 0 apps/activity/templatetags/dict_get.py | 12 ++++++++++++ apps/activity/views.py | 19 +++++++++++++++++++ apps/permission/fixtures/initial.json | 16 ++++++++++++++++ 5 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 apps/activity/templatetags/__init__.py create mode 100644 apps/activity/templatetags/dict_get.py diff --git a/apps/activity/templates/activity/includes/activity_info.html b/apps/activity/templates/activity/includes/activity_info.html index f9ea634b..4565a086 100644 --- a/apps/activity/templates/activity/includes/activity_info.html +++ b/apps/activity/templates/activity/includes/activity_info.html @@ -1,7 +1,7 @@ {% comment %} SPDX-License-Identifier: GPL-3.0-or-later {% endcomment %} -{% load i18n perms pretty_money %} +{% load i18n perms pretty_money dict_get %} {% url 'activity:activity_detail' activity.pk as activity_detail_url %}
@@ -53,6 +53,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% trans 'opened'|capfirst %}
{{ activity.open|yesno }}
+ {% if show_entries|dict_get:activity %} +

+ {{ entries_count|dict_get:activity }} + {% if entries_count|dict_get:activity >= 2 %}{% trans "entries" %}{% else %}{% trans "entry" %}{% endif %} +

+ {% endif %}
+ +{{ block.super }} {% endblock %} diff --git a/apps/activity/views.py b/apps/activity/views.py index 9011f0e1..9ef0d4f2 100644 --- a/apps/activity/views.py +++ b/apps/activity/views.py @@ -67,27 +67,49 @@ class ActivityListView(ProtectQuerysetMixin, LoginRequiredMixin, MultiTableMixin tables = [ lambda data: ActivityTable(data, prefix="all-"), lambda data: ActivityTable(data, prefix="upcoming-"), + lambda data: ActivityTable(data, prefix="search-"), ] extra_context = {"title": _("Activities")} def get_queryset(self, **kwargs): - return super().get_queryset(**kwargs).distinct() + """ + Filter the user list with the given pattern. + """ + return super().get_queryset().distinct() def get_tables_data(self): - # first table = all activities, second table = upcoming + # first table = all activities, second table = upcoming, third table = search + + # table search + qs = self.get_queryset().order_by('-date_start') + if "search" in self.request.GET and self.request.GET['search']: + pattern = self.request.GET['search'] + + # check regex + valid_regex = is_regex(pattern) + suffix = '__iregex' if valid_regex else '__istartswith' + prefix = '^' if valid_regex else '' + qs = qs.filter(Q(**{f'name{suffix}': prefix + pattern}) + | Q(**{f'organizer__name{suffix}': prefix + pattern}) + | Q(**{f'organizer__note__alias__name{suffix}': prefix + pattern})) + else: + qs = qs.none() + search_table = qs.filter(PermissionBackend.filter_queryset(self.request, Activity, 'view')) + return [ self.get_queryset().order_by("-date_start"), Activity.objects.filter(date_end__gt=timezone.now()) .filter(PermissionBackend.filter_queryset(self.request, Activity, "view")) .distinct() - .order_by("date_start") + .order_by("date_start"), + search_table, ] def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) tables = context["tables"] - for name, table in zip(["table", "upcoming"], tables): + for name, table in zip(["all", "upcoming", "table"], tables): context[name] = table started_activities = self.get_queryset().filter(open=True, valid=True).distinct().all() From 9907cfbd860985530f6af2329524918c62acb911 Mon Sep 17 00:00:00 2001 From: Ehouarn Date: Sat, 27 Sep 2025 01:17:33 +0200 Subject: [PATCH 5/6] Autocomplete Credit reason with 'Rechargement note' --- apps/note/static/note/js/transfer.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/note/static/note/js/transfer.js b/apps/note/static/note/js/transfer.js index 509d9b48..ce6ff6ff 100644 --- a/apps/note/static/note/js/transfer.js +++ b/apps/note/static/note/js/transfer.js @@ -66,6 +66,8 @@ $(document).ready(function () { arr.push(last) last.quantity = 1 + + if (last.note.club) { $('#last_name').val(last.note.name) @@ -111,7 +113,8 @@ $(document).ready(function () { dest.removeClass('d-none') $('#dest_note_list').removeClass('d-none') $('#debit_type').addClass('d-none') - + $('#reason').val('') + $('#source_note_label').text(select_emitters_label) $('#dest_note_label').text(select_receveirs_label) @@ -134,6 +137,7 @@ $(document).ready(function () { dest.val('') dest.tooltip('hide') $('#debit_type').addClass('d-none') + $('#reason').val('Rechargement note') $('#source_note_label').text(transfer_type_label) $('#dest_note_label').text(select_receveir_label) @@ -162,6 +166,7 @@ $(document).ready(function () { dest.addClass('d-none') dest.tooltip('hide') $('#debit_type').removeClass('d-none') + $('#reason').val('') $('#source_note_label').text(select_emitter_label) $('#dest_note_label').text(transfer_type_label) From 0962a3735eb025cb811d9071e3691ec2d74229b4 Mon Sep 17 00:00:00 2001 From: Ehouarn Date: Sat, 27 Sep 2025 13:19:48 +0200 Subject: [PATCH 6/6] Better Food search --- apps/food/tables.py | 18 +++++++++++++++++- apps/food/templates/food/food_list.html | 25 +++++++++++++++++++++++++ apps/food/views.py | 9 +++++++-- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/apps/food/tables.py b/apps/food/tables.py index 7789ad76..5b854e64 100644 --- a/apps/food/tables.py +++ b/apps/food/tables.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later import django_tables2 as tables +from django.utils.translation import gettext_lazy as _ from .models import Food @@ -10,10 +11,25 @@ class FoodTable(tables.Table): """ List all foods. """ + qr_code_numbers = tables.Column(empty_values=(), verbose_name=_("QR Codes"), orderable=False) + + date = tables.Column(empty_values=(), verbose_name=_("Arrival/creation date"), orderable=False) + + def render_date(self, record): + if record.__class__.__name__ == "BasicFood": + return record.arrival_date.strftime("%d/%m/%Y %H:%M") + elif record.__class__.__name__ == "TransformedFood": + return record.creation_date.strftime("%d/%m/%Y %H:%M") + else: + return "--" + + def render_qr_code_numbers(self, record): + return ", ".join(str(q.qr_code_number) for q in record.QR_code.all()) + class Meta: model = Food template_name = 'django_tables2/bootstrap4.html' - fields = ('name', 'owner', 'allergens', 'expiry_date') + fields = ('name', 'owner', 'qr_code_numbers', 'allergens', 'date', 'expiry_date') row_attrs = { 'class': 'table-row', 'data-href': lambda record: 'detail/' + str(record.pk), diff --git a/apps/food/templates/food/food_list.html b/apps/food/templates/food/food_list.html index bd54ece9..8e52a00a 100644 --- a/apps/food/templates/food/food_list.html +++ b/apps/food/templates/food/food_list.html @@ -34,6 +34,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
+
+ +
@@ -114,7 +120,26 @@ SPDX-License-Identifier: GPL-3.0-or-later {% endif %} +