From 0c20d7d0f4ea2da615054f84b88d1d8dce92d8a8 Mon Sep 17 00:00:00 2001 From: SDE Date: Fri, 10 Nov 2023 18:06:05 +0300 Subject: [PATCH] 0.7.77 dashboard page --- AuthApp/funcs.py | 10 ++++++++++ AuthApp/js_urls.py | 2 ++ AuthApp/js_views.py | 23 +++++++++++++++++++++-- AuthApp/urls.py | 2 +- RoutesApp/js_views.py | 3 +++ static/js/authorization.js | 2 +- static/js/registration.js | 2 +- templates/blocks/b_user_profile.html | 8 ++++---- 8 files changed, 43 insertions(+), 9 deletions(-) diff --git a/AuthApp/funcs.py b/AuthApp/funcs.py index be7c4d3..13eb757 100644 --- a/AuthApp/funcs.py +++ b/AuthApp/funcs.py @@ -1,5 +1,13 @@ from django.template.loader import render_to_string +def get_dashboard_page_content_html(request): + + Dict = { + } + + html = render_to_string('blocks/profile/b_profile_first_page.html', Dict, request=request) + return html + def get_profile_page_content_html(request, page_name, data): if page_name == 'chat': @@ -21,6 +29,8 @@ def get_profile_page_content_html(request, page_name, data): return get_profile_subscribe_page_content_html(request) elif page_name == 'change_profile': return get_profile_change_page_content_html(request) + elif page_name == 'dashboard': + return get_dashboard_page_content_html(request) else: return None diff --git a/AuthApp/js_urls.py b/AuthApp/js_urls.py index ab58350..795d2f9 100644 --- a/AuthApp/js_urls.py +++ b/AuthApp/js_urls.py @@ -14,6 +14,8 @@ urlpatterns = [ path('new_route_view/', new_route_view_ajax, name='new_route_view_ajax'), + path('dashboard/', dashboard_ajax, name='dashboard_ajax'), + path('my_routes/', my_routes_ajax, name='my_routes_ajax'), # path('subscribe/', subscribe_ajax, name='subscribe_ajax'), diff --git a/AuthApp/js_views.py b/AuthApp/js_views.py index 0140607..feca994 100644 --- a/AuthApp/js_views.py +++ b/AuthApp/js_views.py @@ -152,6 +152,25 @@ def change_profile_confirm_ajax(request): html = get_profile_change_page_content_html(request) return JsonResponse({'html': html}, status=200) + +@login_required(login_url='/profile/login/') +def dashboard_ajax(request): + if request.method != 'POST': + raise Http404 + + try: + + from .funcs import get_dashboard_page_content_html + html = get_dashboard_page_content_html(request) + + except Exception as e: + msg = f'dashboard_ajax Error = {str(e)}' + print(msg) + html = msg + + return JsonResponse({'html': html}, status=200) + + @login_required(login_url='/profile/login/') def change_profile_ajax(request): if request.method != 'POST': @@ -208,7 +227,7 @@ def login_ajax(request): res_Dict = { - 'redirect_url': reverse('user_profile') + 'redirect_url': reverse('profile_page', args=['dashboard']) } return JsonResponse(res_Dict) @@ -259,7 +278,7 @@ def registration_ajax(request): user.user_profile.save() res_Dict = { - 'redirect_url': reverse('user_profile') + 'redirect_url': reverse('profile_page', args=['dashboard']) } return JsonResponse(res_Dict) diff --git a/AuthApp/urls.py b/AuthApp/urls.py index 0a0c96c..6d627a1 100644 --- a/AuthApp/urls.py +++ b/AuthApp/urls.py @@ -8,7 +8,7 @@ from django.contrib.auth import views urlpatterns = [ path('registration/', registration_View, name='registration_page'), - path('', user_profile_View, name='user_profile'), + # path('', user_profile_View, name='user_profile'), # path('page/chat//', chat_w_user_View, name='chat_w_user'), # path('page/chat/', chat_w_user_View, name='chat_w_user_wo_user_id'), diff --git a/RoutesApp/js_views.py b/RoutesApp/js_views.py index 0224ff1..03656a4 100644 --- a/RoutesApp/js_views.py +++ b/RoutesApp/js_views.py @@ -90,6 +90,9 @@ def edit_route_ajax(request): + + + def new_route_view_ajax(request): if request.method != 'POST': raise Http404 diff --git a/static/js/authorization.js b/static/js/authorization.js index be6f8c9..efb698b 100644 --- a/static/js/authorization.js +++ b/static/js/authorization.js @@ -18,7 +18,7 @@ function SendLoginForm(el){ data: formData, success: function(data){ - location.href = '/profile' + location.href = '/profile/page/dashboard/' diff --git a/static/js/registration.js b/static/js/registration.js index bb6fcbd..6cb64f7 100644 --- a/static/js/registration.js +++ b/static/js/registration.js @@ -15,7 +15,7 @@ function SendRegistrationForm(el){ data: formData, success: function(data){ - location.href = '/profile' + location.href = '/profile/page/dashboard/' }, error: function (data, exception){ document.querySelector(".register").innerHTML = data.responseJSON.html diff --git a/templates/blocks/b_user_profile.html b/templates/blocks/b_user_profile.html index f9b23a5..1ee45da 100644 --- a/templates/blocks/b_user_profile.html +++ b/templates/blocks/b_user_profile.html @@ -16,14 +16,14 @@ {# #} {##}
- {% if not page_html %} - {% include "blocks/profile/b_profile_first_page.html" %} - {% else %} +{# {% if not page_html %}#} +{# {% include "blocks/profile/b_profile_first_page.html" %}#} +{# {% else %}#} {{ page_html|safe }} {# {% include "blocks/profile/b_chats.html" %}#} {# {% elif page == 'chat' %}#} {# {% include "blocks/profile/b_chats.html" %}#} - {% endif %} +{# {% endif %}#}
{#