Merge pull request 'dev' (#19) from dev into main

Reviewed-on: #19
This commit is contained in:
2024-10-22 16:50:19 +03:00
5 changed files with 27 additions and 6 deletions

View File

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

View File

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

View File

@@ -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')
}
});

View File

@@ -16,7 +16,7 @@
<div class="f-r">
<div class="cur_subscribe_label">{% translate "Текущая подписка:" %}</div>
<div class="cur_subscribe_f_profile">{% if user_subscribe.subscribe.name %}{{ user_subscribe.subscribe.name }}{% else %}{% translate "Нет активных подписок" %}{% endif %}</div>
<div class="btn_go_to_subscribes pointer" onclick="select_tab_profile(this,'show_cur_subscribe', {% if owner_type %},'{{ owner_type }}' {% else %}, null {% endif %}, false)">{% translate "Перейти к подпискам" %}</div>
<div class="btn_go_to_subscribes pointer" onclick="select_tab_profile(this,'show_cur_subscribe',{% if owner_type %}'{{ owner_type }}', {% else %}null, {% endif %} false)">{% translate "Перейти к подпискам" %}</div>
</div>
<div class="clear_both"></div>
</div>

View File

@@ -5,7 +5,7 @@
{% trans "Пароль" as p_password %}
<section class="login">
<h1>{% translate "Войдите в профиль" %}</h1>
<h1>{% translate "Войдите в профиль" %}</h1>
<form class="login_form" name="login_form" method="post">