Merge branch 'remove_picture' into 'main'

Allow you to delete the profile picture

See merge request bde/nk20!250
This commit is contained in:
korenstin 2024-07-18 18:02:43 +02:00
commit af819f45a1
4 changed files with 27 additions and 17 deletions

View File

@ -138,6 +138,9 @@ class ImageForm(forms.Form):
return cleaned_data return cleaned_data
def is_valid(self):
return super().is_valid() or super().clean().get('image') is None
class ClubForm(forms.ModelForm): class ClubForm(forms.ModelForm):
def clean(self): def clean(self):

View File

@ -14,6 +14,9 @@ SPDX-License-Identifier: GPL-3.0-or-later
<form method="post" enctype="multipart/form-data" id="formUpload"> <form method="post" enctype="multipart/form-data" id="formUpload">
{% csrf_token %} {% csrf_token %}
{{ form |crispy }} {{ form |crispy }}
{% if user.note.display_image != "pic/default.png" %}
<input type="submit" class="btn btn-primary" value="{% trans "Remove" %}">
{% endif %}
</form> </form>
</div> </div>
<!-- MODAL TO CROP THE IMAGE --> <!-- MODAL TO CROP THE IMAGE -->

View File

@ -326,6 +326,9 @@ class PictureUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, FormMixin, Det
"""Save image to note""" """Save image to note"""
image = form.cleaned_data['image'] image = form.cleaned_data['image']
if image is None:
image = "pic/default.png"
else:
# Rename as a PNG or GIF # Rename as a PNG or GIF
extension = image.name.split(".")[-1] extension = image.name.split(".")[-1]
if extension == "gif": if extension == "gif":

View File

@ -247,6 +247,7 @@ msgid "The validation of the activity is pending."
msgstr "La validation de cette activité est en attente." msgstr "La validation de cette activité est en attente."
#: apps/activity/tables.py:43 apps/treasury/tables.py:107 #: apps/activity/tables.py:43 apps/treasury/tables.py:107
#: apps/member/templates/member/picture_update.html:18
msgid "Remove" msgid "Remove"
msgstr "Supprimer" msgstr "Supprimer"
@ -262,13 +263,13 @@ msgstr "supprimer"
msgid "Type" msgid "Type"
msgstr "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/registration/forms.py:92 apps/treasury/forms.py:131
#: apps/wei/forms/registration.py:104 #: apps/wei/forms/registration.py:104
msgid "Last name" msgid "Last name"
msgstr "Nom de famille" 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/note/templates/note/transaction_form.html:138
#: apps/registration/forms.py:97 apps/treasury/forms.py:133 #: apps/registration/forms.py:97 apps/treasury/forms.py:133
#: apps/wei/forms/registration.py:109 #: apps/wei/forms/registration.py:109
@ -567,25 +568,25 @@ msgstr "Cette image ne peut pas être chargée."
msgid "An alias with a similar name already exists." msgid "An alias with a similar name already exists."
msgstr "Un alias avec un nom similaire existe déjà." 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" msgid "Inscription paid by Société Générale"
msgstr "Inscription payée par la 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." 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." 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 #: apps/wei/forms/registration.py:91
msgid "Credit type" msgid "Credit type"
msgstr "Type de rechargement" 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 #: apps/wei/forms/registration.py:92
msgid "No credit" msgid "No credit"
msgstr "Pas de rechargement" msgstr "Pas de rechargement"
#: apps/member/forms.py:182 #: apps/member/forms.py:185
msgid "You can credit the note of the user." msgid "You can credit the note of the user."
msgstr "Vous pouvez créditer la note de l'utilisateur·ice avant l'adhésion." 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" msgid "Credit amount"
msgstr "Montant à créditer" 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/registration/forms.py:102 apps/treasury/forms.py:135
#: apps/wei/forms/registration.py:114 #: apps/wei/forms/registration.py:114
msgid "Bank" msgid "Bank"
msgstr "Banque" msgstr "Banque"
#: apps/member/forms.py:230 #: apps/member/forms.py:233
msgid "User" msgid "User"
msgstr "Utilisateur·ice" msgstr "Utilisateur·ice"
#: apps/member/forms.py:244 #: apps/member/forms.py:247
msgid "Roles" msgid "Roles"
msgstr "Rôles" msgstr "Rôles"
@ -1157,11 +1158,11 @@ msgstr "Introspection :"
msgid "Show my applications" msgid "Show my applications"
msgstr "Voir mes applications" msgstr "Voir mes applications"
#: apps/member/templates/member/picture_update.html:35 #: apps/member/templates/member/picture_update.html:38
msgid "Nevermind" msgid "Nevermind"
msgstr "Annuler" msgstr "Annuler"
#: apps/member/templates/member/picture_update.html:36 #: apps/member/templates/member/picture_update.html:39
msgid "Crop and upload" msgid "Crop and upload"
msgstr "Recadrer et envoyer" msgstr "Recadrer et envoyer"