From 364025b195e6e836dd63da5d67cb7ea1a349b531 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Mon, 18 Jan 2021 16:35:37 +0100 Subject: [PATCH] Add Payment model --- apps/registration/migrations/0002_payment.py | 26 +++++++++++ apps/registration/models.py | 49 ++++++++++++++++++++ locale/fr/LC_MESSAGES/django.po | 42 +++++++++++++++-- 3 files changed, 114 insertions(+), 3 deletions(-) create mode 100644 apps/registration/migrations/0002_payment.py diff --git a/apps/registration/migrations/0002_payment.py b/apps/registration/migrations/0002_payment.py new file mode 100644 index 0000000..71c8fcf --- /dev/null +++ b/apps/registration/migrations/0002_payment.py @@ -0,0 +1,26 @@ +# Generated by Django 3.0.11 on 2021-01-18 15:35 + +from django.db import migrations, models +import django.db.models.deletion +import registration.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('registration', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='Payment', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('type', models.CharField(blank=True, choices=[('', 'No payment'), ('helloasso', 'Hello Asso'), ('scholarship', 'Scholarship'), ('bank_transfer', 'Bank transfer'), ('free', 'The tournament is free')], default='', max_length=16, verbose_name='type')), + ('scholarship_file', models.FileField(blank=True, default='', help_text='only if you have a scholarship.', unique=True, upload_to=registration.models.get_scholarship_filename, verbose_name='scholarship file')), + ('additional_information', models.TextField(blank=True, default='', help_text='To help us to find your payment.', verbose_name='additional information')), + ('valid', models.BooleanField(default=False, null=True, verbose_name='valid')), + ('registration', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='registration', to='registration.ParticipantRegistration', verbose_name='registration')), + ], + ), + ] diff --git a/apps/registration/models.py b/apps/registration/models.py index a870df4..afa69d7 100644 --- a/apps/registration/models.py +++ b/apps/registration/models.py @@ -288,3 +288,52 @@ class AdminRegistration(VolunteerRegistration): class Meta: verbose_name = _("admin registration") verbose_name_plural = _("admin registrations") + + +def get_scholarship_filename(instance, filename): + return f"authorization/scholarship/scholarship_{instance.registration.pk}" + + +class Payment(models.Model): + registration = models.OneToOneField( + ParticipantRegistration, + on_delete=models.CASCADE, + related_name="registration", + verbose_name=_("registration"), + ) + + type = models.CharField( + verbose_name=_("type"), + max_length=16, + choices=[ + ('', _("No payment")), + ('helloasso', "Hello Asso"), + ('scholarship', _("Scholarship")), + ('bank_transfer', _("Bank transfer")), + ('free', _("The tournament is free")), + ], + blank=True, + default="", + ) + + scholarship_file = models.FileField( + verbose_name=_("scholarship file"), + help_text=_("only if you have a scholarship."), + upload_to=get_scholarship_filename, + unique=True, + blank=True, + default="", + ) + + additional_information = models.TextField( + verbose_name=_("additional information"), + help_text=_("To help us to find your payment."), + blank=True, + default="", + ) + + valid = models.BooleanField( + verbose_name=_("valid"), + null=True, + default=False, + ) diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 2a52234..54309e8 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: TFJM\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-01-18 16:13+0100\n" +"POT-Creation-Date: 2021-01-18 16:33+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Yohann D'ANELLO \n" "Language-Team: LANGUAGE \n" @@ -100,7 +100,7 @@ msgid "Changelog of type \"{action}\" for model {model} at {timestamp}" msgstr "Changelog de type \"{action}\" pour le modèle {model} le {timestamp}" #: apps/participation/admin.py:19 apps/participation/models.py:297 -#: apps/participation/tables.py:44 +#: apps/participation/tables.py:44 apps/registration/models.py:336 msgid "valid" msgstr "valide" @@ -1017,7 +1017,7 @@ msgstr "email confirmé" msgid "Activate your TFJM² account" msgstr "Activez votre compte du TFJM²" -#: apps/registration/models.py:99 +#: apps/registration/models.py:99 apps/registration/models.py:302 msgid "registration" msgstr "inscription" @@ -1117,6 +1117,42 @@ msgstr "inscription d'administrateur" msgid "admin registrations" msgstr "inscriptions d'administrateur" +#: apps/registration/models.py:306 +msgid "type" +msgstr "type" + +#: apps/registration/models.py:309 +msgid "No payment" +msgstr "Pas de paiement" + +#: apps/registration/models.py:311 +msgid "Scholarship" +msgstr "Notification de bourse" + +#: apps/registration/models.py:312 +msgid "Bank transfer" +msgstr "Virement bancaire" + +#: apps/registration/models.py:313 +msgid "The tournament is free" +msgstr "Le tournoi est gratuit" + +#: apps/registration/models.py:320 +msgid "scholarship file" +msgstr "Notification de bourse" + +#: apps/registration/models.py:321 +msgid "only if you have a scholarship." +msgstr "Nécessaire seulement si vous déclarez être boursier." + +#: apps/registration/models.py:329 +msgid "additional information" +msgstr "informations additionnelles" + +#: apps/registration/models.py:330 +msgid "To help us to find your payment." +msgstr "Pour nous aider à retrouver votre paiement, si nécessaire." + #: apps/registration/tables.py:17 msgid "last name" msgstr "nom de famille"