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
This commit is contained in:
parent
0814cfe1ef
commit
41256154ad
2 changed files with 10 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue