Merge branch 'kerl/noncof_profile_and_passwd_change' into 'master'

Les utilisateurs non-COF peuvent changer leur mot de passe et éditer leur profil

Closes #178 and #177

See merge request klub-dev-ens/gestioCOF!368
This commit is contained in:
Ludovic Stephan 2019-10-16 19:17:56 +02:00
commit f83eeb7a5f
5 changed files with 23 additions and 12 deletions

View file

@ -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/<tirage_id>/manage
- Si on essaie d'accéder au compte que qqn d'autre on a une 404 (et plus une 403)

View file

@ -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

View file

@ -56,18 +56,19 @@
</ul>
</div>
{% if user.profile.is_cof %}
<h3 class="block-title">Divers<span class="pull-right glyphicon glyphicon-question-sign"></span></h3>
<div class="hm-block">
<ul>
<li><a href="{% url "calendar" %}">Calendrier dynamique</a></li>
{% if user.profile.is_cof %}<li><a href="{% url "petits-cours-inscription" %}">Inscription pour donner des petits cours</a></li>{% endif %}
<li><a href="{% url "profile" %}">Éditer mon profil</a></li>
{% if not user.profile.login_clipper %}<li><a href="{% url "password_change" %}">Changer mon mot de passe</a></li>{% endif %}
</ul>
<ul>
<li><a href="{% url "profile" %}">Éditer mon profil</a></li>
{% if user.profile.is_cof %}
<li><a href="{% url "calendar" %}">Calendrier dynamique</a></li>
<li><a href="{% url "petits-cours-inscription" %}">Inscription pour donner des petits cours</a></li>
{% endif %}
{% if not user.profile.login_clipper %}
<li><a href="{% url "password_change" %}">Changer mon mot de passe</a></li>
{% endif %}
</ul>
</div>
{% endif %}
</div>
{% if user.profile.is_buro %}
<div class="col-sm-6 buro-user-hm">

View file

@ -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)

View file

@ -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()