From 23f46cc59839b3a23776c0d8fc20235b8a2dc11b Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 28 Sep 2021 16:57:23 +0200 Subject: [PATCH 01/10] Create transfers when pressing Enter in the amount part Signed-off-by: Yohann D'ANELLO --- apps/note/static/note/js/transfer.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/note/static/note/js/transfer.js b/apps/note/static/note/js/transfer.js index 0ae76501..6c5a0329 100644 --- a/apps/note/static/note/js/transfer.js +++ b/apps/note/static/note/js/transfer.js @@ -222,6 +222,13 @@ $(document).ready(function () { }) }) +// Make transfer when pressing Enter on the amount section +$('#amount, #reason, #last_name, #first_name, #bank').keypress((event) => { + if (event.originalEvent.charCode === 13) { + $('#btn_transfer').click() + } +}) + $('#btn_transfer').click(function () { if (LOCK) { return } From d4896bfd766ee521d8e6931385528c1b92f1fb1f Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 28 Sep 2021 17:03:32 +0200 Subject: [PATCH 02/10] Check that club's note is active before creating an activity Signed-off-by: Yohann D'ANELLO --- apps/activity/forms.py | 6 + apps/registration/forms.py | 4 +- locale/fr/LC_MESSAGES/django.po | 198 +++++++++++++++++--------------- 3 files changed, 111 insertions(+), 97 deletions(-) diff --git a/apps/activity/forms.py b/apps/activity/forms.py index b40463c0..1ca98cef 100644 --- a/apps/activity/forms.py +++ b/apps/activity/forms.py @@ -28,6 +28,12 @@ class ActivityForm(forms.ModelForm): shuffle(clubs) self.fields["organizer"].widget.attrs["placeholder"] = ", ".join(club.name for club in clubs[:4]) + ", ..." + def clean_organizer(self): + organizer = self.cleaned_data['organizer'] + if not organizer.note.is_active: + self.add_error('organiser', _('The note of this club is inactive.')) + return organizer + def clean_date_end(self): date_end = self.cleaned_data["date_end"] date_start = self.cleaned_data["date_start"] diff --git a/apps/registration/forms.py b/apps/registration/forms.py index 21e0da55..64e79d52 100644 --- a/apps/registration/forms.py +++ b/apps/registration/forms.py @@ -46,8 +46,8 @@ class SignUpForm(UserCreationForm): class DeclareSogeAccountOpenedForm(forms.Form): soge_account = forms.BooleanField( - label=_("I declare that I opened or I will open soon a bank account in the Société générale with the BDE \ - partnership."), + label=_("I declare that I opened or I will open soon a bank account in the Société générale with the BDE " + "partnership."), help_text=_("Warning: this engages you to open your bank account. If you finally decides to don't open your " "account, you will have to pay the BDE membership."), required=False, diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 9175e2e7..d7f05ff3 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-09-13 23:26+0200\n" +"POT-Creation-Date: 2021-09-28 17:02+0200\n" "PO-Revision-Date: 2020-11-16 20:02+0000\n" "Last-Translator: Yohann D'ANELLO \n" "Language-Team: French \n" @@ -23,28 +23,32 @@ msgstr "" msgid "activity" msgstr "activité" -#: apps/activity/forms.py:35 apps/activity/models.py:132 +#: apps/activity/forms.py:34 +msgid "The note of this club is inactive." +msgstr "La note du club est inactive." + +#: apps/activity/forms.py:41 apps/activity/models.py:132 msgid "The end date must be after the start date." msgstr "La date de fin doit être après celle de début." -#: apps/activity/forms.py:76 apps/activity/models.py:270 +#: apps/activity/forms.py:82 apps/activity/models.py:270 msgid "You can't invite someone once the activity is started." msgstr "" "Vous ne pouvez pas inviter quelqu'un une fois que l'activité a démarré." -#: apps/activity/forms.py:79 apps/activity/models.py:273 +#: apps/activity/forms.py:85 apps/activity/models.py:273 msgid "This activity is not validated yet." msgstr "Cette activité n'est pas encore validée." -#: apps/activity/forms.py:89 apps/activity/models.py:281 +#: apps/activity/forms.py:95 apps/activity/models.py:281 msgid "This person has been already invited 5 times this year." msgstr "Cette personne a déjà été invitée 5 fois cette année." -#: apps/activity/forms.py:93 apps/activity/models.py:285 +#: apps/activity/forms.py:99 apps/activity/models.py:285 msgid "This person is already invited." msgstr "Cette personne est déjà invitée." -#: apps/activity/forms.py:97 apps/activity/models.py:289 +#: apps/activity/forms.py:103 apps/activity/models.py:289 msgid "You can't invite more than 3 people to this activity." msgstr "Vous ne pouvez pas inviter plus de 3 personnes à cette activité." @@ -195,7 +199,7 @@ msgstr "Entrée de la note {note} pour l'activité « {activity} »" msgid "Already entered on " msgstr "Déjà rentré le " -#: apps/activity/models.py:202 apps/activity/tables.py:54 +#: apps/activity/models.py:202 apps/activity/tables.py:56 msgid "{:%Y-%m-%d %H:%M:%S}" msgstr "{:%d/%m/%Y %H:%M:%S}" @@ -234,48 +238,48 @@ msgstr "invités" msgid "Invitation" msgstr "Invitation" -#: apps/activity/tables.py:25 +#: apps/activity/tables.py:27 msgid "The activity is currently open." msgstr "Cette activité est actuellement ouverte." -#: apps/activity/tables.py:26 +#: apps/activity/tables.py:28 msgid "The validation of the activity is pending." msgstr "La validation de cette activité est en attente." -#: apps/activity/tables.py:41 apps/treasury/tables.py:107 +#: apps/activity/tables.py:43 apps/treasury/tables.py:107 msgid "Remove" msgstr "Supprimer" -#: apps/activity/tables.py:54 +#: apps/activity/tables.py:56 msgid "Entered on " msgstr "Entré le " -#: apps/activity/tables.py:56 +#: apps/activity/tables.py:58 msgid "remove" msgstr "supprimer" -#: apps/activity/tables.py:80 apps/note/forms.py:68 apps/treasury/models.py:199 +#: apps/activity/tables.py:82 apps/note/forms.py:68 apps/treasury/models.py:199 msgid "Type" msgstr "Type" -#: apps/activity/tables.py:82 apps/member/forms.py:186 -#: apps/registration/forms.py:90 apps/treasury/forms.py:131 +#: apps/activity/tables.py:84 apps/member/forms.py:186 +#: apps/registration/forms.py:91 apps/treasury/forms.py:131 #: apps/wei/forms/registration.py:104 msgid "Last name" msgstr "Nom de famille" -#: apps/activity/tables.py:84 apps/member/forms.py:191 -#: apps/note/templates/note/transaction_form.html:134 -#: apps/registration/forms.py:95 apps/treasury/forms.py:133 +#: apps/activity/tables.py:86 apps/member/forms.py:191 +#: apps/note/templates/note/transaction_form.html:138 +#: apps/registration/forms.py:96 apps/treasury/forms.py:133 #: apps/wei/forms/registration.py:109 msgid "First name" msgstr "Prénom" -#: apps/activity/tables.py:86 apps/note/models/notes.py:86 +#: apps/activity/tables.py:88 apps/note/models/notes.py:86 msgid "Note" msgstr "Note" -#: apps/activity/tables.py:88 apps/member/tables.py:49 +#: apps/activity/tables.py:90 apps/member/tables.py:49 msgid "Balance" msgstr "Solde du compte" @@ -289,26 +293,26 @@ msgstr "Invité supprimé" #: apps/activity/templates/activity/activity_entry.html:14 #: apps/note/models/transactions.py:257 -#: apps/note/templates/note/transaction_form.html:16 -#: apps/note/templates/note/transaction_form.html:148 +#: apps/note/templates/note/transaction_form.html:17 +#: apps/note/templates/note/transaction_form.html:152 #: note_kfet/templates/base.html:73 msgid "Transfer" msgstr "Virement" #: apps/activity/templates/activity/activity_entry.html:18 #: apps/note/models/transactions.py:317 -#: apps/note/templates/note/transaction_form.html:21 +#: apps/note/templates/note/transaction_form.html:22 msgid "Credit" msgstr "Crédit" #: apps/activity/templates/activity/activity_entry.html:21 #: apps/note/models/transactions.py:317 -#: apps/note/templates/note/transaction_form.html:25 +#: apps/note/templates/note/transaction_form.html:26 msgid "Debit" msgstr "Débit" #: apps/activity/templates/activity/activity_entry.html:27 -#: apps/note/templates/note/transaction_form.html:30 +#: apps/note/templates/note/transaction_form.html:34 msgid "Entries" msgstr "Entrées" @@ -548,20 +552,20 @@ msgstr "Cette image ne peut pas être chargée." msgid "An alias with a similar name already exists." msgstr "Un alias avec un nom similaire existe déjà." -#: apps/member/forms.py:165 apps/registration/forms.py:70 +#: apps/member/forms.py:165 apps/registration/forms.py:71 msgid "Inscription paid by Société Générale" msgstr "Inscription payée par la Société générale" -#: apps/member/forms.py:167 apps/registration/forms.py:72 +#: apps/member/forms.py:167 apps/registration/forms.py:73 msgid "Check this case if the Société Générale paid the inscription." msgstr "Cochez cette case si la Société Générale a payé l'inscription." -#: apps/member/forms.py:172 apps/registration/forms.py:77 +#: apps/member/forms.py:172 apps/registration/forms.py:78 #: apps/wei/forms/registration.py:91 msgid "Credit type" msgstr "Type de rechargement" -#: apps/member/forms.py:173 apps/registration/forms.py:78 +#: apps/member/forms.py:173 apps/registration/forms.py:79 #: apps/wei/forms/registration.py:92 msgid "No credit" msgstr "Pas de rechargement" @@ -570,13 +574,13 @@ msgstr "Pas de rechargement" msgid "You can credit the note of the user." msgstr "Vous pouvez créditer la note de l'utilisateur avant l'adhésion." -#: apps/member/forms.py:179 apps/registration/forms.py:83 +#: apps/member/forms.py:179 apps/registration/forms.py:84 #: apps/wei/forms/registration.py:97 msgid "Credit amount" msgstr "Montant à créditer" -#: apps/member/forms.py:196 apps/note/templates/note/transaction_form.html:140 -#: apps/registration/forms.py:100 apps/treasury/forms.py:135 +#: apps/member/forms.py:196 apps/note/templates/note/transaction_form.html:144 +#: apps/registration/forms.py:101 apps/treasury/forms.py:135 #: apps/wei/forms/registration.py:114 msgid "Bank" msgstr "Banque" @@ -1192,7 +1196,7 @@ msgstr "Modifier le club" msgid "Add new member to the club" msgstr "Ajouter un nouveau membre au club" -#: apps/member/views.py:642 apps/wei/views.py:956 +#: apps/member/views.py:642 apps/wei/views.py:973 msgid "" "This user don't have enough money to join this club, and can't have a " "negative balance." @@ -1247,7 +1251,7 @@ msgstr "Source" msgid "Destination" msgstr "Destination" -#: apps/note/forms.py:74 apps/note/templates/note/transaction_form.html:119 +#: apps/note/forms.py:74 apps/note/templates/note/transaction_form.html:123 msgid "Reason" msgstr "Raison" @@ -1498,8 +1502,8 @@ msgstr "" "mode de paiement et un utilisateur ou un club" #: apps/note/models/transactions.py:355 apps/note/models/transactions.py:358 -#: apps/note/models/transactions.py:361 apps/wei/views.py:961 -#: apps/wei/views.py:965 +#: apps/note/models/transactions.py:361 apps/wei/views.py:978 +#: apps/wei/views.py:982 msgid "This field is required." msgstr "Ce champ est requis." @@ -1553,7 +1557,7 @@ msgid "Edit" msgstr "Éditer" #: apps/note/templates/note/conso_form.html:22 -#: apps/note/templates/note/transaction_form.html:44 +#: apps/note/templates/note/transaction_form.html:48 msgid "Please select a note" msgstr "Sélectionnez une note" @@ -1562,8 +1566,8 @@ msgid "Consum" msgstr "Consommer" #: apps/note/templates/note/conso_form.html:43 -#: apps/note/templates/note/transaction_form.html:65 -#: apps/note/templates/note/transaction_form.html:92 +#: apps/note/templates/note/transaction_form.html:69 +#: apps/note/templates/note/transaction_form.html:96 msgid "Name or alias..." msgstr "Pseudo ou alias ..." @@ -1588,7 +1592,7 @@ msgid "Double consumptions" msgstr "Consommations doubles" #: apps/note/templates/note/conso_form.html:154 -#: apps/note/templates/note/transaction_form.html:159 +#: apps/note/templates/note/transaction_form.html:163 msgid "Recent transactions history" msgstr "Historique des transactions récentes" @@ -1603,45 +1607,45 @@ msgstr "Historique des transactions récentes" msgid "Mail generated by the Note Kfet on the" msgstr "Mail généré par la Note Kfet le" -#: apps/note/templates/note/transaction_form.html:54 -#: apps/note/templates/note/transaction_form.html:174 +#: apps/note/templates/note/transaction_form.html:58 +#: apps/note/templates/note/transaction_form.html:178 msgid "Select emitters" msgstr "Sélection des émetteurs" -#: apps/note/templates/note/transaction_form.html:69 +#: apps/note/templates/note/transaction_form.html:73 msgid "I am the emitter" msgstr "Je suis l'émetteur" -#: apps/note/templates/note/transaction_form.html:81 -#: apps/note/templates/note/transaction_form.html:176 +#: apps/note/templates/note/transaction_form.html:85 +#: apps/note/templates/note/transaction_form.html:180 msgid "Select receivers" msgstr "Sélection des destinataires" -#: apps/note/templates/note/transaction_form.html:104 +#: apps/note/templates/note/transaction_form.html:108 msgid "Action" msgstr "Action" -#: apps/note/templates/note/transaction_form.html:112 +#: apps/note/templates/note/transaction_form.html:116 #: apps/treasury/forms.py:137 apps/treasury/tables.py:67 #: apps/treasury/tables.py:132 #: apps/treasury/templates/treasury/remittance_form.html:23 msgid "Amount" msgstr "Montant" -#: apps/note/templates/note/transaction_form.html:128 +#: apps/note/templates/note/transaction_form.html:132 #: apps/treasury/models.py:54 msgid "Name" msgstr "Nom" -#: apps/note/templates/note/transaction_form.html:173 +#: apps/note/templates/note/transaction_form.html:177 msgid "Select emitter" msgstr "Sélection de l'émetteur" -#: apps/note/templates/note/transaction_form.html:175 +#: apps/note/templates/note/transaction_form.html:179 msgid "Select receiver" msgstr "Sélection du destinataire" -#: apps/note/templates/note/transaction_form.html:177 +#: apps/note/templates/note/transaction_form.html:181 msgid "Transfer type" msgstr "Type de transfert" @@ -1913,13 +1917,13 @@ msgstr "Cet email est déjà pris." #: apps/registration/forms.py:49 msgid "" -"I declare that I opened or I will open soon a bank account in the Société générale with the BDE " -"partnership." +"I declare that I opened or I will open soon a bank account in the Société " +"générale with the BDE partnership." msgstr "" -"Je déclare avoir ouvert ou ouvrir prochainement un compte à la société générale avec le partenariat " -"du BDE." +"Je déclare avoir ouvert ou ouvrir prochainement un compte à la société " +"générale avec le partenariat du BDE." -#: apps/registration/forms.py:50 +#: apps/registration/forms.py:51 msgid "" "Warning: this engages you to open your bank account. If you finally decides " "to don't open your account, you will have to pay the BDE membership." @@ -1927,11 +1931,11 @@ msgstr "" "Attention : cocher cette case vous engage à ouvrir votre compte. Si vous " "décidez de ne pas le faire, vous devrez payer l'adhésion au BDE." -#: apps/registration/forms.py:58 +#: apps/registration/forms.py:59 msgid "Register to the WEI" msgstr "S'inscrire au WEI" -#: apps/registration/forms.py:60 +#: apps/registration/forms.py:61 msgid "" "Check this case if you want to register to the WEI. If you hesitate, you " "will be able to register later, after validating your account in the Kfet." @@ -1940,11 +1944,11 @@ msgstr "" "pourrez toujours vous inscrire plus tard, après avoir validé votre compte à " "la Kfet." -#: apps/registration/forms.py:105 +#: apps/registration/forms.py:106 msgid "Join BDE Club" msgstr "Adhérer au club BDE" -#: apps/registration/forms.py:112 +#: apps/registration/forms.py:113 msgid "Join Kfet Club" msgstr "Adhérer au club Kfet" @@ -2244,7 +2248,7 @@ msgstr "proxys de transactions spéciales" msgid "credit transaction" msgstr "transaction de crédit" -#: apps/treasury/models.py:419 +#: apps/treasury/models.py:430 msgid "" "This user doesn't have enough money to pay the memberships with its note. " "Please ask her/him to credit the note before invalidating this credit." @@ -2252,16 +2256,16 @@ msgstr "" "Cet utilisateur n'a pas assez d'argent pour payer les adhésions avec sa " "note. Merci de lui demander de recharger sa note avant d'invalider ce crédit." -#: apps/treasury/models.py:439 +#: apps/treasury/models.py:451 #: apps/treasury/templates/treasury/sogecredit_detail.html:10 msgid "Credit from the Société générale" msgstr "Crédit de la Société générale" -#: apps/treasury/models.py:440 +#: apps/treasury/models.py:452 msgid "Credits from the Société générale" msgstr "Crédits de la Société générale" -#: apps/treasury/models.py:443 +#: apps/treasury/models.py:455 #, python-brace-format msgid "Soge credit for {user}" msgstr "Crédit de la société générale pour l'utilisateur {user}" @@ -2559,7 +2563,7 @@ msgstr "Sélectionnez les rôles qui vous intéressent." msgid "This team doesn't belong to the given bus." msgstr "Cette équipe n'appartient pas à ce bus." -#: apps/wei/forms/surveys/wei2021.py:31 +#: apps/wei/forms/surveys/wei2021.py:35 msgid "Choose a word:" msgstr "Choisissez un mot :" @@ -2804,11 +2808,11 @@ msgstr "Prix du WEI (étudiants)" msgid "WEI list" msgstr "Liste des WEI" -#: apps/wei/templates/wei/base.html:81 apps/wei/views.py:523 +#: apps/wei/templates/wei/base.html:81 apps/wei/views.py:528 msgid "Register 1A" msgstr "Inscrire un 1A" -#: apps/wei/templates/wei/base.html:85 apps/wei/views.py:603 +#: apps/wei/templates/wei/base.html:85 apps/wei/views.py:614 msgid "Register 2A+" msgstr "Inscrire un 2A+" @@ -2837,8 +2841,8 @@ msgstr "Télécharger au format PDF" #: apps/wei/templates/wei/survey.html:11 #: apps/wei/templates/wei/survey_closed.html:11 -#: apps/wei/templates/wei/survey_end.html:11 apps/wei/views.py:1011 -#: apps/wei/views.py:1066 apps/wei/views.py:1076 +#: apps/wei/templates/wei/survey_end.html:11 apps/wei/views.py:1028 +#: apps/wei/views.py:1083 apps/wei/views.py:1093 msgid "Survey WEI" msgstr "Questionnaire WEI" @@ -2883,7 +2887,7 @@ msgstr "Inscriptions non validées" msgid "Attribute buses" msgstr "Répartition dans les bus" -#: apps/wei/templates/wei/weiclub_list.html:14 apps/wei/views.py:78 +#: apps/wei/templates/wei/weiclub_list.html:14 apps/wei/views.py:79 msgid "Create WEI" msgstr "Créer un WEI" @@ -3020,67 +3024,67 @@ msgstr "Il n'y a pas de pré-inscription en attente avec cette entrée." msgid "View validated memberships..." msgstr "Voir les adhésions validées ..." -#: apps/wei/views.py:57 +#: apps/wei/views.py:58 msgid "Search WEI" msgstr "Chercher un WEI" -#: apps/wei/views.py:108 +#: apps/wei/views.py:109 msgid "WEI Detail" msgstr "Détails du WEI" -#: apps/wei/views.py:203 +#: apps/wei/views.py:208 msgid "View members of the WEI" msgstr "Voir les membres du WEI" -#: apps/wei/views.py:231 +#: apps/wei/views.py:236 msgid "Find WEI Membership" msgstr "Trouver une adhésion au WEI" -#: apps/wei/views.py:241 +#: apps/wei/views.py:246 msgid "View registrations to the WEI" msgstr "Voir les inscriptions au WEI" -#: apps/wei/views.py:265 +#: apps/wei/views.py:270 msgid "Find WEI Registration" msgstr "Trouver une inscription au WEI" -#: apps/wei/views.py:276 +#: apps/wei/views.py:281 msgid "Update the WEI" msgstr "Modifier le WEI" -#: apps/wei/views.py:297 +#: apps/wei/views.py:302 msgid "Create new bus" msgstr "Ajouter un nouveau bus" -#: apps/wei/views.py:335 +#: apps/wei/views.py:340 msgid "Update bus" msgstr "Modifier le bus" -#: apps/wei/views.py:367 +#: apps/wei/views.py:372 msgid "Manage bus" msgstr "Gérer le bus" -#: apps/wei/views.py:394 +#: apps/wei/views.py:399 msgid "Create new team" msgstr "Créer une nouvelle équipe" -#: apps/wei/views.py:434 +#: apps/wei/views.py:439 msgid "Update team" msgstr "Modifier l'équipe" -#: apps/wei/views.py:465 +#: apps/wei/views.py:470 msgid "Manage WEI team" msgstr "Gérer l'équipe WEI" -#: apps/wei/views.py:487 +#: apps/wei/views.py:492 msgid "Register first year student to the WEI" msgstr "Inscrire un 1A au WEI" -#: apps/wei/views.py:545 apps/wei/views.py:638 +#: apps/wei/views.py:550 apps/wei/views.py:649 msgid "This user is already registered to this WEI." msgstr "Cette personne est déjà inscrite au WEI." -#: apps/wei/views.py:550 +#: apps/wei/views.py:555 msgid "" "This user can't be in her/his first year since he/she has already " "participated to a WEI." @@ -3088,35 +3092,35 @@ msgstr "" "Cet utilisateur ne peut pas être en première année puisqu'il a déjà " "participé à un WEI." -#: apps/wei/views.py:567 +#: apps/wei/views.py:578 msgid "Register old student to the WEI" msgstr "Inscrire un 2A+ au WEI" -#: apps/wei/views.py:622 apps/wei/views.py:704 +#: apps/wei/views.py:633 apps/wei/views.py:721 msgid "You already opened an account in the Société générale." msgstr "Vous avez déjà ouvert un compte auprès de la société générale." -#: apps/wei/views.py:668 +#: apps/wei/views.py:685 msgid "Update WEI Registration" msgstr "Modifier l'inscription WEI" -#: apps/wei/views.py:778 +#: apps/wei/views.py:795 msgid "Delete WEI registration" msgstr "Supprimer l'inscription WEI" -#: apps/wei/views.py:789 +#: apps/wei/views.py:806 msgid "You don't have the right to delete this WEI registration." msgstr "Vous n'avez pas la permission de supprimer cette inscription au WEI." -#: apps/wei/views.py:807 +#: apps/wei/views.py:824 msgid "Validate WEI registration" msgstr "Valider l'inscription WEI" -#: apps/wei/views.py:1169 +#: apps/wei/views.py:1186 msgid "Attribute buses to first year members" msgstr "Répartir les 1A dans les bus" -#: apps/wei/views.py:1191 +#: apps/wei/views.py:1211 msgid "Attribute bus" msgstr "Attribuer un bus" @@ -3266,6 +3270,10 @@ msgstr "" msgid "Contact us" msgstr "Nous contacter" +#: note_kfet/templates/base.html:197 +msgid "Technical Support" +msgstr "Support technique" + #: note_kfet/templates/base_search.html:15 msgid "Search by attribute such as name…" msgstr "Chercher par un attribut tel que le nom …" From 62431a4910609492c07e2594a871eb07671beb20 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Mon, 4 Oct 2021 13:49:16 +0200 Subject: [PATCH 03/10] Treasurers can manage activity entries Signed-off-by: Yohann D'ANELLO --- apps/permission/fixtures/initial.json | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/permission/fixtures/initial.json b/apps/permission/fixtures/initial.json index 1a55e991..f47f9dda 100644 --- a/apps/permission/fixtures/initial.json +++ b/apps/permission/fixtures/initial.json @@ -3048,6 +3048,7 @@ 31, 32, 33, + 43, 51, 53, 54, From 8dd2619013db04acf4559779251d4fd879a9b51d Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Mon, 4 Oct 2021 13:50:21 +0200 Subject: [PATCH 04/10] Activities are distinct Signed-off-by: Yohann D'ANELLO --- apps/activity/views.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/activity/views.py b/apps/activity/views.py index a2ae59ab..270083cb 100644 --- a/apps/activity/views.py +++ b/apps/activity/views.py @@ -66,8 +66,8 @@ class ActivityListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView ordering = ('-date_start',) extra_context = {"title": _("Activities")} - def get_queryset(self): - return super().get_queryset().distinct() + def get_queryset(self, **kwargs): + return super().get_queryset(**kwargs).distinct() def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) @@ -78,9 +78,7 @@ class ActivityListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView prefix='upcoming-', ) - started_activities = Activity.objects\ - .filter(PermissionBackend.filter_queryset(self.request, Activity, "view"))\ - .filter(open=True, valid=True).all() + started_activities = self.get_queryset().filter(open=True, valid=True).distinct().all() context["started_activities"] = started_activities return context From 2a216fd9946554263056dd3da94afb4c9ae7b76f Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Mon, 4 Oct 2021 13:50:39 +0200 Subject: [PATCH 05/10] Entries are distinct Signed-off-by: Yohann D'ANELLO --- apps/activity/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/activity/views.py b/apps/activity/views.py index 270083cb..9e7c9704 100644 --- a/apps/activity/views.py +++ b/apps/activity/views.py @@ -190,7 +190,7 @@ class ActivityEntryView(LoginRequiredMixin, TemplateView): .annotate(balance=F("inviter__balance"), note_name=F("inviter__user__username"))\ .filter(activity=activity)\ .filter(PermissionBackend.filter_queryset(self.request, Guest, "view"))\ - .order_by('last_name', 'first_name').distinct() + .order_by('last_name', 'first_name') if "search" in self.request.GET and self.request.GET["search"]: pattern = self.request.GET["search"] @@ -204,7 +204,7 @@ class ActivityEntryView(LoginRequiredMixin, TemplateView): ) else: guest_qs = guest_qs.none() - return guest_qs + return guest_qs.distinct() def get_invited_note(self, activity): """ From df3bb7135754298937225e66be4a95f9683ce105 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Mon, 4 Oct 2021 13:58:48 +0200 Subject: [PATCH 06/10] Serve static files with Nginx only in production to make JavaScript development easier Signed-off-by: Yohann D'ANELLO --- ansible/host_vars/bde-nk20-beta.adh.crans.org.yml | 6 ------ ansible/host_vars/bde-note-dev.adh.crans.org.yml | 1 + ansible/host_vars/bde-note.adh.crans.org.yml | 1 + ansible/hosts_example | 1 - ansible/roles/5-nginx/templates/nginx_note.conf | 2 ++ note_kfet/urls.py | 3 ++- 6 files changed, 6 insertions(+), 8 deletions(-) delete mode 100644 ansible/host_vars/bde-nk20-beta.adh.crans.org.yml diff --git a/ansible/host_vars/bde-nk20-beta.adh.crans.org.yml b/ansible/host_vars/bde-nk20-beta.adh.crans.org.yml deleted file mode 100644 index d9d850da..00000000 --- a/ansible/host_vars/bde-nk20-beta.adh.crans.org.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -note: - server_name: note-beta.crans.org - git_branch: beta - cron_enabled: false - email: notekfet2020@lists.crans.org diff --git a/ansible/host_vars/bde-note-dev.adh.crans.org.yml b/ansible/host_vars/bde-note-dev.adh.crans.org.yml index 471f35f0..8a4cdc43 100644 --- a/ansible/host_vars/bde-note-dev.adh.crans.org.yml +++ b/ansible/host_vars/bde-note-dev.adh.crans.org.yml @@ -2,5 +2,6 @@ note: server_name: note-dev.crans.org git_branch: beta + serve_static: false cron_enabled: false email: notekfet2020@lists.crans.org diff --git a/ansible/host_vars/bde-note.adh.crans.org.yml b/ansible/host_vars/bde-note.adh.crans.org.yml index 8405dc0f..9c8ec1ed 100644 --- a/ansible/host_vars/bde-note.adh.crans.org.yml +++ b/ansible/host_vars/bde-note.adh.crans.org.yml @@ -2,5 +2,6 @@ note: server_name: note.crans.org git_branch: master + serve_static: true cron_enabled: true email: notekfet2020@lists.crans.org diff --git a/ansible/hosts_example b/ansible/hosts_example index 79526d3d..bd83e3d2 100644 --- a/ansible/hosts_example +++ b/ansible/hosts_example @@ -1,6 +1,5 @@ [dev] bde-note-dev.adh.crans.org -bde-nk20-beta.adh.crans.org [prod] bde-note.adh.crans.org diff --git a/ansible/roles/5-nginx/templates/nginx_note.conf b/ansible/roles/5-nginx/templates/nginx_note.conf index 567c4789..02eb9056 100644 --- a/ansible/roles/5-nginx/templates/nginx_note.conf +++ b/ansible/roles/5-nginx/templates/nginx_note.conf @@ -41,6 +41,7 @@ server { # max upload size client_max_body_size 75M; # adjust to taste +{% if note.serve_static %} # Django media location /media { alias /var/www/note_kfet/media; # your Django project's media files - amend as required @@ -50,6 +51,7 @@ server { alias /var/www/note_kfet/static; # your Django project's static files - amend as required } +{% endif %} location /doc { alias /var/www/documentation; # The documentation of the project } diff --git a/note_kfet/urls.py b/note_kfet/urls.py index 9981df99..7fc37fa7 100644 --- a/note_kfet/urls.py +++ b/note_kfet/urls.py @@ -35,8 +35,9 @@ urlpatterns = [ path('coffee/', include('django_htcpcp_tea.urls')), ] -# During development, serve media files +# During development, serve static and media files if settings.DEBUG: + urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) if "oauth2_provider" in settings.INSTALLED_APPS: From 9628560d649552deb034b2dfd30d8ca3a765e671 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Mon, 4 Oct 2021 14:39:53 +0200 Subject: [PATCH 07/10] Improve entry search with a debouncer Signed-off-by: Yohann D'ANELLO --- apps/activity/templates/activity/activity_entry.html | 7 ++++++- note_kfet/static/js/base.js | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/activity/templates/activity/activity_entry.html b/apps/activity/templates/activity/activity_entry.html index 0a0e8015..0286bdb7 100644 --- a/apps/activity/templates/activity/activity_entry.html +++ b/apps/activity/templates/activity/activity_entry.html @@ -63,7 +63,12 @@ SPDX-License-Identifier: GPL-3.0-or-later refreshBalance(); } - alias_obj.keyup(reloadTable); + alias_obj.keyup(function(event) { + let code = event.originalEvent.keyCode + if (65 <= code <= 122 || code === 13) { + debounce(reloadTable)() + } + }); $(document).ready(init); diff --git a/note_kfet/static/js/base.js b/note_kfet/static/js/base.js index 39b2216d..4b1b7c78 100644 --- a/note_kfet/static/js/base.js +++ b/note_kfet/static/js/base.js @@ -381,11 +381,11 @@ function de_validate (id, validated, resourcetype) { * @param callback Function to call * @param wait Debounced milliseconds */ -function debounce (callback, wait) { - let timeout +let debounce_timeout +function debounce (callback, wait=500) { return (...args) => { const context = this - clearTimeout(timeout) - timeout = setTimeout(() => callback.apply(context, args), wait) + clearTimeout(debounce_timeout) + debounce_timeout = setTimeout(() => callback.apply(context, args), wait) } } From 69bb38297f58e1084fa30f94a768f6305f09d46d Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Mon, 4 Oct 2021 18:15:07 +0200 Subject: [PATCH 08/10] Fix membership dates for new memberships, fix tests Signed-off-by: Yohann D'ANELLO --- apps/member/migrations/0003_create_bde_and_kfet.py | 8 ++++---- apps/member/models.py | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/member/migrations/0003_create_bde_and_kfet.py b/apps/member/migrations/0003_create_bde_and_kfet.py index d2f80c2d..2dbcd9dc 100644 --- a/apps/member/migrations/0003_create_bde_and_kfet.py +++ b/apps/member/migrations/0003_create_bde_and_kfet.py @@ -19,8 +19,8 @@ def create_bde_and_kfet(apps, schema_editor): membership_fee_paid=500, membership_fee_unpaid=500, membership_duration=396, - membership_start="2020-08-01", - membership_end="2021-09-30", + membership_start="2021-08-01", + membership_end="2022-09-30", ) Club.objects.get_or_create( id=2, @@ -31,8 +31,8 @@ def create_bde_and_kfet(apps, schema_editor): membership_fee_paid=3500, membership_fee_unpaid=3500, membership_duration=396, - membership_start="2020-08-01", - membership_end="2021-09-30", + membership_start="2021-08-01", + membership_end="2022-09-30", ) NoteClub.objects.get_or_create( diff --git a/apps/member/models.py b/apps/member/models.py index 9bb4ecf0..9cb0cbde 100644 --- a/apps/member/models.py +++ b/apps/member/models.py @@ -413,6 +413,12 @@ class Membership(models.Model): """ Calculate fee and end date before saving the membership and creating the transaction if needed. """ + # Ensure that club membership dates are valid + old_membership_start = self.club.membership_start + self.club.update_membership_dates() + if self.club.membership_start != old_membership_start: + self.club.save() + created = not self.pk if not created: for role in self.roles.all(): From d94cc2a7adfbf9ddb84b7aedbe2ba2ec47838454 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Mon, 4 Oct 2021 18:26:14 +0200 Subject: [PATCH 09/10] NameNAN Signed-off-by: Yohann D'ANELLO --- apps/note/static/note/js/transfer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/note/static/note/js/transfer.js b/apps/note/static/note/js/transfer.js index 6c5a0329..6c1656ef 100644 --- a/apps/note/static/note/js/transfer.js +++ b/apps/note/static/note/js/transfer.js @@ -355,14 +355,14 @@ $('#btn_transfer').click(function () { destination_alias: dest.name }).done(function () { addMsg(interpolate(gettext('Transfer of %s from %s to %s failed: %s'), - [pretty_money(source.quantity * dest.quantity * amount), source.name, + dest.name, gettext('insufficient funds')]), 'danger', 10000) + [pretty_money(source.quantity * dest.quantity * amount), source.name, dest.name, gettext('insufficient funds')]), 'danger', 10000) reset() }).fail(function (err) { const errObj = JSON.parse(err.responseText) let error = errObj.detail ? errObj.detail : errObj.non_field_errors if (!error) { error = err.responseText } addMsg(interpolate(gettext('Transfer of %s from %s to %s failed: %s'), - [pretty_money(source.quantity * dest.quantity * amount), source.name, + dest.name, error]), 'danger') + [pretty_money(source.quantity * dest.quantity * amount), source.name, dest.name, error]), 'danger') LOCK = false }) }) From 654c01631a938028ea87a6c5c4531970e0388ff7 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Mon, 4 Oct 2021 18:29:34 +0200 Subject: [PATCH 10/10] BDE members can see aliases from other people now Signed-off-by: Yohann D'ANELLO --- apps/permission/fixtures/initial.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/permission/fixtures/initial.json b/apps/permission/fixtures/initial.json index f47f9dda..fe4f90e8 100644 --- a/apps/permission/fixtures/initial.json +++ b/apps/permission/fixtures/initial.json @@ -111,12 +111,12 @@ "note", "alias" ], - "query": "[\"AND\", [\"OR\", {\"note__noteuser__user__memberships__club__name\": \"Kfet\", \"note__noteuser__user__memberships__date_start__lte\": [\"today\"], \"note__noteuser__user__memberships__date_end__gte\": [\"today\"]}, {\"note__noteclub__isnull\": false}], {\"note__is_active\": true}]", + "query": "[\"AND\", [\"OR\", {\"note__noteuser__user__memberships__club__name\": \"BDE\", \"note__noteuser__user__memberships__date_start__lte\": [\"today\"], \"note__noteuser__user__memberships__date_end__gte\": [\"today\"]}, {\"note__noteclub__isnull\": false}], {\"note__is_active\": true}]", "type": "view", "mask": 1, "field": "", "permanent": false, - "description": "Voir les aliases des notes des clubs et des adhérents du club Kfet" + "description": "Voir les aliases des notes des clubs et des adhérents du club BDE" } }, {