diff --git a/apps/member/forms.py b/apps/member/forms.py index 3d892705..4dd62c88 100644 --- a/apps/member/forms.py +++ b/apps/member/forms.py @@ -138,6 +138,9 @@ class ImageForm(forms.Form): return cleaned_data + def is_valid(self): + return super().is_valid() or super().clean().get('image') is None + class ClubForm(forms.ModelForm): def clean(self): diff --git a/apps/member/templates/member/picture_update.html b/apps/member/templates/member/picture_update.html index 51d05f91..60707dcb 100644 --- a/apps/member/templates/member/picture_update.html +++ b/apps/member/templates/member/picture_update.html @@ -14,6 +14,9 @@ SPDX-License-Identifier: GPL-3.0-or-later
diff --git a/apps/member/views.py b/apps/member/views.py index ad0cc79f..45ba81a7 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -326,12 +326,15 @@ class PictureUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, FormMixin, Det """Save image to note""" image = form.cleaned_data['image'] - # Rename as a PNG or GIF - extension = image.name.split(".")[-1] - if extension == "gif": - image.name = "{}_pic.gif".format(self.object.note.pk) + if image is None: + image = "pic/default.png" else: - image.name = "{}_pic.png".format(self.object.note.pk) + # Rename as a PNG or GIF + extension = image.name.split(".")[-1] + if extension == "gif": + image.name = "{}_pic.gif".format(self.object.note.pk) + else: + image.name = "{}_pic.png".format(self.object.note.pk) # Save self.object.note.display_image = image diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index c6ca48b0..f46b9aab 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -247,6 +247,7 @@ msgid "The validation of the activity is pending." msgstr "La validation de cette activité est en attente." #: apps/activity/tables.py:43 apps/treasury/tables.py:107 +#: apps/member/templates/member/picture_update.html:18 msgid "Remove" msgstr "Supprimer" @@ -262,13 +263,13 @@ msgstr "supprimer" msgid "Type" msgstr "Type" -#: apps/activity/tables.py:84 apps/member/forms.py:193 +#: apps/activity/tables.py:84 apps/member/forms.py:196 #: apps/registration/forms.py:92 apps/treasury/forms.py:131 #: apps/wei/forms/registration.py:104 msgid "Last name" msgstr "Nom de famille" -#: apps/activity/tables.py:86 apps/member/forms.py:198 +#: apps/activity/tables.py:86 apps/member/forms.py:201 #: apps/note/templates/note/transaction_form.html:138 #: apps/registration/forms.py:97 apps/treasury/forms.py:133 #: apps/wei/forms/registration.py:109 @@ -562,30 +563,30 @@ msgstr "Taille maximale : 2 Mo" msgid "This image cannot be loaded." msgstr "Cette image ne peut pas être chargée." -#: apps/member/forms.py:148 apps/member/views.py:102 +#: apps/member/forms.py:151 apps/member/views.py:102 #: apps/registration/forms.py:34 apps/registration/views.py:266 msgid "An alias with a similar name already exists." msgstr "Un alias avec un nom similaire existe déjà." -#: apps/member/forms.py:172 +#: apps/member/forms.py:175 msgid "Inscription paid by Société Générale" msgstr "Inscription payée par la Société générale" -#: apps/member/forms.py:174 +#: apps/member/forms.py:177 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:179 apps/registration/forms.py:79 +#: apps/member/forms.py:182 apps/registration/forms.py:79 #: apps/wei/forms/registration.py:91 msgid "Credit type" msgstr "Type de rechargement" -#: apps/member/forms.py:180 apps/registration/forms.py:80 +#: apps/member/forms.py:183 apps/registration/forms.py:80 #: apps/wei/forms/registration.py:92 msgid "No credit" msgstr "Pas de rechargement" -#: apps/member/forms.py:182 +#: apps/member/forms.py:185 msgid "You can credit the note of the user." msgstr "Vous pouvez créditer la note de l'utilisateur·ice avant l'adhésion." @@ -594,17 +595,17 @@ msgstr "Vous pouvez créditer la note de l'utilisateur·ice avant l'adhésion." msgid "Credit amount" msgstr "Montant à créditer" -#: apps/member/forms.py:203 apps/note/templates/note/transaction_form.html:144 +#: apps/member/forms.py:206 apps/note/templates/note/transaction_form.html:144 #: apps/registration/forms.py:102 apps/treasury/forms.py:135 #: apps/wei/forms/registration.py:114 msgid "Bank" msgstr "Banque" -#: apps/member/forms.py:230 +#: apps/member/forms.py:233 msgid "User" msgstr "Utilisateur·ice" -#: apps/member/forms.py:244 +#: apps/member/forms.py:247 msgid "Roles" msgstr "Rôles" @@ -1153,11 +1154,11 @@ msgstr "Introspection :" msgid "Show my applications" msgstr "Voir mes applications" -#: apps/member/templates/member/picture_update.html:35 +#: apps/member/templates/member/picture_update.html:38 msgid "Nevermind" msgstr "Annuler" -#: apps/member/templates/member/picture_update.html:36 +#: apps/member/templates/member/picture_update.html:39 msgid "Crop and upload" msgstr "Recadrer et envoyer"