diff --git a/AuthApp/funcs.py b/AuthApp/funcs.py index 4d0baa7..53c5853 100644 --- a/AuthApp/funcs.py +++ b/AuthApp/funcs.py @@ -1,3 +1,4 @@ +from django.http import QueryDict from django.template.loader import render_to_string from SubscribesApp.funcs import check_option_in_cur_user_subscribe @@ -56,7 +57,7 @@ def get_profile_page_content_html(request, page_name, data): return None -def get_profile_change_page_content_html(request): +def get_profile_change_page_content_html(request, data=None): init_Dict = { 'firstname': request.user.first_name, @@ -66,6 +67,25 @@ def get_profile_change_page_content_html(request): 'country': request.user.user_profile.country, 'city': request.user.user_profile.city, } + + if data: + if type(data) == QueryDict: + data = data.dict() + init_Dict.update(data) + # if 'firstname' in data: + # init_Dict.update({'first_name': data['firstname']}) + # if 'lastname' in data: + # init_Dict.update({'last_name': data['lastname']}) + # if 'email' in data: + # init_Dict.update({'email': data['email']}) + # init_Dict.update({'username': data['email']}) + # if 'country' in data: + # init_Dict.update({'country': data['country']}) + # if 'city' in data: + # init_Dict.update({'city': data['city']}) + # if 'tel' in data: + # init_Dict.update({'tel': data['tel']}) + from .forms import RegistrationForm form = RegistrationForm(initial=init_Dict) diff --git a/AuthApp/js_views.py b/AuthApp/js_views.py index bfe0742..294797c 100644 --- a/AuthApp/js_views.py +++ b/AuthApp/js_views.py @@ -78,9 +78,10 @@ def password_recovery_ajax(request): try: user = User.objects.get(email=email) except User.DoesNotExist: + msg = _('Пользователь с указанным email не зарегистрирован на сайте') return JsonResponse({ 'status': 'error', - 'error': _('Пользователь с указанным email не зарегистрирован на сайте') + 'error': msg }, status=400) user.user_profile.authMailCode = uuid1().hex @@ -501,7 +502,7 @@ def change_profile_confirm_ajax(request): if data_for_save: user_profiles.update(**data_for_save) - html = get_profile_change_page_content_html(request) + html = get_profile_change_page_content_html(request, data) from GeneralApp.funcs import get_add_to_ajax_response_Dict res_Dict = {'html': html} res_Dict.update(get_add_to_ajax_response_Dict(request.user)) diff --git a/static/js/authorization.js b/static/js/authorization.js index 0c59dfe..d670ec9 100644 --- a/static/js/authorization.js +++ b/static/js/authorization.js @@ -39,7 +39,7 @@ function SendLoginForm(el){ }, error: function (data, exception){ - document.querySelector(".login").innerHTML = data.responseJSON.html + document.querySelector(".wrapper_content").innerHTML = data.responseJSON.html document.getElementsByClassName('recovery')[0].classList.remove('hide') } }); diff --git a/templates/blocks/profile/b_profile.html b/templates/blocks/profile/b_profile.html index 902499d..979b60e 100644 --- a/templates/blocks/profile/b_profile.html +++ b/templates/blocks/profile/b_profile.html @@ -16,7 +16,7 @@