From 47ffae4b828c151b56a69fa0a5bf686b6098ea46 Mon Sep 17 00:00:00 2001 From: SDE Date: Sun, 22 Oct 2023 13:04:05 +0300 Subject: [PATCH] 0.7.63 user_subscribe in all views --- AuthApp/forms.py | 4 ++++ AuthApp/funcs.py | 16 ++++++++++++++++ AuthApp/js_views.py | 1 + 3 files changed, 21 insertions(+) diff --git a/AuthApp/forms.py b/AuthApp/forms.py index d6b6065..b61fc9d 100644 --- a/AuthApp/forms.py +++ b/AuthApp/forms.py @@ -14,11 +14,15 @@ class LoginForm(forms.Form): username = forms.CharField(required=True) password = forms.CharField(required=True) + + class RegistrationForm(forms.Form): from .models import account_type_choices account_type = forms.ChoiceField(choices=account_type_choices, initial='sender', required=True) firstname = forms.CharField(required=False) lastname = forms.CharField(required=False) + country = forms.CharField(required=False) + city = forms.CharField(required=False) email = forms.EmailField() password = forms.CharField(widget=forms.PasswordInput()) confirm_password = forms.CharField(widget=forms.PasswordInput()) diff --git a/AuthApp/funcs.py b/AuthApp/funcs.py index c6c8403..be7c4d3 100644 --- a/AuthApp/funcs.py +++ b/AuthApp/funcs.py @@ -26,7 +26,23 @@ def get_profile_page_content_html(request, page_name, data): def get_profile_change_page_content_html(request): + + init_Dict = { + 'firstname': request.user.first_name, + 'lastname': request.user.last_name, + 'email': request.user.email, + 'tel': request.user.user_profile.phone, + 'country': request.user.user_profile.country, + 'city': request.user.user_profile.city, + } + from .forms import RegistrationForm + form = RegistrationForm(initial=init_Dict) + + from SubscribesApp.funcs import get_cur_user_subscribe + Dict = { + 'profileForm': form, + 'user_subscribe': get_cur_user_subscribe(request.user) } html = render_to_string('blocks/profile/b_profile.html', Dict, request=request) diff --git a/AuthApp/js_views.py b/AuthApp/js_views.py index 4084ab9..a4fea0a 100644 --- a/AuthApp/js_views.py +++ b/AuthApp/js_views.py @@ -70,6 +70,7 @@ def change_profile_ajax(request): if request.method != 'POST': raise Http404 + html = get_profile_change_page_content_html(request) return JsonResponse({'html': html}, status=200)