Move profile editing to gestion
This commit is contained in:
parent
815a5f274c
commit
b1cf96d0ae
7 changed files with 52 additions and 36 deletions
21
cof/forms.py
21
cof/forms.py
|
@ -177,27 +177,6 @@ class EventStatusFilterForm(forms.Form):
|
|||
yield ("has_paid", None, value)
|
||||
|
||||
|
||||
class UserProfileForm(forms.ModelForm):
|
||||
first_name = forms.CharField(label=_('Prénom'), max_length=30)
|
||||
last_name = forms.CharField(label=_('Nom'), max_length=30)
|
||||
|
||||
def __init__(self, *args, **kw):
|
||||
super(UserProfileForm, self).__init__(*args, **kw)
|
||||
self.fields['first_name'].initial = self.instance.user.first_name
|
||||
self.fields['last_name'].initial = self.instance.user.last_name
|
||||
|
||||
def save(self, *args, **kw):
|
||||
super(UserProfileForm, self).save(*args, **kw)
|
||||
self.instance.user.first_name = self.cleaned_data.get('first_name')
|
||||
self.instance.user.last_name = self.cleaned_data.get('last_name')
|
||||
self.instance.user.save()
|
||||
|
||||
class Meta:
|
||||
model = CofProfile
|
||||
fields = ["first_name", "last_name", "phone", "mailing_cof",
|
||||
"mailing_bda", "mailing_bda_revente"]
|
||||
|
||||
|
||||
class RegistrationUserForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kw):
|
||||
super(RegistrationUserForm, self).__init__(*args, **kw)
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
{% extends "base_title.html" %}
|
||||
{% load bootstrap %}
|
||||
|
||||
{% block page_size %}col-sm-8{%endblock%}
|
||||
|
||||
{% block realcontent %}
|
||||
<h2>Modifier mon profil</h2>
|
||||
{% if success %}
|
||||
<p class="success">Votre profil a été mis à jour avec succès !</p>
|
||||
{% endif %}
|
||||
<form id="profile form-horizontal" method="post" action="{% url 'cof.views.profile' %}">
|
||||
<div class="row" style="margin: 0 15%;">
|
||||
{% csrf_token %}
|
||||
<fieldset"center-block">
|
||||
{% for field in form %}
|
||||
{{ field | bootstrap }}
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
</div>
|
||||
{% if user.profile.comments %}
|
||||
<div class="row" style="margin: 0 15%;">
|
||||
<h4>Commentaires</h4>
|
||||
<p>
|
||||
{{ user.profile.comments }}
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="form-actions">
|
||||
<input type="submit" class="btn btn-primary pull-right" value="Enregistrer" />
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
13
cof/views.py
13
cof/views.py
|
@ -302,19 +302,6 @@ def survey_status(request, survey_id):
|
|||
"form": form})
|
||||
|
||||
|
||||
@cof_required
|
||||
def profile(request):
|
||||
success = False
|
||||
if request.method == "POST":
|
||||
form = UserProfileForm(request.POST, instance=request.user.profile)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
success = True
|
||||
else:
|
||||
form = UserProfileForm(instance=request.user.profile)
|
||||
return render(request, "profile.html", {"form": form, "success": success})
|
||||
|
||||
|
||||
def registration_set_ro_fields(user_form, profile_form):
|
||||
user_form.fields['username'].widget.attrs['readonly'] = True
|
||||
profile_form.fields['login_clipper'].widget.attrs['readonly'] = True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue