Merge branch 'och' into 'master'

Edited subscriptions

See merge request ae/Sith!275
This commit is contained in:
Antoine Bartuccio 2020-09-01 00:21:48 +02:00
commit 48ae1f7c1c
4 changed files with 109 additions and 46 deletions

View File

@ -21,7 +21,7 @@ msgstr ""
#: com/models.py:294 counter/models.py:121 counter/models.py:149 #: com/models.py:294 counter/models.py:121 counter/models.py:149
#: counter/models.py:213 forum/models.py:58 launderette/models.py:38 #: counter/models.py:213 forum/models.py:58 launderette/models.py:38
#: launderette/models.py:93 launderette/models.py:131 stock/models.py:40 #: launderette/models.py:93 launderette/models.py:131 stock/models.py:40
#: stock/models.py:63 stock/models.py:105 stock/models.py:134 #: stock/models.py:63 stock/models.py:105 stock/models.py:133
msgid "name" msgid "name"
msgstr "nom" msgstr "nom"
@ -1169,7 +1169,7 @@ msgid "There are no members in this club."
msgstr "Il n'y a pas de membres dans ce club." msgstr "Il n'y a pas de membres dans ce club."
#: club/templates/club/club_members.jinja:78 #: club/templates/club/club_members.jinja:78
#: core/templates/core/file_detail.jinja:19 core/views/forms.py:337 #: core/templates/core/file_detail.jinja:19 core/views/forms.py:331
#: launderette/views.py:226 trombi/templates/trombi/detail.jinja:19 #: launderette/views.py:226 trombi/templates/trombi/detail.jinja:19
msgid "Add" msgid "Add"
msgstr "Ajouter" msgstr "Ajouter"
@ -1378,7 +1378,7 @@ msgid "History"
msgstr "Historique" msgstr "Historique"
#: club/views.py:125 core/templates/core/base.jinja:118 core/views/user.py:219 #: club/views.py:125 core/templates/core/base.jinja:118 core/views/user.py:219
#: sas/templates/sas/picture.jinja:95 trombi/views.py:61 #: sas/templates/sas/picture.jinja:95 trombi/views.py:63
msgid "Tools" msgid "Tools"
msgstr "Outils" msgstr "Outils"
@ -1444,7 +1444,7 @@ msgstr "contenu"
#: com/models.py:72 core/models.py:1432 launderette/models.py:101 #: com/models.py:72 core/models.py:1432 launderette/models.py:101
#: launderette/models.py:139 launderette/models.py:196 stock/models.py:80 #: launderette/models.py:139 launderette/models.py:196 stock/models.py:80
#: stock/models.py:138 #: stock/models.py:137
msgid "type" msgid "type"
msgstr "type" msgstr "type"
@ -3543,7 +3543,7 @@ msgstr "Ajouter un nouveau dossier"
msgid "Error creating folder %(folder_name)s: %(msg)s" msgid "Error creating folder %(folder_name)s: %(msg)s"
msgstr "Erreur de création du dossier %(folder_name)s : %(msg)s" msgstr "Erreur de création du dossier %(folder_name)s : %(msg)s"
#: core/views/files.py:121 core/views/forms.py:305 core/views/forms.py:312 #: core/views/files.py:121 core/views/forms.py:299 core/views/forms.py:306
#: sas/views.py:94 #: sas/views.py:94
#, python-format #, python-format
msgid "Error uploading file %(file_name)s: %(msg)s" msgid "Error uploading file %(file_name)s: %(msg)s"
@ -3625,19 +3625,19 @@ msgstr "Activer le plein écran"
msgid "Markdown guide" msgid "Markdown guide"
msgstr "Guide markdown" msgstr "Guide markdown"
#: core/views/forms.py:121 core/views/forms.py:129 #: core/views/forms.py:119 core/views/forms.py:126
msgid "Choose file" msgid "Choose file"
msgstr "Choisir un fichier" msgstr "Choisir un fichier"
#: core/views/forms.py:145 core/views/forms.py:153 #: core/views/forms.py:140 core/views/forms.py:147
msgid "Choose user" msgid "Choose user"
msgstr "Choisir un utilisateur" msgstr "Choisir un utilisateur"
#: core/views/forms.py:185 #: core/views/forms.py:179
msgid "Username, email, or account number" msgid "Username, email, or account number"
msgstr "Nom d'utilisateur, email, ou numéro de compte AE" msgstr "Nom d'utilisateur, email, ou numéro de compte AE"
#: core/views/forms.py:251 #: core/views/forms.py:245
msgid "" msgid ""
"Profile: you need to be visible on the picture, in order to be recognized (e." "Profile: you need to be visible on the picture, in order to be recognized (e."
"g. by the barmen)" "g. by the barmen)"
@ -3645,36 +3645,36 @@ msgstr ""
"Photo de profil: vous devez être visible sur la photo afin d'être reconnu " "Photo de profil: vous devez être visible sur la photo afin d'être reconnu "
"(par exemple par les barmen)" "(par exemple par les barmen)"
#: core/views/forms.py:253 #: core/views/forms.py:247
msgid "Avatar: used on the forum" msgid "Avatar: used on the forum"
msgstr "Avatar : utilisé sur le forum" msgstr "Avatar : utilisé sur le forum"
#: core/views/forms.py:254 #: core/views/forms.py:248
msgid "Scrub: let other know how your scrub looks like!" msgid "Scrub: let other know how your scrub looks like!"
msgstr "Blouse : montrez aux autres à quoi ressemble votre blouse !" msgstr "Blouse : montrez aux autres à quoi ressemble votre blouse !"
#: core/views/forms.py:316 #: core/views/forms.py:310
msgid "Bad image format, only jpeg, png, and gif are accepted" msgid "Bad image format, only jpeg, png, and gif are accepted"
msgstr "Mauvais format d'image, seuls les jpeg, png, et gif sont acceptés" msgstr "Mauvais format d'image, seuls les jpeg, png, et gif sont acceptés"
#: core/views/forms.py:336 #: core/views/forms.py:330
msgid "Godfather" msgid "Godfather"
msgstr "Parrain" msgstr "Parrain"
#: core/views/forms.py:336 #: core/views/forms.py:330
msgid "Godchild" msgid "Godchild"
msgstr "Fillot" msgstr "Fillot"
#: core/views/forms.py:340 counter/views.py:154 trombi/views.py:158 #: core/views/forms.py:334 counter/views.py:154 trombi/views.py:158
msgid "Select user" msgid "Select user"
msgstr "Choisir un utilisateur" msgstr "Choisir un utilisateur"
#: core/views/forms.py:353 core/views/forms.py:371 election/models.py:24 #: core/views/forms.py:347 core/views/forms.py:365 election/models.py:24
#: election/views.py:154 #: election/views.py:154
msgid "edit groups" msgid "edit groups"
msgstr "groupe d'édition" msgstr "groupe d'édition"
#: core/views/forms.py:356 core/views/forms.py:374 election/models.py:31 #: core/views/forms.py:350 core/views/forms.py:368 election/models.py:31
#: election/views.py:157 #: election/views.py:157
msgid "view groups" msgid "view groups"
msgstr "groupe de vue" msgstr "groupe de vue"
@ -4760,7 +4760,7 @@ msgid "Washing"
msgstr "Lavage" msgstr "Lavage"
#: launderette/templates/launderette/launderette_book.jinja:31 #: launderette/templates/launderette/launderette_book.jinja:31
#: sith/settings.py:593 #: sith/settings.py:594
msgid "Drying" msgid "Drying"
msgstr "Séchage" msgstr "Séchage"
@ -5432,19 +5432,19 @@ msgstr "Suppression de rechargement"
#: sith/settings.py:480 #: sith/settings.py:480
msgid "One semester" msgid "One semester"
msgstr "Un semestre, 15" msgstr "Un semestre, 20"
#: sith/settings.py:481 #: sith/settings.py:481
msgid "Two semesters" msgid "Two semesters"
msgstr "Deux semestres, 28" msgstr "Deux semestres, 35"
#: sith/settings.py:483 #: sith/settings.py:483
msgid "Common core cursus" msgid "Common core cursus"
msgstr "Cursus tronc commun, 45" msgstr "Cursus tronc commun, 60"
#: sith/settings.py:487 #: sith/settings.py:487
msgid "Branch cursus" msgid "Branch cursus"
msgstr "Cursus branche, 45" msgstr "Cursus branche, 60"
#: sith/settings.py:488 #: sith/settings.py:488
msgid "Alternating cursus" msgid "Alternating cursus"
@ -5472,25 +5472,29 @@ msgstr "Membres du CROUS, 0 €"
#: sith/settings.py:494 #: sith/settings.py:494
msgid "Sbarro/ESTA member" msgid "Sbarro/ESTA member"
msgstr "Membre de Sbarro ou de l'ESTA, 15" msgstr "Membre de Sbarro ou de l'ESTA, 20"
#: sith/settings.py:496 #: sith/settings.py:496
msgid "One semester Welcome Week" msgid "One semester Welcome Week"
msgstr "Un semestre Welcome Week" msgstr "Un semestre Welcome Week"
#: sith/settings.py:500 #: sith/settings.py:500
msgid "One month for free"
msgstr "Un mois gratuit"
#: sith/settings.py:501
msgid "Two months for free" msgid "Two months for free"
msgstr "Deux mois gratuits" msgstr "Deux mois gratuits"
#: sith/settings.py:501 #: sith/settings.py:502
msgid "Eurok's volunteer" msgid "Eurock's volunteer"
msgstr "Bénévole Eurockéennes" msgstr "Bénévole Eurockéennes"
#: sith/settings.py:503 #: sith/settings.py:504
msgid "Six weeks for free" msgid "Six weeks for free"
msgstr "6 semaines gratuites" msgstr "6 semaines gratuites"
#: sith/settings.py:507 #: sith/settings.py:508
msgid "One day" msgid "One day"
msgstr "Un jour" msgstr "Un jour"
@ -5562,40 +5566,40 @@ msgstr "Une nouvelle affiche a besoin d'être modérée"
msgid "A new mailing list needs to be moderated" msgid "A new mailing list needs to be moderated"
msgstr "Une nouvelle mailing list a besoin d'être modérée" msgstr "Une nouvelle mailing list a besoin d'être modérée"
#: sith/settings.py:601 #: sith/settings.py:602
msgid "A new pedagogy comment has been signaled for moderation" msgid "A new pedagogy comment has been signaled for moderation"
msgstr "" msgstr ""
"Un nouveau commentaire de la pédagogie a été signalé pour la modération" "Un nouveau commentaire de la pédagogie a été signalé pour la modération"
#: sith/settings.py:603 #: sith/settings.py:604
#, python-format #, python-format
msgid "There are %s fresh news to be moderated" msgid "There are %s fresh news to be moderated"
msgstr "Il y a %s nouvelles toutes fraîches à modérer" msgstr "Il y a %s nouvelles toutes fraîches à modérer"
#: sith/settings.py:604 #: sith/settings.py:605
msgid "New files to be moderated" msgid "New files to be moderated"
msgstr "Nouveaux fichiers à modérer" msgstr "Nouveaux fichiers à modérer"
#: sith/settings.py:605 #: sith/settings.py:606
#, python-format #, python-format
msgid "There are %s pictures to be moderated in the SAS" msgid "There are %s pictures to be moderated in the SAS"
msgstr "Il y a %s photos à modérer dans le SAS" msgstr "Il y a %s photos à modérer dans le SAS"
#: sith/settings.py:606 #: sith/settings.py:607
msgid "You've been identified on some pictures" msgid "You've been identified on some pictures"
msgstr "Vous avez été identifié sur des photos" msgstr "Vous avez été identifié sur des photos"
#: sith/settings.py:607 #: sith/settings.py:608
#, python-format #, python-format
msgid "You just refilled of %s" msgid "You just refilled of %s"
msgstr "Vous avez rechargé votre compte de %s" msgstr "Vous avez rechargé votre compte de %s"
#: sith/settings.py:608 #: sith/settings.py:609
#, python-format #, python-format
msgid "You just bought %s" msgid "You just bought %s"
msgstr "Vous avez acheté %s" msgstr "Vous avez acheté %s"
#: sith/settings.py:609 #: sith/settings.py:610
msgid "You have a notification" msgid "You have a notification"
msgstr "Vous avez une notification" msgstr "Vous avez une notification"
@ -5655,23 +5659,23 @@ msgstr ""
msgid "todo" msgid "todo"
msgstr "à faire" msgstr "à faire"
#: stock/models.py:128 #: stock/models.py:127
msgid "shopping lists" msgid "shopping lists"
msgstr "listes de courses" msgstr "listes de courses"
#: stock/models.py:144 #: stock/models.py:143
msgid "quantity to buy" msgid "quantity to buy"
msgstr "quantité à acheter" msgstr "quantité à acheter"
#: stock/models.py:146 #: stock/models.py:145
msgid "quantity to buy during the next shopping session" msgid "quantity to buy during the next shopping session"
msgstr "quantité à acheter pendant les prochaines courses" msgstr "quantité à acheter pendant les prochaines courses"
#: stock/models.py:149 #: stock/models.py:148
msgid "quantity bought" msgid "quantity bought"
msgstr "quantité achetée" msgstr "quantité achetée"
#: stock/models.py:151 #: stock/models.py:150
msgid "quantity bought during the last shopping session" msgid "quantity bought during the last shopping session"
msgstr "quantité achetée pendant les dernières courses" msgstr "quantité achetée pendant les dernières courses"

View File

@ -477,14 +477,14 @@ SITH_SUBSCRIPTION_END = 10
# Subscription durations are in semestres # Subscription durations are in semestres
# Be careful, modifying this parameter will need a migration to be applied # Be careful, modifying this parameter will need a migration to be applied
SITH_SUBSCRIPTIONS = { SITH_SUBSCRIPTIONS = {
"un-semestre": {"name": _("One semester"), "price": 15, "duration": 1}, "un-semestre": {"name": _("One semester"), "price": 20, "duration": 1},
"deux-semestres": {"name": _("Two semesters"), "price": 28, "duration": 2}, "deux-semestres": {"name": _("Two semesters"), "price": 35, "duration": 2},
"cursus-tronc-commun": { "cursus-tronc-commun": {
"name": _("Common core cursus"), "name": _("Common core cursus"),
"price": 45, "price": 60,
"duration": 4, "duration": 4,
}, },
"cursus-branche": {"name": _("Branch cursus"), "price": 45, "duration": 6}, "cursus-branche": {"name": _("Branch cursus"), "price": 60, "duration": 6},
"cursus-alternant": {"name": _("Alternating cursus"), "price": 30, "duration": 6}, "cursus-alternant": {"name": _("Alternating cursus"), "price": 30, "duration": 6},
"membre-honoraire": {"name": _("Honorary member"), "price": 0, "duration": 666}, "membre-honoraire": {"name": _("Honorary member"), "price": 0, "duration": 666},
"assidu": {"name": _("Assidu member"), "price": 0, "duration": 2}, "assidu": {"name": _("Assidu member"), "price": 0, "duration": 2},
@ -497,6 +497,7 @@ SITH_SUBSCRIPTIONS = {
"price": 0, "price": 0,
"duration": 1, "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}, "deux-mois-essai": {"name": _("Two months for free"), "price": 0, "duration": 0.33},
"benevoles-euroks": {"name": _("Eurok's volunteer"), "price": 5, "duration": 0.1}, "benevoles-euroks": {"name": _("Eurok's volunteer"), "price": 5, "duration": 0.1},
"six-semaines-essai": { "six-semaines-essai": {

View File

@ -0,0 +1,46 @@
# Generated by Django 2.2.13 on 2020-08-28 19:17
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("subscription", "0012_auto_20200615_1438"),
]
operations = [
migrations.AlterField(
model_name="subscription",
name="subscription_type",
field=models.CharField(
choices=[
("amicale/doceo", "Amicale/DOCEO member"),
("assidu", "Assidu member"),
("benevoles-euroks", "Eurok's volunteer"),
("crous", "CROUS member"),
("cursus-alternant", "Alternating cursus"),
("cursus-alternant-reduction", "Alternating cursus (-20%)"),
("cursus-branche", "Branch cursus"),
("cursus-branche-reduction", "Branch cursus (-20%)"),
("cursus-tronc-commun", "Common core cursus"),
("cursus-tronc-commun-reduction", "Common core cursus (-20%)"),
("deux-mois-essai", "Two months for free"),
("deux-semestres", "Two semesters"),
("deux-semestres-reduction", "Two semesters (-20%)"),
("membre-honoraire", "Honorary member"),
("membre-staff-ga", "GA staff member"),
("reseau-ut", "UT network member"),
("sbarro/esta", "Sbarro/ESTA member"),
("six-semaines-essai", "Six weeks for free"),
("un-jour", "One day"),
("un-mois-essai", "One month for free"),
("un-semestre", "One semester"),
("un-semestre-reduction", "One semester (-20%)"),
("un-semestre-welcome", "One semester Welcome Week"),
],
max_length=255,
verbose_name="subscription type",
),
),
]

View File

@ -114,6 +114,18 @@ class SubscriptionIntegrationTest(TestCase):
call_command("populate") call_command("populate")
self.user = User.objects.filter(username="public").first() self.user = User.objects.filter(username="public").first()
def test_duration_one_month(self):
s = Subscription(
member=User.objects.filter(pk=self.user.pk).first(),
subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[3],
payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0],
)
s.subscription_start = date(2017, 8, 29)
s.subscription_end = s.compute_end(duration=0.166, start=s.subscription_start)
s.save()
self.assertTrue(s.subscription_end == date(2017, 9, 29))
def test_duration_two_months(self): def test_duration_two_months(self):
s = Subscription( s = Subscription(
@ -122,11 +134,11 @@ class SubscriptionIntegrationTest(TestCase):
payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0], payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0],
) )
s.subscription_start = date(2017, 8, 29) s.subscription_start = date(2017, 8, 29)
s.subscription_end = s.compute_end(duration=0.33, start=s.subscription_start) s.subscription_end = s.compute_end(duration=0.333, start=s.subscription_start)
s.save() s.save()
self.assertTrue(s.subscription_end == date(2017, 10, 29)) self.assertTrue(s.subscription_end == date(2017, 10, 29))
def test_duration_two_months(self): def test_duration_one_day(self):
s = Subscription( s = Subscription(
member=User.objects.filter(pk=self.user.pk).first(), member=User.objects.filter(pk=self.user.pk).first(),