diff --git a/apps/member/forms.py b/apps/member/forms.py index c4940bf6..8735dc8e 100644 --- a/apps/member/forms.py +++ b/apps/member/forms.py @@ -10,6 +10,7 @@ from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth.models import User from django.db import transaction from django.forms import CheckboxSelectMultiple +from phonenumber_field.formfields import PhoneNumberField from django.utils import timezone from django.utils.translation import gettext_lazy as _ from note.models import NoteSpecial, Alias @@ -45,6 +46,11 @@ class ProfileForm(forms.ModelForm): A form for the extras field provided by the :model:`member.Profile` model. """ # Remove widget=forms.HiddenInput() if you want to use report frequency. + phone_number = PhoneNumberField( + widget=forms.TextInput(attrs={"type": "tel", "class": "form-control"}), + required=False + ) + report_frequency = forms.IntegerField(required=False, initial=0, label=_("Report frequency")) last_report = forms.DateTimeField(required=False, disabled=True, label=_("Last report date")) @@ -72,7 +78,12 @@ class ProfileForm(forms.ModelForm): if not self.instance.section or (("department" in self.changed_data or "promotion" in self.changed_data) and "section" not in self.changed_data): self.instance.section = self.instance.section_generated - return super().save(commit) + instance = super().save(commit=False) + if instance.phone_number: + instance.phone_number = instance.phone_number.as_e164 + if commit: + instance.save() + return instance class Meta: model = Profile diff --git a/apps/member/templates/member/profile_update.html b/apps/member/templates/member/profile_update.html index 2f018381..e0975c22 100644 --- a/apps/member/templates/member/profile_update.html +++ b/apps/member/templates/member/profile_update.html @@ -10,7 +10,7 @@ SPDX-License-Identifier: GPL-3.0-or-later {{ title }}
-
+ {% csrf_token %} {{ form | crispy }} {{ profile_form | crispy }} @@ -20,4 +20,46 @@ SPDX-License-Identifier: GPL-3.0-or-later
+{% endblock %} + +{% block extrajavascript %} + + {% endblock %} \ No newline at end of file diff --git a/apps/wei/templates/wei/weiregistration_form.html b/apps/wei/templates/wei/weiregistration_form.html index fae85e0f..4964814d 100644 --- a/apps/wei/templates/wei/weiregistration_form.html +++ b/apps/wei/templates/wei/weiregistration_form.html @@ -11,7 +11,7 @@ SPDX-License-Identifier: GPL-3.0-or-later {{ title }}
-
+ {% csrf_token %} {{ form|crispy }} {{ membership_form|crispy }} @@ -22,6 +22,46 @@ SPDX-License-Identifier: GPL-3.0-or-later {% endblock %} {% block extrajavascript %} + + + {% if not object.membership %} @@ -41,6 +43,8 @@ SPDX-License-Identifier: GPL-3.0-or-later {# Translation in javascript files #} + + {# If extra ressources are needed for a form, load here #} {% if form.media %} {{ form.media }} diff --git a/note_kfet/templates/registration/signup.html b/note_kfet/templates/registration/signup.html index 7bd503eb..8aa15f8c 100644 --- a/note_kfet/templates/registration/signup.html +++ b/note_kfet/templates/registration/signup.html @@ -31,3 +31,45 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% endblock %} + +{% block extrajavascript %} + + +{% endblock %} \ No newline at end of file