dashboard page
This commit is contained in:
SDE
2023-11-10 18:06:05 +03:00
parent d4e3b75bcb
commit 0c20d7d0f4
8 changed files with 43 additions and 9 deletions

View File

@@ -1,5 +1,13 @@
from django.template.loader import render_to_string 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): def get_profile_page_content_html(request, page_name, data):
if page_name == 'chat': 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) return get_profile_subscribe_page_content_html(request)
elif page_name == 'change_profile': elif page_name == 'change_profile':
return get_profile_change_page_content_html(request) return get_profile_change_page_content_html(request)
elif page_name == 'dashboard':
return get_dashboard_page_content_html(request)
else: else:
return None return None

View File

@@ -14,6 +14,8 @@ urlpatterns = [
path('new_route_view/', new_route_view_ajax, name='new_route_view_ajax'), 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('my_routes/', my_routes_ajax, name='my_routes_ajax'),
# path('subscribe/', subscribe_ajax, name='subscribe_ajax'), # path('subscribe/', subscribe_ajax, name='subscribe_ajax'),

View File

@@ -152,6 +152,25 @@ def change_profile_confirm_ajax(request):
html = get_profile_change_page_content_html(request) html = get_profile_change_page_content_html(request)
return JsonResponse({'html': html}, status=200) 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/') @login_required(login_url='/profile/login/')
def change_profile_ajax(request): def change_profile_ajax(request):
if request.method != 'POST': if request.method != 'POST':
@@ -208,7 +227,7 @@ def login_ajax(request):
res_Dict = { res_Dict = {
'redirect_url': reverse('user_profile') 'redirect_url': reverse('profile_page', args=['dashboard'])
} }
return JsonResponse(res_Dict) return JsonResponse(res_Dict)
@@ -259,7 +278,7 @@ def registration_ajax(request):
user.user_profile.save() user.user_profile.save()
res_Dict = { res_Dict = {
'redirect_url': reverse('user_profile') 'redirect_url': reverse('profile_page', args=['dashboard'])
} }
return JsonResponse(res_Dict) return JsonResponse(res_Dict)

View File

@@ -8,7 +8,7 @@ from django.contrib.auth import views
urlpatterns = [ urlpatterns = [
path('registration/', registration_View, name='registration_page'), path('registration/', registration_View, name='registration_page'),
path('', user_profile_View, name='user_profile'), # path('', user_profile_View, name='user_profile'),
# path('page/chat/<int:user_id>/', chat_w_user_View, name='chat_w_user'), # path('page/chat/<int:user_id>/', chat_w_user_View, name='chat_w_user'),
# path('page/chat/', chat_w_user_View, name='chat_w_user_wo_user_id'), # path('page/chat/', chat_w_user_View, name='chat_w_user_wo_user_id'),

View File

@@ -90,6 +90,9 @@ def edit_route_ajax(request):
def new_route_view_ajax(request): def new_route_view_ajax(request):
if request.method != 'POST': if request.method != 'POST':
raise Http404 raise Http404

View File

@@ -18,7 +18,7 @@ function SendLoginForm(el){
data: formData, data: formData,
success: function(data){ success: function(data){
location.href = '/profile' location.href = '/profile/page/dashboard/'

View File

@@ -15,7 +15,7 @@ function SendRegistrationForm(el){
data: formData, data: formData,
success: function(data){ success: function(data){
location.href = '/profile' location.href = '/profile/page/dashboard/'
}, },
error: function (data, exception){ error: function (data, exception){
document.querySelector(".register").innerHTML = data.responseJSON.html document.querySelector(".register").innerHTML = data.responseJSON.html

View File

@@ -16,14 +16,14 @@
{# </div>#} {# </div>#}
{##} {##}
<div class="info_profile"> <div class="info_profile">
{% if not page_html %} {# {% if not page_html %}#}
{% include "blocks/profile/b_profile_first_page.html" %} {# {% include "blocks/profile/b_profile_first_page.html" %}#}
{% else %} {# {% else %}#}
{{ page_html|safe }} {{ page_html|safe }}
{# {% include "blocks/profile/b_chats.html" %}#} {# {% include "blocks/profile/b_chats.html" %}#}
{# {% elif page == 'chat' %}#} {# {% elif page == 'chat' %}#}
{# {% include "blocks/profile/b_chats.html" %}#} {# {% include "blocks/profile/b_chats.html" %}#}
{% endif %} {# {% endif %}#}
</div> </div>
<div class="clear_both"></div> <div class="clear_both"></div>
{# <div class="menu_buttons curtain right close" data-name="Пользователи">#} {# <div class="menu_buttons curtain right close" data-name="Пользователи">#}