mirror of
https://github.com/ae-utbm/sith.git
synced 2025-09-23 00:23:52 +00:00
Merge pull request #1181 from ae-utbm/fix-subscription
Fix subscription
This commit is contained in:
@@ -344,7 +344,7 @@ class ClubSellingView(ClubTabsMixin, CanEditMixin, DetailFormView):
|
|||||||
form = self.get_form()
|
form = self.get_form()
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
if not len([v for v in form.cleaned_data.values() if v is not None]):
|
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"]:
|
if form.cleaned_data["begin_date"]:
|
||||||
qs = qs.filter(date__gte=form.cleaned_data["begin_date"])
|
qs = qs.filter(date__gte=form.cleaned_data["begin_date"])
|
||||||
if form.cleaned_data["end_date"]:
|
if form.cleaned_data["end_date"]:
|
||||||
@@ -362,7 +362,9 @@ class ClubSellingView(ClubTabsMixin, CanEditMixin, DetailFormView):
|
|||||||
if len(selected_products) > 0:
|
if len(selected_products) > 0:
|
||||||
qs = qs.filter(product__in=selected_products)
|
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"]])
|
kwargs["total"] = sum([s.quantity * s.unit_price for s in kwargs["result"]])
|
||||||
total_quantity = qs.all().aggregate(Sum("quantity"))
|
total_quantity = qs.all().aggregate(Sum("quantity"))
|
||||||
if total_quantity["quantity__sum"]:
|
if total_quantity["quantity__sum"]:
|
||||||
|
@@ -768,7 +768,7 @@ class Command(BaseCommand):
|
|||||||
s = Subscription(
|
s = Subscription(
|
||||||
member=user,
|
member=user,
|
||||||
subscription_type=subscription_type,
|
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_start = s.compute_start(start)
|
||||||
s.subscription_end = s.compute_end(
|
s.subscription_end = s.compute_end(
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
{{ select_all_checkbox("add_users") }}
|
{{ select_all_checkbox("add_users") }}
|
||||||
<hr>
|
<hr>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
{{ form.non_field_errors() }}
|
||||||
<label for="{{ form.users_removed.id_for_label }}">{{ form.users_removed.label }} :</label>
|
<label for="{{ form.users_removed.id_for_label }}">{{ form.users_removed.label }} :</label>
|
||||||
{{ form.users_removed.errors }}
|
{{ form.users_removed.errors }}
|
||||||
{% for user in form.users_removed %}
|
{% for user in form.users_removed %}
|
||||||
|
@@ -4819,8 +4819,8 @@ msgid "N/A"
|
|||||||
msgstr "N/A"
|
msgstr "N/A"
|
||||||
|
|
||||||
#: sith/settings.py
|
#: sith/settings.py
|
||||||
msgid "Transfert"
|
msgid "AE account"
|
||||||
msgstr "Virement"
|
msgstr "Compte AE"
|
||||||
|
|
||||||
#: sith/settings.py
|
#: sith/settings.py
|
||||||
msgid "Belfort"
|
msgid "Belfort"
|
||||||
@@ -5168,6 +5168,14 @@ msgstr "lieu"
|
|||||||
msgid "You can not subscribe many time for the same period"
|
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"
|
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
|
#: subscription/templates/subscription/fragments/creation_success.jinja
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Subscription created for %(user)s"
|
msgid "Subscription created for %(user)s"
|
||||||
|
@@ -421,18 +421,11 @@ SITH_PROFILE_DEPARTMENTS = [
|
|||||||
("NA", _("N/A")),
|
("NA", _("N/A")),
|
||||||
]
|
]
|
||||||
|
|
||||||
SITH_ACCOUNTING_PAYMENT_METHOD = [
|
|
||||||
("CHECK", _("Check")),
|
|
||||||
("CASH", _("Cash")),
|
|
||||||
("TRANSFERT", _("Transfert")),
|
|
||||||
("CARD", _("Credit card")),
|
|
||||||
]
|
|
||||||
|
|
||||||
SITH_SUBSCRIPTION_PAYMENT_METHOD = [
|
SITH_SUBSCRIPTION_PAYMENT_METHOD = [
|
||||||
("CHECK", _("Check")),
|
("CHECK", _("Check")),
|
||||||
("CARD", _("Credit card")),
|
("CARD", _("Credit card")),
|
||||||
("CASH", _("Cash")),
|
("CASH", _("Cash")),
|
||||||
("EBOUTIC", _("Eboutic")),
|
("AE_ACCOUNT", _("AE account")),
|
||||||
("OTHER", _("Other")),
|
("OTHER", _("Other")),
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -441,6 +434,7 @@ SITH_SUBSCRIPTION_LOCATIONS = [
|
|||||||
("SEVENANS", _("Sevenans")),
|
("SEVENANS", _("Sevenans")),
|
||||||
("MONTBELIARD", _("Montbéliard")),
|
("MONTBELIARD", _("Montbéliard")),
|
||||||
("EBOUTIC", _("Eboutic")),
|
("EBOUTIC", _("Eboutic")),
|
||||||
|
("OTHER", _("Other")),
|
||||||
]
|
]
|
||||||
|
|
||||||
SITH_COUNTER_BARS = [(1, "MDE"), (2, "Foyer"), (35, "La Gommette")]
|
SITH_COUNTER_BARS = [(1, "MDE"), (2, "Foyer"), (35, "La Gommette")]
|
||||||
|
@@ -2,6 +2,7 @@ import secrets
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
|
from django.conf import settings
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
@@ -23,6 +24,13 @@ class SelectionDateForm(forms.Form):
|
|||||||
|
|
||||||
|
|
||||||
class SubscriptionForm(forms.ModelForm):
|
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):
|
def __init__(self, *args, initial=None, **kwargs):
|
||||||
initial = initial or {}
|
initial = initial or {}
|
||||||
if "subscription_type" not in initial:
|
if "subscription_type" not in initial:
|
||||||
@@ -30,6 +38,14 @@ class SubscriptionForm(forms.ModelForm):
|
|||||||
if "payment_method" not in initial:
|
if "payment_method" not in initial:
|
||||||
initial["payment_method"] = "CARD"
|
initial["payment_method"] = "CARD"
|
||||||
super().__init__(*args, initial=initial, **kwargs)
|
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):
|
def save(self, *args, **kwargs):
|
||||||
if self.errors:
|
if self.errors:
|
||||||
@@ -61,7 +77,8 @@ class SubscriptionNewUserForm(SubscriptionForm):
|
|||||||
assert user.is_subscribed
|
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_fields = forms.fields_for_model(
|
||||||
User,
|
User,
|
||||||
@@ -73,10 +90,6 @@ class SubscriptionNewUserForm(SubscriptionForm):
|
|||||||
email = __user_fields["email"]
|
email = __user_fields["email"]
|
||||||
date_of_birth = __user_fields["date_of_birth"]
|
date_of_birth = __user_fields["date_of_birth"]
|
||||||
|
|
||||||
class Meta:
|
|
||||||
model = Subscription
|
|
||||||
fields = ["subscription_type", "payment_method", "location"]
|
|
||||||
|
|
||||||
field_order = [
|
field_order = [
|
||||||
"first_name",
|
"first_name",
|
||||||
"last_name",
|
"last_name",
|
||||||
@@ -130,7 +143,7 @@ class SubscriptionNewUserForm(SubscriptionForm):
|
|||||||
class SubscriptionExistingUserForm(SubscriptionForm):
|
class SubscriptionExistingUserForm(SubscriptionForm):
|
||||||
"""Form to add a subscription to an existing user."""
|
"""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"
|
required_css_class = "required"
|
||||||
|
|
||||||
birthdate = forms.fields_for_model(
|
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.")},
|
help_texts={"date_of_birth": _("This user didn't fill its birthdate yet.")},
|
||||||
)["date_of_birth"]
|
)["date_of_birth"]
|
||||||
|
|
||||||
class Meta:
|
class Meta(SubscriptionForm.Meta):
|
||||||
model = Subscription
|
fields = ["member", *SubscriptionForm.Meta.fields]
|
||||||
fields = ["member", "subscription_type", "payment_method", "location"]
|
widgets = SubscriptionForm.Meta.widgets | {"member": AutoCompleteSelectUser}
|
||||||
widgets = {"member": AutoCompleteSelectUser}
|
|
||||||
|
|
||||||
field_order = [
|
field_order = [
|
||||||
"member",
|
"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(
|
s = Subscription(
|
||||||
member=self.user,
|
member=self.user,
|
||||||
subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[3],
|
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_start = date(2017, 8, 29)
|
||||||
s.subscription_end = s.compute_end(duration=0.166, start=s.subscription_start)
|
s.subscription_end = s.compute_end(duration=0.166, start=s.subscription_start)
|
||||||
@@ -101,7 +101,7 @@ class TestSubscriptionIntegration(TestCase):
|
|||||||
s = Subscription(
|
s = Subscription(
|
||||||
member=self.user,
|
member=self.user,
|
||||||
subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[3],
|
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_start = date(2017, 8, 29)
|
||||||
s.subscription_end = s.compute_end(duration=0.333, start=s.subscription_start)
|
s.subscription_end = s.compute_end(duration=0.333, start=s.subscription_start)
|
||||||
@@ -112,7 +112,7 @@ class TestSubscriptionIntegration(TestCase):
|
|||||||
s = Subscription(
|
s = Subscription(
|
||||||
member=self.user,
|
member=self.user,
|
||||||
subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[3],
|
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_start = date(2017, 8, 29)
|
||||||
s.subscription_end = s.compute_end(
|
s.subscription_end = s.compute_end(
|
||||||
@@ -126,7 +126,7 @@ class TestSubscriptionIntegration(TestCase):
|
|||||||
s = Subscription(
|
s = Subscription(
|
||||||
member=self.user,
|
member=self.user,
|
||||||
subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[3],
|
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_start = date(2017, 8, 29)
|
||||||
s.subscription_end = s.compute_end(duration=0.5, start=s.subscription_start)
|
s.subscription_end = s.compute_end(duration=0.5, start=s.subscription_start)
|
||||||
@@ -137,7 +137,7 @@ class TestSubscriptionIntegration(TestCase):
|
|||||||
s = Subscription(
|
s = Subscription(
|
||||||
member=self.user,
|
member=self.user,
|
||||||
subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[3],
|
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_start = date(2017, 8, 29)
|
||||||
s.subscription_end = s.compute_end(duration=0.67, start=s.subscription_start)
|
s.subscription_end = s.compute_end(duration=0.67, start=s.subscription_start)
|
||||||
@@ -148,7 +148,7 @@ class TestSubscriptionIntegration(TestCase):
|
|||||||
s = Subscription(
|
s = Subscription(
|
||||||
member=self.user,
|
member=self.user,
|
||||||
subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[3],
|
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_start = date(2018, 9, 1)
|
||||||
s.subscription_end = s.compute_end(duration=0.23, start=s.subscription_start)
|
s.subscription_end = s.compute_end(duration=0.23, start=s.subscription_start)
|
||||||
@@ -160,7 +160,7 @@ class TestSubscriptionIntegration(TestCase):
|
|||||||
s = Subscription(
|
s = Subscription(
|
||||||
member=user,
|
member=user,
|
||||||
subscription_type="deux-semestres",
|
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_start = date(2015, 8, 29)
|
||||||
s.subscription_end = s.compute_end(
|
s.subscription_end = s.compute_end(
|
||||||
@@ -181,7 +181,7 @@ class TestSubscriptionIntegration(TestCase):
|
|||||||
s = Subscription(
|
s = Subscription(
|
||||||
member=user,
|
member=user,
|
||||||
subscription_type="deux-mois-essai",
|
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_start = date(2015, 8, 29)
|
||||||
s.subscription_end = s.compute_end(
|
s.subscription_end = s.compute_end(
|
||||||
@@ -202,7 +202,7 @@ class TestSubscriptionIntegration(TestCase):
|
|||||||
s = Subscription(
|
s = Subscription(
|
||||||
member=user,
|
member=user,
|
||||||
subscription_type="deux-mois-essai",
|
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_start = date(2015, 8, 29)
|
||||||
s.subscription_end = s.compute_end(
|
s.subscription_end = s.compute_end(
|
||||||
|
@@ -38,7 +38,7 @@ def test_form_existing_user_valid(
|
|||||||
"birthdate": user.date_of_birth,
|
"birthdate": user.date_of_birth,
|
||||||
"subscription_type": "deux-semestres",
|
"subscription_type": "deux-semestres",
|
||||||
"location": settings.SITH_SUBSCRIPTION_LOCATIONS[0][0],
|
"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)
|
form = SubscriptionExistingUserForm(data)
|
||||||
assert form.is_valid()
|
assert form.is_valid()
|
||||||
@@ -55,7 +55,7 @@ def test_form_existing_user_with_birthdate(settings: SettingsWrapper):
|
|||||||
"member": user,
|
"member": user,
|
||||||
"subscription_type": "deux-semestres",
|
"subscription_type": "deux-semestres",
|
||||||
"location": settings.SITH_SUBSCRIPTION_LOCATIONS[0][0],
|
"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)
|
form = SubscriptionExistingUserForm(data)
|
||||||
assert not form.is_valid()
|
assert not form.is_valid()
|
||||||
@@ -81,7 +81,7 @@ def test_form_existing_user_invalid(settings: SettingsWrapper):
|
|||||||
"member": user,
|
"member": user,
|
||||||
"subscription_type": "deux-semestres",
|
"subscription_type": "deux-semestres",
|
||||||
"location": settings.SITH_SUBSCRIPTION_LOCATIONS[0][0],
|
"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)
|
form = SubscriptionExistingUserForm(data)
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ def test_form_new_user(settings: SettingsWrapper):
|
|||||||
"date_of_birth": localdate() - relativedelta(years=18),
|
"date_of_birth": localdate() - relativedelta(years=18),
|
||||||
"subscription_type": "deux-semestres",
|
"subscription_type": "deux-semestres",
|
||||||
"location": settings.SITH_SUBSCRIPTION_LOCATIONS[0][0],
|
"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)
|
form = SubscriptionNewUserForm(data)
|
||||||
assert form.is_valid()
|
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),
|
"date_of_birth": localdate() - relativedelta(years=18),
|
||||||
"subscription_type": subscription_type,
|
"subscription_type": subscription_type,
|
||||||
"location": settings.SITH_SUBSCRIPTION_LOCATIONS[0][0],
|
"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)
|
form = SubscriptionNewUserForm(data)
|
||||||
assert form.is_valid()
|
assert form.is_valid()
|
||||||
@@ -180,7 +180,7 @@ def test_submit_form_existing_user(client: Client, settings: SettingsWrapper):
|
|||||||
"birthdate": user.date_of_birth,
|
"birthdate": user.date_of_birth,
|
||||||
"subscription_type": "deux-semestres",
|
"subscription_type": "deux-semestres",
|
||||||
"location": settings.SITH_SUBSCRIPTION_LOCATIONS[0][0],
|
"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()
|
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),
|
"date_of_birth": localdate() - relativedelta(years=18),
|
||||||
"subscription_type": "deux-semestres",
|
"subscription_type": "deux-semestres",
|
||||||
"location": settings.SITH_SUBSCRIPTION_LOCATIONS[0][0],
|
"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")
|
user = User.objects.get(email="jdoe@utbm.fr")
|
||||||
|
Reference in New Issue
Block a user