Compare commits

...

5 Commits

Author SHA1 Message Date
Kenneth SOARES
2550fd0af7 update subscription price 2025-10-06 13:37:50 +02:00
thomas girod
4b44e50780 Merge pull request #1193 from ae-utbm/optimize-jinja
Optimisations
2025-10-02 19:05:03 +02:00
imperosol
40c3276c3c remove spaces from autocomplete selects 2025-09-29 17:43:50 +02:00
imperosol
543a424258 fix: N+1 on news list for admins 2025-09-29 16:10:50 +02:00
imperosol
8ff25e6034 optimize main page notifications 2025-09-29 08:45:56 +02:00
8 changed files with 94 additions and 68 deletions

View File

@@ -76,18 +76,20 @@
It will stay hidden for other users until it has been published.
{% endtrans %}
</p>
{% if user.has_perm("com.moderate_news") %}
{%- if user.has_perm("com.moderate_news") -%}
{# This is an additional query for each non-moderated news,
but it will be executed only for admin users, and only one time
(if they do their job and moderated news as soon as they see them),
(if they do their job and moderate news as soon as they see them),
so it's still reasonable #}
<div
{% if news is integer or news is string %}
{% if news is integer or news is string -%}
x-data="{ nbEvents: 0 }"
x-init="nbEvents = await nbToPublish()"
{% else %}
{%- elif news.is_published -%}
x-data="{ nbEvents: 0 }"
{%- else -%}
x-data="{ nbEvents: {{ news.dates.count() }} }"
{% endif %}
{%- endif -%}
>
<template x-if="nbEvents > 1">
<div>

View File

@@ -77,22 +77,22 @@
<div class="notification" x-data="{display: false}" :class="{white: display}">
<a href="#" @click.prevent="display = !display">
<i :class="`fa-${display ? 'solid': 'regular'} fa-bell`" x-transition></i>
{% set notification_count = user.notifications.filter(viewed=False).count() %}
{% set notifications = user.notifications.filter(viewed=False).order_by("-date")|list %}
{% if notification_count > 0 %}
{%- if notifications|length > 0 -%}
<span>
{% if notification_count < 100 %}
{{ notification_count }}
{% else %}
&nbsp;
{% endif %}
{% if notifications|length < 100 %}
{{ notifications|length }}
{%- else -%}
99+
{%- endif -%}
</span>
{% endif %}
</a>
<div id="header_notif" x-show="display" x-cloak x-transition @click.outside="display = false">
<ul>
{% if user.notifications.filter(viewed=False).count() > 0 %}
{% for n in user.notifications.filter(viewed=False).order_by('-date') %}
{%- if notifications|length > 0 -%}
{%- for n in notifications -%}
<li>
<a href="{{ url("core:notification", notif_id=n.id) }}">
<div class="datetime">
@@ -108,10 +108,10 @@
</div>
</a>
</li>
{% endfor %}
{% else %}
{%- endfor -%}
{%- else -%}
<li class="empty-notification">{% trans %}You do not have any unread notification{% endtrans %}</li>
{% endif %}
{%- endif -%}
</ul>
<div class="options">
<a href="{{ url('core:notification_list') }}">

View File

@@ -1,12 +1,13 @@
{% for js in statics.js %}
{% spaceless %}
{% for js in statics.js %}
<script-once type="module" src="{{ js }}"></script-once>
{% endfor %}
{% for css in statics.css %}
{% endfor %}
{% for css in statics.css %}
<link-once rel="stylesheet" type="text/css" href="{{ css }}" defer></link-once>
{% endfor %}
{% endfor %}
<{{ component }} name="{{ widget.name }}" {% include "django/forms/widgets/attrs.html" %}>
{% for group_name, group_choices, group_index in widget.optgroups %}
<{{ component }} name="{{ widget.name }}" {% include "django/forms/widgets/attrs.html" %}>
{% for group_name, group_choices, group_index in widget.optgroups %}
{% if group_name %}
<optgroup label="{{ group_name }}">
{% endif %}
@@ -16,8 +17,9 @@
{% if group_name %}
</optgroup>
{% endif %}
{% endfor %}
{% if initial %}
{% endfor %}
{% if initial %}
<slot style="display:none" name="initial">{{ initial }}</slot>
{% endif %}
</{{ component }}>
{% endif %}
</{{ component }}>
{% endspaceless %}

View File

@@ -67,13 +67,13 @@
<option value="FIN">{% trans %}Confirm (FIN){% endtrans %}</option>
<option value="ANN">{% trans %}Cancel (ANN){% endtrans %}</option>
</optgroup>
{% for category in categories.keys() %}
{%- for category in categories.keys() -%}
<optgroup label="{{ category }}">
{% for product in categories[category] %}
{%- for product in categories[category] -%}
<option value="{{ product.id }}">{{ product }}</option>
{% endfor %}
{%- endfor -%}
</optgroup>
{% endfor %}
{%- endfor -%}
</counter-product-select>
<input type="submit" value="{% trans %}Go{% endtrans %}"/>

View File

@@ -4974,47 +4974,47 @@ msgstr "Suppression de rechargement"
#: sith/settings.py
msgid "One semester"
msgstr "Un semestre, 20 €"
msgstr "Un semestre"
#: sith/settings.py
msgid "Two semesters"
msgstr "Deux semestres, 35 €"
msgstr "Deux semestres"
#: sith/settings.py
msgid "Common core cursus"
msgstr "Cursus tronc commun, 60 €"
msgstr "Cursus tronc commun"
#: sith/settings.py
msgid "Branch cursus"
msgstr "Cursus branche, 60 €"
msgstr "Cursus branche"
#: sith/settings.py
msgid "Alternating cursus"
msgstr "Cursus alternant, 30 €"
msgstr "Cursus alternant"
#: sith/settings.py
msgid "Honorary member"
msgstr "Membre honoraire, 0 €"
msgstr "Membre honoraire"
#: sith/settings.py
msgid "Assidu member"
msgstr "Membre d'Assidu, 0 €"
msgstr "Membre d'Assidu"
#: sith/settings.py
msgid "Amicale/DOCEO member"
msgstr "Membre de l'Amicale/DOCEO, 0 €"
msgstr "Membre de l'Amicale/DOCEO"
#: sith/settings.py
msgid "UT network member"
msgstr "Cotisant du réseau UT, 0 €"
msgstr "Cotisant du réseau UT"
#: sith/settings.py
msgid "CROUS member"
msgstr "Membres du CROUS, 0 €"
msgstr "Membres du CROUS"
#: sith/settings.py
msgid "Sbarro/ESTA member"
msgstr "Membre de Sbarro ou de l'ESTA, 20 €"
msgstr "Membre de Sbarro ou de l'ESTA"
#: sith/settings.py
msgid "One semester Welcome Week"
@@ -5041,28 +5041,28 @@ msgid "One day"
msgstr "Un jour"
#: sith/settings.py
msgid "GA staff member"
msgstr "Membre staff GA (2 semaines), 1 €"
msgid "GA staff member (2 weeks)"
msgstr "Membre staff GA (2 semaines)"
#: sith/settings.py
msgid "One semester (-20%)"
msgstr "Un semestre (-20%), 12 €"
msgstr "Un semestre (-20%)"
#: sith/settings.py
msgid "Two semesters (-20%)"
msgstr "Deux semestres (-20%), 22 €"
msgstr "Deux semestres (-20%)"
#: sith/settings.py
msgid "Common core cursus (-20%)"
msgstr "Cursus tronc commun (-20%), 36 €"
msgstr "Cursus tronc commun (-20%)"
#: sith/settings.py
msgid "Branch cursus (-20%)"
msgstr "Cursus branche (-20%), 36 €"
msgstr "Cursus branche (-20%)"
#: sith/settings.py
msgid "Alternating cursus (-20%)"
msgstr "Cursus alternant (-20%), 24 €"
msgstr "Cursus alternant (-20%)"
#: sith/settings.py
msgid "One year for free(CA offer)"

View File

@@ -541,7 +541,7 @@ SITH_SUBSCRIPTIONS = {
"duration": 4,
},
"cursus-branche": {"name": _("Branch cursus"), "price": 60, "duration": 6},
"cursus-alternant": {"name": _("Alternating cursus"), "price": 30, "duration": 6},
"cursus-alternant": {"name": _("Alternating cursus"), "price": 35, "duration": 6},
"membre-honoraire": {"name": _("Honorary member"), "price": 0, "duration": 666},
"assidu": {"name": _("Assidu member"), "price": 0, "duration": 2},
"amicale/doceo": {"name": _("Amicale/DOCEO member"), "price": 0, "duration": 2},
@@ -553,8 +553,6 @@ SITH_SUBSCRIPTIONS = {
"price": 0,
"duration": 1,
},
"un-mois-essai": {"name": _("One month for free"), "price": 0, "duration": 0.166},
"deux-mois-essai": {"name": _("Two months for free"), "price": 0, "duration": 0.33},
"benevoles-euroks": {"name": _("Eurok's volunteer"), "price": 5, "duration": 0.1},
"six-semaines-essai": {
"name": _("Six weeks for free"),

View File

@@ -0,0 +1,21 @@
# Generated by Django 5.2.3 on 2025-10-06 11:24
from django.db import migrations, models
import subscription.models
class Migration(migrations.Migration):
dependencies = [("subscription", "0015_alter_subscription_location_and_more")]
operations = [
migrations.AlterField(
model_name="subscription",
name="subscription_type",
field=models.CharField(
choices=subscription.models.get_subscription_types,
max_length=255,
verbose_name="subscription type",
),
)
]

View File

@@ -38,16 +38,19 @@ def validate_payment(value):
raise ValidationError(_("Bad payment method"))
def get_subscription_types():
return (
(k, f"{v['name']}, {v['price']}")
for k, v in sorted(settings.SITH_SUBSCRIPTIONS.items())
)
class Subscription(models.Model):
member = models.ForeignKey(
User, related_name="subscriptions", on_delete=models.CASCADE
)
subscription_type = models.CharField(
_("subscription type"),
max_length=255,
choices=(
(k, v["name"]) for k, v in sorted(settings.SITH_SUBSCRIPTIONS.items())
),
_("subscription type"), max_length=255, choices=get_subscription_types
)
subscription_start = models.DateField(_("subscription start"))
subscription_end = models.DateField(_("subscription end"))