From 0814cfe1ef3bcc6da42eb49c5a264172e1a18e34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Sun, 6 Oct 2019 00:00:20 +0200 Subject: [PATCH 1/4] home templates: add links for non-COF users Add links to - change password page - profile page --- gestioncof/templates/gestioncof/home.html | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/gestioncof/templates/gestioncof/home.html b/gestioncof/templates/gestioncof/home.html index 9569af43..8b014ee8 100644 --- a/gestioncof/templates/gestioncof/home.html +++ b/gestioncof/templates/gestioncof/home.html @@ -56,18 +56,19 @@ - {% if user.profile.is_cof %}

Divers

- +
- {% endif %} {% if user.profile.is_buro %}
From 41256154ade700723592ed579b9e192fda49166a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Sun, 6 Oct 2019 00:01:41 +0200 Subject: [PATCH 2/4] Make profile editable for non-COF user Non-COF users can now edit their own profile Contrary to COF users they cannot change their mailing list settings --- gestioncof/forms.py | 6 ++++++ gestioncof/views.py | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/gestioncof/forms.py b/gestioncof/forms.py index 755d44af..6147aa78 100644 --- a/gestioncof/forms.py +++ b/gestioncof/forms.py @@ -214,6 +214,12 @@ class UserForm(forms.ModelForm): fields = ["first_name", "last_name", "email"] +class PhoneForm(forms.ModelForm): + class Meta: + model = CofProfile + fields = ["phone"] + + class ProfileForm(forms.ModelForm): class Meta: model = CofProfile diff --git a/gestioncof/views.py b/gestioncof/views.py index f4a8be14..6c7bf337 100644 --- a/gestioncof/views.py +++ b/gestioncof/views.py @@ -33,6 +33,7 @@ from gestioncof.forms import ( EventStatusFilterForm, ExteAuthenticationForm, GestioncofConfigForm, + PhoneForm, ProfileForm, RegistrationPassUserForm, RegistrationProfileForm, @@ -355,12 +356,13 @@ def survey_status(request, survey_id): ) -@cof_required +@login_required def profile(request): user = request.user data = request.POST if request.method == "POST" else None user_form = UserForm(data=data, instance=user, prefix="u") - profile_form = ProfileForm(data=data, instance=user.profile, prefix="p") + profile_form_klass = ProfileForm if user.profile.is_cof else PhoneForm + profile_form = profile_form_klass(data=data, instance=user.profile, prefix="p") if request.method == "POST": if user_form.is_valid() and profile_form.is_valid(): user_form.save() From d5f0060e2efb24f0bcb1e52c4883b8c8c6956809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Sun, 6 Oct 2019 00:06:10 +0200 Subject: [PATCH 3/4] Fix profile test: non-cof users can access /profile --- gestioncof/tests/test_views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gestioncof/tests/test_views.py b/gestioncof/tests/test_views.py index e945a87a..31cb8d8a 100644 --- a/gestioncof/tests/test_views.py +++ b/gestioncof/tests/test_views.py @@ -362,7 +362,7 @@ class ProfileViewTests(ViewTestCaseMixin, TestCase): http_methods = ["GET", "POST"] auth_user = "member" - auth_forbidden = [None, "user"] + auth_forbidden = [None] def test_get(self): r = self.client.get(self.url) From 83c83d791beceb8854caf604cbc30e3d4c9bd6db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Sun, 6 Oct 2019 11:55:14 +0200 Subject: [PATCH 4/4] Update changelog --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 3d787bf1..7b91303f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,8 @@ * Version 0.3 - ??? +- Comptes extés: lien pour changer son mot de passe sur la page d'accueil +- Les utilisateurices non-COF peuvent éditer leur profil - Un peu de pub pour KDEns sur la page d'accueil - Fix erreur 500 sur /bda/revente//manage - Si on essaie d'accéder au compte que qqn d'autre on a une 404 (et plus une 403)