Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -29,7 +29,22 @@ class RegistrationForm(forms.Form):
|
||||
tel = forms.CharField()
|
||||
agreement = forms.BooleanField(initial=False, required=True)
|
||||
|
||||
# def clean(self):
|
||||
def clean(self):
|
||||
pass
|
||||
# cleaned_data = super().clean()
|
||||
# for item in self.changed_data:
|
||||
# if item in self.data:
|
||||
#
|
||||
#
|
||||
# cc_myself = cleaned_data.get("cc_myself")
|
||||
# subject = cleaned_data.get("subject")
|
||||
#
|
||||
# if cc_myself and subject:
|
||||
# # Only do something if both fields are valid so far.
|
||||
# if "help" not in subject:
|
||||
# raise ValidationError(
|
||||
# "Did not send for 'help' in the subject despite " "CC'ing yourself."
|
||||
# )
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -103,10 +103,9 @@ def change_profile_confirm_ajax(request):
|
||||
|
||||
from .forms import RegistrationForm
|
||||
form = RegistrationForm(data)
|
||||
if not form.is_valid():
|
||||
raise ValidationError(form.errors)
|
||||
|
||||
data_for_save = {}
|
||||
users = User.objects.filter(id=request.user.id)
|
||||
if 'firstname' in data:
|
||||
data_for_save.update({'first_name': data['firstname']})
|
||||
if 'lastname' in data:
|
||||
@@ -114,23 +113,41 @@ def change_profile_confirm_ajax(request):
|
||||
if 'email' in data:
|
||||
data_for_save.update({'email': data['email']})
|
||||
data_for_save.update({'username': data['email']})
|
||||
request.user.update(**data_for_save)
|
||||
|
||||
if data_for_save:
|
||||
users.update(**data_for_save)
|
||||
|
||||
data_for_save = {}
|
||||
|
||||
password = None
|
||||
confirm_password = None
|
||||
if 'password' in data:
|
||||
data_for_save.update({'password': data['password']})
|
||||
password = data['password']
|
||||
if 'confirm_password' in data:
|
||||
data_for_save.update({'confirm_password': data['confirm_password']})
|
||||
request.user.u.set_password(data['password'])
|
||||
confirm_password = data['confirm_password']
|
||||
if password and confirm_password:
|
||||
if password != confirm_password:
|
||||
errors = {
|
||||
'password': 'Не совпадают пароли',
|
||||
'confirm_password': 'Не совпадают пароли',
|
||||
}
|
||||
raise ValidationError(errors)
|
||||
|
||||
request.user.set_password(password)
|
||||
request.user.save()
|
||||
|
||||
|
||||
data_for_save = {}
|
||||
user_profiles = UserProfile.objects.filter(user__in=users)
|
||||
if 'country' in data:
|
||||
data_for_save.update({'country': data['country']})
|
||||
if 'city' in data:
|
||||
data_for_save.update({'city': data['city']})
|
||||
if 'tel' in data:
|
||||
data_for_save.update({'phone': data['tel']})
|
||||
request.user.user_profile.update(**data_for_save)
|
||||
|
||||
if data_for_save:
|
||||
user_profiles.update(**data_for_save)
|
||||
|
||||
html = get_profile_change_page_content_html(request)
|
||||
return JsonResponse({'html': html}, status=200)
|
||||
|
||||
Reference in New Issue
Block a user