mirror of
https://github.com/ae-utbm/sith.git
synced 2025-09-23 00:23:52 +00:00
add disclaimer for subscription purchase with AE account
This commit is contained in:
@@ -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(
|
||||
|
@@ -15,6 +15,7 @@
|
||||
{{ select_all_checkbox("add_users") }}
|
||||
<hr>
|
||||
{% csrf_token %}
|
||||
{{ form.non_field_errors() }}
|
||||
<label for="{{ form.users_removed.id_for_label }}">{{ form.users_removed.label }} :</label>
|
||||
{{ form.users_removed.errors }}
|
||||
{% for user in form.users_removed %}
|
||||
|
@@ -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"
|
||||
|
@@ -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")]
|
||||
|
@@ -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",
|
||||
|
@@ -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),
|
||||
]
|
@@ -1,14 +0,0 @@
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
|
||||
|
||||
<div x-data="existing_user_subscription_form" class="form-content existing-user">
|
||||
<fieldset>
|
||||
{{ form.as_p }}
|
||||
</fieldset>
|
||||
<div
|
||||
id="subscription-form-user-mini-profile"
|
||||
x-html="profileFragment"
|
||||
:aria-busy="loading"
|
||||
></div>
|
||||
</div>
|
@@ -0,0 +1,28 @@
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
|
||||
|
||||
<div x-data="existing_user_subscription_form" class="form-content existing-user">
|
||||
<fieldset>
|
||||
{{ errors }}
|
||||
{% for field, errors in fields %}
|
||||
<p{% with classes=field.css_classes %}{% if classes %} class="{{ classes }}"{% endif %}{% endwith %}>
|
||||
{{ field.label_tag }}
|
||||
{{ field }}
|
||||
{% if field.help_text %}
|
||||
<span class="helptext">{{ field.help_text }}</span>
|
||||
{% endif %}
|
||||
</p>
|
||||
{% if field.name == "payment_method" %}
|
||||
<i>
|
||||
{% blocktranslate %}If the subscription is done using the AE account, you must also click it on the AE counter.{% endblocktranslate %}
|
||||
</i>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
<div
|
||||
id="subscription-form-user-mini-profile"
|
||||
x-html="profileFragment"
|
||||
:aria-busy="loading"
|
||||
></div>
|
||||
</div>
|
@@ -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(
|
||||
|
@@ -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")
|
||||
|
Reference in New Issue
Block a user