From 79297b7a756e2f33e1242a8f57d79809db5dc8eb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Sep 2025 02:04:00 +0000 Subject: [PATCH 01/61] Bump vite from 6.3.5 to 6.3.6 Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.3.5 to 6.3.6. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v6.3.6/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v6.3.6/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-version: 6.3.6 dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4d92469f..774d7396 100644 --- a/package-lock.json +++ b/package-lock.json @@ -50,7 +50,7 @@ "@types/jquery": "^3.5.31", "@types/js-cookie": "^3.0.6", "typescript": "^5.8.3", - "vite": "^6.2.6", + "vite": "^6.3.6", "vite-bundle-visualizer": "^1.2.1", "vite-plugin-static-copy": "^3.1.2" } @@ -5737,9 +5737,9 @@ } }, "node_modules/vite": { - "version": "6.3.5", - "resolved": "https://registry.npmjs.org/vite/-/vite-6.3.5.tgz", - "integrity": "sha512-cZn6NDFE7wdTpINgs++ZJ4N49W2vRp8LCKrn3Ob1kYNtOo21vfDoaV5GzBfLU4MovSAB8uNRm4jgzVQZ+mBzPQ==", + "version": "6.3.6", + "resolved": "https://registry.npmjs.org/vite/-/vite-6.3.6.tgz", + "integrity": "sha512-0msEVHJEScQbhkbVTb/4iHZdJ6SXp/AvxL2sjwYQFfBqleHtnCqv1J3sa9zbWz/6kW1m9Tfzn92vW+kZ1WV6QA==", "dev": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index eb600f26..33363697 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "@types/jquery": "^3.5.31", "@types/js-cookie": "^3.0.6", "typescript": "^5.8.3", - "vite": "^6.2.6", + "vite": "^6.3.6", "vite-bundle-visualizer": "^1.2.1", "vite-plugin-static-copy": "^3.1.2" }, From ce2ef78a6df90f7e80bb3e9cdf21ff0ff78d598e Mon Sep 17 00:00:00 2001 From: imperosol Date: Sun, 21 Sep 2025 16:01:17 +0200 Subject: [PATCH 02/61] fix: 500 on page properties edit --- core/models.py | 18 +++++++++--------- core/tests/test_page.py | 26 ++++++++++++++++++++++++++ core/views/page.py | 2 +- 3 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 core/tests/test_page.py diff --git a/core/models.py b/core/models.py index f2a799c3..ac65708d 100644 --- a/core/models.py +++ b/core/models.py @@ -1275,12 +1275,9 @@ class Page(models.Model): def __str__(self): return self.get_full_name() - def save(self, *args, **kwargs): + def save(self, *args, force_lock: bool = False, **kwargs): """Performs some needed actions before and after saving a page in database.""" - locked = kwargs.pop("force_lock", False) - if not locked: - locked = self.is_locked() - if not locked: + if not force_lock and not self.is_locked(): raise NotLocked("The page is not locked and thus can not be saved") self.full_clean() if not self.id: @@ -1292,7 +1289,7 @@ class Page(models.Model): # It also update all the children to maintain correct names self._full_name = self.get_full_name() for c in self.children.all(): - c.save() + c.save(force_lock=force_lock) super().save(*args, **kwargs) self.unset_lock() @@ -1408,14 +1405,14 @@ class Page(models.Model): def need_club_redirection(self): return self.is_club_page and self.name != settings.SITH_CLUB_ROOT_PAGE - def delete(self): + def delete(self, *args, **kwargs): self.unset_lock_recursive() self.set_lock_recursive(User.objects.get(id=0)) for child in self.children.all(): child.parent = self.parent child.save() child.unset_lock_recursive() - super().delete() + return super().delete(*args, **kwargs) class PageRev(models.Model): @@ -1462,9 +1459,12 @@ class PageRev(models.Model): def get_absolute_url(self): return reverse("core:page", kwargs={"page_name": self.page._full_name}) - def can_be_edited_by(self, user): + def can_be_edited_by(self, user: User) -> bool: return self.page.can_be_edited_by(user) + def is_owned_by(self, user: User) -> bool: + return any(g.id == self.page.owner_group_id for g in user.cached_groups) + def get_notification_types(): return settings.SITH_NOTIFICATIONS diff --git a/core/tests/test_page.py b/core/tests/test_page.py new file mode 100644 index 00000000..39764c2d --- /dev/null +++ b/core/tests/test_page.py @@ -0,0 +1,26 @@ +import pytest +from django.test import Client +from django.urls import reverse +from model_bakery import baker +from pytest_django.asserts import assertRedirects + +from core.baker_recipes import board_user +from core.models import Page + + +@pytest.mark.django_db +def test_edit_page(client: Client): + user = board_user.make() + page = baker.prepare(Page) + page.save(force_lock=True) + page.view_groups.add(user.groups.first()) + client.force_login(user) + + url = reverse("core:page_edit", kwargs={"page_name": page._full_name}) + res = client.get(url) + assert res.status_code == 200 + + res = client.post(url, data={"content": "Hello World"}) + assertRedirects(res, reverse("core:page", kwargs={"page_name": page._full_name})) + revision = page.revisions.last() + assert revision.content == "Hello World" diff --git a/core/views/page.py b/core/views/page.py index db366891..9700d651 100644 --- a/core/views/page.py +++ b/core/views/page.py @@ -184,7 +184,7 @@ class PageEditViewBase(CanEditMixin, UpdateView): ) template_name = "core/pagerev_edit.jinja" - def get_object(self): + def get_object(self, *args, **kwargs): self.page = Page.get_page_by_full_name(self.kwargs["page_name"]) return self._get_revision() From dff23fae7f76430c0b120bbd6b5a71f9a3da4697 Mon Sep 17 00:00:00 2001 From: Sli Date: Mon, 22 Sep 2025 13:26:28 +0200 Subject: [PATCH 03/61] Migrate slideshow to alpine --- com/static/bundled/com/slideshow-index.ts | 47 +++++++++++ com/static/com/js/slideshow.js | 98 ----------------------- com/static/css/slideshow.scss | 79 +++++++++--------- com/templates/com/screen_slideshow.jinja | 33 +++++--- 4 files changed, 106 insertions(+), 151 deletions(-) create mode 100644 com/static/bundled/com/slideshow-index.ts delete mode 100644 com/static/com/js/slideshow.js diff --git a/com/static/bundled/com/slideshow-index.ts b/com/static/bundled/com/slideshow-index.ts new file mode 100644 index 00000000..6d5aad3e --- /dev/null +++ b/com/static/bundled/com/slideshow-index.ts @@ -0,0 +1,47 @@ +const INTERVAL = 10; + +interface Poster { + url: string; // URL of the poster + displayTime: number; // Number of seconds to display that poster +} + +document.addEventListener("alpine:init", () => { + Alpine.data("slideshow", (posters: Poster[]) => ({ + posters: posters, + progress: 0, + elapsed: 0, + + current: 0, + + init() { + this.$watch("elapsed", () => { + const displayTime = this.posters[this.current].displayTime * 1000; + if (this.elapsed > displayTime) { + this.current = this.getNext(); + this.elapsed = 0; + } + if (displayTime === 0) { + this.progress = 100; + } else { + this.progress = (100 * this.elapsed) / displayTime; + } + }); + setInterval(() => { + this.elapsed += INTERVAL; + }, INTERVAL); + }, + + getNext() { + return (this.current + 1) % this.posters.length; + }, + + async toggleFullScreen(event: Event) { + const target = event.target as HTMLElement; + if (document.fullscreenElement) { + await document.exitFullscreen(); + return; + } + await target.requestFullscreen(); + }, + })); +}); diff --git a/com/static/com/js/slideshow.js b/com/static/com/js/slideshow.js deleted file mode 100644 index 952af8b8..00000000 --- a/com/static/com/js/slideshow.js +++ /dev/null @@ -1,98 +0,0 @@ -$(document).ready(() => { - const transitionTime = 1000; - - let i = 0; - const max = $("#slideshow .slide").length; - - function enterFullscreen() { - const element = document.getElementById("slideshow"); - $(element).addClass("fullscreen"); - if (element.requestFullscreen) { - element.requestFullscreen(); - } else if (element.mozRequestFullScreen) { - element.mozRequestFullScreen(); - } else if (element.webkitRequestFullscreen) { - element.webkitRequestFullscreen(); - } else if (element.msRequestFullscreen) { - element.msRequestFullscreen(); - } - } - - function exitFullscreen() { - const element = document.getElementById("slideshow"); - $(element).removeClass("fullscreen"); - if (document.exitFullscreen) { - document.exitFullscreen(); - } else if (document.webkitExitFullscreen) { - document.webkitExitFullscreen(); - } else if (document.mozCancelFullScreen) { - document.mozCancelFullScreen(); - } else if (document.msExitFullscreen) { - document.msExitFullscreen(); - } - } - - function initProgressBar() { - $("#slideshow #progress_bar").css("transition", "none"); - $("#slideshow #progress_bar").removeClass("progress"); - $("#slideshow #progress_bar").addClass("init"); - } - - function startProgressBar(displayTime) { - $("#slideshow #progress_bar").removeClass("init"); - $("#slideshow #progress_bar").addClass("progress"); - $("#slideshow #progress_bar").css("transition", `width ${displayTime}s linear`); - } - - function next() { - initProgressBar(); - const slide = $($("#slideshow .slide").get(i % max)); - slide.removeClass("center"); - slide.addClass("left"); - - const nextSlide = $($("#slideshow .slide").get((i + 1) % max)); - nextSlide.removeClass("right"); - nextSlide.addClass("center"); - const displayTime = nextSlide.attr("display_time") || 2; - - $("#slideshow .bullet").removeClass("active"); - const bullet = $("#slideshow .bullet")[(i + 1) % max]; - $(bullet).addClass("active"); - - i = (i + 1) % max; - - setTimeout(() => { - const othersLeft = $("#slideshow .slide.left"); - othersLeft.removeClass("left"); - othersLeft.addClass("right"); - - startProgressBar(displayTime); - setTimeout(next, displayTime * 1000); - }, transitionTime); - } - - const displayTime = $("#slideshow .center").attr("display_time"); - initProgressBar(); - setTimeout(() => { - if (max > 1) { - startProgressBar(displayTime); - setTimeout(next, displayTime * 1000); - } - }, 10); - - $("#slideshow").click(() => { - if ($("#slideshow").hasClass("fullscreen")) { - exitFullscreen(); - } else { - enterFullscreen(); - } - }); - - $(document).keyup((e) => { - if (e.keyCode === 27) { - // escape key maps to keycode `27` - e.preventDefault(); - exitFullscreen(); - } - }); -}); diff --git a/com/static/css/slideshow.scss b/com/static/css/slideshow.scss index 9ea4fa52..cf30d0e6 100644 --- a/com/static/css/slideshow.scss +++ b/com/static/css/slideshow.scss @@ -1,4 +1,4 @@ -body{ +body { position: absolute; width: 100vw; height: 100vh; @@ -7,22 +7,22 @@ body{ margin: 0; } -#slideshow{ +#slideshow { position: relative; background-color: lightgrey; height: 100%; - *{ + * { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } - &:hover{ + &:hover { - &::before{ + &::before { position: absolute; width: 100%; @@ -43,7 +43,7 @@ body{ } - &.fullscreen{ + &:fullscreen { position: fixed; width: 100%; height: 100%; @@ -51,57 +51,58 @@ body{ left: 0; background: none; - &:before{ - display:none; + &:before { + display: none; } - #slides{ + #slides { height: 100vh; } } - #slides{ + #slides { position: relative; height: 100%; overflow: hidden; + background-color: grey; - .slide{ + .slide { position: absolute; width: 100%; height: 100%; - display: inline-flex; + display: none; justify-content: center; top: 0px; - background-color: grey; - transition: left 1s ease-out; - - img{ + img { max-width: 100%; max-height: 100%; object-fit: contain; } - } - .slide.left{ - left: -100%; - } + &.active { + animation: scrolling 1s; + display: inline-flex; + } - .slide.center{ - left: 0px; - } + @keyframes scrolling { + 0% { + transform: translateX(100%); + } + + 100% { + transform: translateX(0%); + } + } - .slide.right{ - left: 100%; - transition: none; } } - #progress_bullets{ + #progress_bullets { position: absolute; bottom: 10px; width: 100%; @@ -112,7 +113,7 @@ body{ margin-bottom: 10px; - .bullet{ + .bullet { height: 10px; width: 10px; @@ -123,27 +124,23 @@ body{ background-color: grey; - &.active{ + &.active { background-color: #c99836; } } } - #progress_bar{ + progress { position: absolute; bottom: 0px; height: 10px; - background-color: #304c83; + // color: #304c83; + width: 100%; + margin-bottom: 0px; + border: none; - &.init{ - width: 0px; - transition: none; - } - - &.progress{ - width: 100%; - transition: width 10s linear; + &[value] { + background-color: transparent; } } -} - +} \ No newline at end of file diff --git a/com/templates/com/screen_slideshow.jinja b/com/templates/com/screen_slideshow.jinja index 0374257e..f0716362 100644 --- a/com/templates/com/screen_slideshow.jinja +++ b/com/templates/com/screen_slideshow.jinja @@ -3,27 +3,36 @@ {% trans %}Slideshow{% endtrans %} - - + + - -
+ +
- {% for poster in posters %} -
- +
- {% for poster in posters %} -
- {% endfor %} +
-
+
From a7c96425c80454bd07bf2c5de2d6835761dd895b Mon Sep 17 00:00:00 2001 From: imperosol Date: Mon, 8 Sep 2025 07:27:39 +0200 Subject: [PATCH 04/61] fix: ClubSellingView N+1 queries --- club/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/club/views.py b/club/views.py index 4ed40a9c..b10c4a09 100644 --- a/club/views.py +++ b/club/views.py @@ -344,7 +344,7 @@ class ClubSellingView(ClubTabsMixin, CanEditMixin, DetailFormView): form = self.get_form() if form.is_valid(): if not len([v for v in form.cleaned_data.values() if v is not None]): - qs = Selling.objects.filter(id=-1) + qs = Selling.objects.none() if form.cleaned_data["begin_date"]: qs = qs.filter(date__gte=form.cleaned_data["begin_date"]) if form.cleaned_data["end_date"]: @@ -362,7 +362,9 @@ class ClubSellingView(ClubTabsMixin, CanEditMixin, DetailFormView): if len(selected_products) > 0: qs = qs.filter(product__in=selected_products) - kwargs["result"] = qs.all().order_by("-id") + kwargs["result"] = qs.select_related( + "counter", "counter__club", "customer", "customer__user", "seller" + ).order_by("-id") kwargs["total"] = sum([s.quantity * s.unit_price for s in kwargs["result"]]) total_quantity = qs.all().aggregate(Sum("quantity")) if total_quantity["quantity__sum"]: From 854dd2d9e7415c5920ca76a2c786a0e5d39778bc Mon Sep 17 00:00:00 2001 From: imperosol Date: Mon, 8 Sep 2025 13:49:23 +0200 Subject: [PATCH 05/61] add disclaimer for subscription purchase with AE account --- core/management/commands/populate.py | 2 +- core/templates/core/group_detail.jinja | 1 + locale/fr/LC_MESSAGES/django.po | 12 +++- sith/settings.py | 10 +--- subscription/forms.py | 32 +++++++---- ...15_alter_subscription_location_and_more.py | 56 +++++++++++++++++++ .../forms/create_existing_user.html | 14 ----- .../forms/create_existing_user.jinja | 28 ++++++++++ ...te_new_user.html => create_new_user.jinja} | 0 subscription/tests/test_dates.py | 18 +++--- subscription/tests/test_new_subscription.py | 14 ++--- 11 files changed, 136 insertions(+), 51 deletions(-) create mode 100644 subscription/migrations/0015_alter_subscription_location_and_more.py delete mode 100644 subscription/templates/subscription/forms/create_existing_user.html create mode 100644 subscription/templates/subscription/forms/create_existing_user.jinja rename subscription/templates/subscription/forms/{create_new_user.html => create_new_user.jinja} (100%) diff --git a/core/management/commands/populate.py b/core/management/commands/populate.py index 659dd5e9..cd0087e7 100644 --- a/core/management/commands/populate.py +++ b/core/management/commands/populate.py @@ -768,7 +768,7 @@ class Command(BaseCommand): s = Subscription( member=user, subscription_type=subscription_type, - payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0][0], + payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[1][0], ) s.subscription_start = s.compute_start(start) s.subscription_end = s.compute_end( diff --git a/core/templates/core/group_detail.jinja b/core/templates/core/group_detail.jinja index 0c9ebb53..3bad8b98 100644 --- a/core/templates/core/group_detail.jinja +++ b/core/templates/core/group_detail.jinja @@ -15,6 +15,7 @@ {{ select_all_checkbox("add_users") }}
{% csrf_token %} + {{ form.non_field_errors() }} {{ form.users_removed.errors }} {% for user in form.users_removed %} diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 9b43dadf..8a99daaa 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -4819,8 +4819,8 @@ msgid "N/A" msgstr "N/A" #: sith/settings.py -msgid "Transfert" -msgstr "Virement" +msgid "AE account" +msgstr "Compte AE" #: sith/settings.py msgid "Belfort" @@ -5168,6 +5168,14 @@ msgstr "lieu" msgid "You can not subscribe many time for the same period" msgstr "Vous ne pouvez pas cotiser plusieurs fois pour la même période" +#: subscription/templates/subscription/forms/create_existing_user.jinja +msgid "" +"If the subscription is done using the AE account, you must also click " +"it on the AE counter." +msgstr "" +"Si la cotisation est faite en utilisant le compte AE, vous devez également " +"la cliquer sur le comptoir AE." + #: subscription/templates/subscription/fragments/creation_success.jinja #, python-format msgid "Subscription created for %(user)s" diff --git a/sith/settings.py b/sith/settings.py index 52c93420..7595ddd0 100644 --- a/sith/settings.py +++ b/sith/settings.py @@ -421,18 +421,11 @@ SITH_PROFILE_DEPARTMENTS = [ ("NA", _("N/A")), ] -SITH_ACCOUNTING_PAYMENT_METHOD = [ - ("CHECK", _("Check")), - ("CASH", _("Cash")), - ("TRANSFERT", _("Transfert")), - ("CARD", _("Credit card")), -] - SITH_SUBSCRIPTION_PAYMENT_METHOD = [ ("CHECK", _("Check")), ("CARD", _("Credit card")), ("CASH", _("Cash")), - ("EBOUTIC", _("Eboutic")), + ("AE_ACCOUNT", _("AE account")), ("OTHER", _("Other")), ] @@ -441,6 +434,7 @@ SITH_SUBSCRIPTION_LOCATIONS = [ ("SEVENANS", _("Sevenans")), ("MONTBELIARD", _("Montbéliard")), ("EBOUTIC", _("Eboutic")), + ("OTHER", _("Other")), ] SITH_COUNTER_BARS = [(1, "MDE"), (2, "Foyer"), (35, "La Gommette")] diff --git a/subscription/forms.py b/subscription/forms.py index 1ac6964d..86624020 100644 --- a/subscription/forms.py +++ b/subscription/forms.py @@ -2,6 +2,7 @@ import secrets from typing import Any from django import forms +from django.conf import settings from django.core.exceptions import ValidationError from django.utils.translation import gettext_lazy as _ @@ -23,6 +24,13 @@ class SelectionDateForm(forms.Form): class SubscriptionForm(forms.ModelForm): + allowed_payment_methods = ["CARD", "CASH", "AE_ACCOUNT"] + + class Meta: + model = Subscription + fields = ["subscription_type", "payment_method", "location"] + widgets = {"payment_method": forms.RadioSelect} + def __init__(self, *args, initial=None, **kwargs): initial = initial or {} if "subscription_type" not in initial: @@ -30,6 +38,14 @@ class SubscriptionForm(forms.ModelForm): if "payment_method" not in initial: initial["payment_method"] = "CARD" super().__init__(*args, initial=initial, **kwargs) + self.fields["payment_method"].choices = [ + m + for m in settings.SITH_SUBSCRIPTION_PAYMENT_METHOD + if m[0] in self.allowed_payment_methods + ] + self.fields["location"].choices = [ + m for m in settings.SITH_SUBSCRIPTION_LOCATIONS if m[0] != "EBOUTIC" + ] def save(self, *args, **kwargs): if self.errors: @@ -61,7 +77,8 @@ class SubscriptionNewUserForm(SubscriptionForm): assert user.is_subscribed """ - template_name = "subscription/forms/create_new_user.html" + allowed_payment_methods = ["CARD", "CASH"] + template_name = "subscription/forms/create_new_user.jinja" __user_fields = forms.fields_for_model( User, @@ -73,10 +90,6 @@ class SubscriptionNewUserForm(SubscriptionForm): email = __user_fields["email"] date_of_birth = __user_fields["date_of_birth"] - class Meta: - model = Subscription - fields = ["subscription_type", "payment_method", "location"] - field_order = [ "first_name", "last_name", @@ -130,7 +143,7 @@ class SubscriptionNewUserForm(SubscriptionForm): class SubscriptionExistingUserForm(SubscriptionForm): """Form to add a subscription to an existing user.""" - template_name = "subscription/forms/create_existing_user.html" + template_name = "subscription/forms/create_existing_user.jinja" required_css_class = "required" birthdate = forms.fields_for_model( @@ -140,10 +153,9 @@ class SubscriptionExistingUserForm(SubscriptionForm): help_texts={"date_of_birth": _("This user didn't fill its birthdate yet.")}, )["date_of_birth"] - class Meta: - model = Subscription - fields = ["member", "subscription_type", "payment_method", "location"] - widgets = {"member": AutoCompleteSelectUser} + class Meta(SubscriptionForm.Meta): + fields = ["member", *SubscriptionForm.Meta.fields] + widgets = SubscriptionForm.Meta.widgets | {"member": AutoCompleteSelectUser} field_order = [ "member", diff --git a/subscription/migrations/0015_alter_subscription_location_and_more.py b/subscription/migrations/0015_alter_subscription_location_and_more.py new file mode 100644 index 00000000..6aed659e --- /dev/null +++ b/subscription/migrations/0015_alter_subscription_location_and_more.py @@ -0,0 +1,56 @@ +# Generated by Django 5.2.3 on 2025-09-08 05:38 + +from django.db import migrations, models +from django.db.migrations.state import StateApps + + +def rename_enums(apps: StateApps, schema_editor): + Subscription = apps.get_model("subscription", "Subscription") + Subscription.objects.filter(subscription_type="EBOUTIC").update( + subscription_type="AE_ACCOUNT" + ) + + +def rename_enums_reverse(apps: StateApps, schema_editor): + Subscription = apps.get_model("subscription", "Subscription") + Subscription.objects.filter(subscription_type="AE_ACCOUNT").update( + subscription_type="EBOUTIC" + ) + + +class Migration(migrations.Migration): + dependencies = [("subscription", "0014_auto_20201207_2323")] + + operations = [ + migrations.AlterField( + model_name="subscription", + name="location", + field=models.CharField( + choices=[ + ("BELFORT", "Belfort"), + ("SEVENANS", "Sevenans"), + ("MONTBELIARD", "Montbéliard"), + ("EBOUTIC", "Eboutic"), + ("OTHER", "Other"), + ], + max_length=20, + verbose_name="location", + ), + ), + migrations.AlterField( + model_name="subscription", + name="payment_method", + field=models.CharField( + choices=[ + ("CHECK", "Check"), + ("CARD", "Credit card"), + ("CASH", "Cash"), + ("AE_ACCOUNT", "AE account"), + ("OTHER", "Other"), + ], + max_length=255, + verbose_name="payment method", + ), + ), + migrations.RunPython(rename_enums, reverse_code=rename_enums_reverse), + ] diff --git a/subscription/templates/subscription/forms/create_existing_user.html b/subscription/templates/subscription/forms/create_existing_user.html deleted file mode 100644 index 2f1cbc99..00000000 --- a/subscription/templates/subscription/forms/create_existing_user.html +++ /dev/null @@ -1,14 +0,0 @@ -{% load static %} -{% load i18n %} - - -
-
- {{ form.as_p }} -
-
-
diff --git a/subscription/templates/subscription/forms/create_existing_user.jinja b/subscription/templates/subscription/forms/create_existing_user.jinja new file mode 100644 index 00000000..380abb01 --- /dev/null +++ b/subscription/templates/subscription/forms/create_existing_user.jinja @@ -0,0 +1,28 @@ +{% load static %} +{% load i18n %} + + +
+
+ {{ errors }} + {% for field, errors in fields %} + + {{ field.label_tag }} + {{ field }} + {% if field.help_text %} + {{ field.help_text }} + {% endif %} +

+ {% if field.name == "payment_method" %} + + {% blocktranslate %}If the subscription is done using the AE account, you must also click it on the AE counter.{% endblocktranslate %} + + {% endif %} + {% endfor %} +
+
+
diff --git a/subscription/templates/subscription/forms/create_new_user.html b/subscription/templates/subscription/forms/create_new_user.jinja similarity index 100% rename from subscription/templates/subscription/forms/create_new_user.html rename to subscription/templates/subscription/forms/create_new_user.jinja diff --git a/subscription/tests/test_dates.py b/subscription/tests/test_dates.py index 181246b1..f81cac82 100644 --- a/subscription/tests/test_dates.py +++ b/subscription/tests/test_dates.py @@ -90,7 +90,7 @@ class TestSubscriptionIntegration(TestCase): s = Subscription( member=self.user, subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[3], - payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0], + payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[1], ) s.subscription_start = date(2017, 8, 29) s.subscription_end = s.compute_end(duration=0.166, start=s.subscription_start) @@ -101,7 +101,7 @@ class TestSubscriptionIntegration(TestCase): s = Subscription( member=self.user, subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[3], - payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0], + payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[1], ) s.subscription_start = date(2017, 8, 29) s.subscription_end = s.compute_end(duration=0.333, start=s.subscription_start) @@ -112,7 +112,7 @@ class TestSubscriptionIntegration(TestCase): s = Subscription( member=self.user, subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[3], - payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0], + payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[1], ) s.subscription_start = date(2017, 8, 29) s.subscription_end = s.compute_end( @@ -126,7 +126,7 @@ class TestSubscriptionIntegration(TestCase): s = Subscription( member=self.user, subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[3], - payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0], + payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[1], ) s.subscription_start = date(2017, 8, 29) s.subscription_end = s.compute_end(duration=0.5, start=s.subscription_start) @@ -137,7 +137,7 @@ class TestSubscriptionIntegration(TestCase): s = Subscription( member=self.user, subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[3], - payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0], + payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[1], ) s.subscription_start = date(2017, 8, 29) s.subscription_end = s.compute_end(duration=0.67, start=s.subscription_start) @@ -148,7 +148,7 @@ class TestSubscriptionIntegration(TestCase): s = Subscription( member=self.user, subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[3], - payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0], + payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[1], ) s.subscription_start = date(2018, 9, 1) s.subscription_end = s.compute_end(duration=0.23, start=s.subscription_start) @@ -160,7 +160,7 @@ class TestSubscriptionIntegration(TestCase): s = Subscription( member=user, subscription_type="deux-semestres", - payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0], + payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[1], ) s.subscription_start = date(2015, 8, 29) s.subscription_end = s.compute_end( @@ -181,7 +181,7 @@ class TestSubscriptionIntegration(TestCase): s = Subscription( member=user, subscription_type="deux-mois-essai", - payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0], + payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[1], ) s.subscription_start = date(2015, 8, 29) s.subscription_end = s.compute_end( @@ -202,7 +202,7 @@ class TestSubscriptionIntegration(TestCase): s = Subscription( member=user, subscription_type="deux-mois-essai", - payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0], + payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[1], ) s.subscription_start = date(2015, 8, 29) s.subscription_end = s.compute_end( diff --git a/subscription/tests/test_new_subscription.py b/subscription/tests/test_new_subscription.py index 5933fe57..3833e48b 100644 --- a/subscription/tests/test_new_subscription.py +++ b/subscription/tests/test_new_subscription.py @@ -38,7 +38,7 @@ def test_form_existing_user_valid( "birthdate": user.date_of_birth, "subscription_type": "deux-semestres", "location": settings.SITH_SUBSCRIPTION_LOCATIONS[0][0], - "payment_method": settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0][0], + "payment_method": settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[1][0], } form = SubscriptionExistingUserForm(data) assert form.is_valid() @@ -55,7 +55,7 @@ def test_form_existing_user_with_birthdate(settings: SettingsWrapper): "member": user, "subscription_type": "deux-semestres", "location": settings.SITH_SUBSCRIPTION_LOCATIONS[0][0], - "payment_method": settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0][0], + "payment_method": settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[1][0], } form = SubscriptionExistingUserForm(data) assert not form.is_valid() @@ -81,7 +81,7 @@ def test_form_existing_user_invalid(settings: SettingsWrapper): "member": user, "subscription_type": "deux-semestres", "location": settings.SITH_SUBSCRIPTION_LOCATIONS[0][0], - "payment_method": settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0][0], + "payment_method": settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[1][0], } form = SubscriptionExistingUserForm(data) @@ -99,7 +99,7 @@ def test_form_new_user(settings: SettingsWrapper): "date_of_birth": localdate() - relativedelta(years=18), "subscription_type": "deux-semestres", "location": settings.SITH_SUBSCRIPTION_LOCATIONS[0][0], - "payment_method": settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0][0], + "payment_method": settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[1][0], } form = SubscriptionNewUserForm(data) assert form.is_valid() @@ -130,7 +130,7 @@ def test_form_set_new_user_as_student(settings: SettingsWrapper, subscription_ty "date_of_birth": localdate() - relativedelta(years=18), "subscription_type": subscription_type, "location": settings.SITH_SUBSCRIPTION_LOCATIONS[0][0], - "payment_method": settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0][0], + "payment_method": settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[1][0], } form = SubscriptionNewUserForm(data) assert form.is_valid() @@ -180,7 +180,7 @@ def test_submit_form_existing_user(client: Client, settings: SettingsWrapper): "birthdate": user.date_of_birth, "subscription_type": "deux-semestres", "location": settings.SITH_SUBSCRIPTION_LOCATIONS[0][0], - "payment_method": settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0][0], + "payment_method": settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[1][0], }, ) user.refresh_from_db() @@ -212,7 +212,7 @@ def test_submit_form_new_user(client: Client, settings: SettingsWrapper): "date_of_birth": localdate() - relativedelta(years=18), "subscription_type": "deux-semestres", "location": settings.SITH_SUBSCRIPTION_LOCATIONS[0][0], - "payment_method": settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0][0], + "payment_method": settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[1][0], }, ) user = User.objects.get(email="jdoe@utbm.fr") From 95e6fff98b7a496193f8c039122920d1de732df5 Mon Sep 17 00:00:00 2001 From: Sli Date: Mon, 22 Sep 2025 14:30:23 +0200 Subject: [PATCH 06/61] Migrate poster view to alpine --- com/static/com/css/posters.scss | 2 +- com/static/com/js/poster_list.js | 23 ---------------------- com/static/css/slideshow.scss | 2 +- com/templates/com/poster_list.jinja | 25 +++++++++++++++--------- com/templates/com/screen_slideshow.jinja | 2 +- locale/fr/LC_MESSAGES/django.po | 6 +++++- 6 files changed, 24 insertions(+), 36 deletions(-) delete mode 100644 com/static/com/js/poster_list.js diff --git a/com/static/com/css/posters.scss b/com/static/com/css/posters.scss index 26cf2b91..e3863bdb 100644 --- a/com/static/com/css/posters.scss +++ b/com/static/com/css/posters.scss @@ -111,7 +111,7 @@ top: 0; left: 0; z-index: 10; - content: "Click to expand"; + content: attr(hover); color: white; background-color: rgba(black, 0.5); } diff --git a/com/static/com/js/poster_list.js b/com/static/com/js/poster_list.js deleted file mode 100644 index 8ffb97c4..00000000 --- a/com/static/com/js/poster_list.js +++ /dev/null @@ -1,23 +0,0 @@ -$(document).ready(() => { - $("#poster_list #view").click(() => { - $("#view").removeClass("active"); - }); - - $("#poster_list .poster .image").click((e) => { - let el = $(e.target); - if (el.hasClass("image")) { - el = el.find("img"); - } - $("#poster_list #view #placeholder").html(el.clone()); - - $("#view").addClass("active"); - }); - - $(document).keyup((e) => { - if (e.keyCode === 27) { - // escape key maps to keycode `27` - e.preventDefault(); - $("#view").removeClass("active"); - } - }); -}); diff --git a/com/static/css/slideshow.scss b/com/static/css/slideshow.scss index cf30d0e6..da2bc178 100644 --- a/com/static/css/slideshow.scss +++ b/com/static/css/slideshow.scss @@ -34,7 +34,7 @@ body { z-index: 10; - content: "Click to expand"; + content: attr(hover); color: white; background-color: rgba(black, 0.5); diff --git a/com/templates/com/poster_list.jinja b/com/templates/com/poster_list.jinja index c9af62c0..8afe5e42 100644 --- a/com/templates/com/poster_list.jinja +++ b/com/templates/com/poster_list.jinja @@ -1,11 +1,5 @@ {% extends "core/base.jinja" %} -{% block script %} - {{ super() }} - -{% endblock %} - - {% block title %} {% trans %}Poster{% endtrans %} {% endblock %} @@ -15,7 +9,7 @@ {% endblock %} {% block content %} -
+

{% trans %}Posters{% endtrans %}

@@ -38,7 +32,13 @@ {% for poster in poster_list %}
{{ poster.name }}
-
+
+ +
{{ poster.date_begin | localtime | date("d/M/Y H:m") }}
{{ poster.date_end | localtime | date("d/M/Y H:m") }}
@@ -62,7 +62,14 @@
-
+
+
+
{% endblock %} diff --git a/com/templates/com/screen_slideshow.jinja b/com/templates/com/screen_slideshow.jinja index f0716362..8b53f0e6 100644 --- a/com/templates/com/screen_slideshow.jinja +++ b/com/templates/com/screen_slideshow.jinja @@ -14,7 +14,7 @@ }, {% endfor %} ])"> -
+