0.7.19
profile static pages
This commit is contained in:
@@ -1,2 +1,51 @@
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
def get_profile_page_content_html(request, page_name, data):
|
||||
|
||||
if page_name == 'chat':
|
||||
from ChatServiceApp.funcs import get_chat_page_content_html
|
||||
return get_chat_page_content_html(request, data)
|
||||
elif page_name == 'create_route_for_customer':
|
||||
from RoutesApp.funcs import get_profile_new_route_page_html
|
||||
return get_profile_new_route_page_html(request, {})
|
||||
elif page_name == 'create_route_for_mover':
|
||||
from RoutesApp.funcs import get_profile_new_route_page_html
|
||||
return get_profile_new_route_page_html(request, {})
|
||||
elif page_name == 'my_routes':
|
||||
from RoutesApp.funcs import get_profile_my_routes_page_content_html
|
||||
return get_profile_my_routes_page_content_html(request)
|
||||
elif page_name == 'support':
|
||||
return get_profile_support_page_content_html(request, data)
|
||||
elif page_name == 'my_subscribe':
|
||||
from SubscribesApp.funcs import get_profile_subscribe_page_content_html
|
||||
return get_profile_subscribe_page_content_html(request)
|
||||
elif page_name == 'change_profile':
|
||||
return get_profile_change_page_content_html(request)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def get_profile_change_page_content_html(request):
|
||||
Dict = {
|
||||
}
|
||||
|
||||
html = render_to_string('blocks/profile/b_profile.html', Dict, request=request)
|
||||
return html
|
||||
|
||||
|
||||
def get_profile_support_page_content_html(request, data=None):
|
||||
if request.user.is_staff:
|
||||
from ChatServiceApp.funcs import get_ticketsDict_for_staff
|
||||
Dict = get_ticketsDict_for_staff(request.user)
|
||||
tpl_name = 'blocks/profile/b_support_chat.html'
|
||||
else:
|
||||
from ChatServiceApp.models import MsgGroup
|
||||
tickets = MsgGroup.objects.filter(enable=True, owner=request.user).order_by('-modifiedDT')
|
||||
|
||||
Dict = {
|
||||
'tickets': tickets,
|
||||
}
|
||||
tpl_name = 'blocks/profile/b_support_tickets.html'
|
||||
|
||||
html = render_to_string(tpl_name, Dict, request=request)
|
||||
return html
|
||||
@@ -16,7 +16,7 @@ urlpatterns = [
|
||||
|
||||
|
||||
path('my_routes/', my_routes_ajax, name='my_routes_ajax'),
|
||||
path('subscribe/', subscribe_ajax, name='subscribe_ajax'),
|
||||
# path('subscribe/', subscribe_ajax, name='subscribe_ajax'),
|
||||
path('chats/', chats_ajax, name='chats_ajax'),
|
||||
|
||||
path('support_tickets/', support_tickets_ajax, name='support_tickets_ajax'),
|
||||
|
||||
@@ -11,18 +11,19 @@ from django.utils.translation import gettext as _
|
||||
from datetime import datetime
|
||||
from django.template.loader import render_to_string
|
||||
from django.urls import reverse
|
||||
from .funcs import *
|
||||
|
||||
|
||||
@login_required(login_url='/profile/login/')
|
||||
def subscribe_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
Dict = {
|
||||
}
|
||||
|
||||
html = render_to_string('blocks/profile/b_subscribe.html', Dict, request=request)
|
||||
return JsonResponse({'html': html}, status=200)
|
||||
# @login_required(login_url='/profile/login/')
|
||||
# def subscribe_ajax(request):
|
||||
# if request.method != 'POST':
|
||||
# raise Http404
|
||||
#
|
||||
# Dict = {
|
||||
# }
|
||||
#
|
||||
# html = render_to_string('blocks/profile/b_subscribe.html', Dict, request=request)
|
||||
# return JsonResponse({'html': html}, status=200)
|
||||
|
||||
@login_required(login_url='/profile/login/')
|
||||
def chats_ajax(request):
|
||||
@@ -58,20 +59,8 @@ def support_tickets_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
if request.user.is_staff:
|
||||
from ChatServiceApp.funcs import get_ticketsDict_for_staff
|
||||
Dict = get_ticketsDict_for_staff(request.user)
|
||||
tpl_name = 'blocks/profile/b_support_chat.html'
|
||||
else:
|
||||
from ChatServiceApp.models import MsgGroup
|
||||
tickets = MsgGroup.objects.filter(enable=True, owner=request.user).order_by('-modifiedDT')
|
||||
html = get_profile_support_page_content_html(request)
|
||||
|
||||
Dict = {
|
||||
'tickets': tickets,
|
||||
}
|
||||
tpl_name = 'blocks/profile/b_support_tickets.html'
|
||||
|
||||
html = render_to_string(tpl_name, Dict, request=request)
|
||||
return JsonResponse({'html': html}, status=200)
|
||||
|
||||
|
||||
@@ -81,10 +70,7 @@ def change_profile_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
Dict = {
|
||||
}
|
||||
|
||||
html = render_to_string('blocks/profile/b_profile.html', Dict, request=request)
|
||||
html = get_profile_change_page_content_html(request)
|
||||
return JsonResponse({'html': html}, status=200)
|
||||
|
||||
|
||||
|
||||
@@ -9,11 +9,14 @@ urlpatterns = [
|
||||
|
||||
path('registration/', registration_View, name='registration_page'),
|
||||
path('', user_profile_View, name='user_profile'),
|
||||
path('chat/<int:user_id>/', chat_w_user_View, name='chat_w_user'),
|
||||
path('chat/', chat_w_user_View, name='chat_w_user_wo_user_id'),
|
||||
# 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('create_route_for_customer/', create_route_for_customer_View, name='create_route_for_customer_View'),
|
||||
path('create_route_for_mover/', create_route_for_mover_View, name='create_route_for_mover_View'),
|
||||
path('page/<str:page_name>/', profile_page_View, name='profile_page'),
|
||||
path('page/<str:page_name>/<int:id>/', profile_page_View, name='profile_page_w_param'),
|
||||
|
||||
# path('create_route_for_customer/', create_route_for_customer_View, name='create_route_for_customer_View'),
|
||||
# path('create_route_for_mover/', create_route_for_mover_View, name='create_route_for_mover_View'),
|
||||
|
||||
path('login/', login_View, name='login_profile'),
|
||||
path('logout/', logout_View, name='logout_profile'),
|
||||
|
||||
@@ -12,6 +12,7 @@ from BaseModels.mailSender import techSendMail
|
||||
from django.utils.translation import gettext as _
|
||||
from datetime import datetime
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from .funcs import *
|
||||
|
||||
|
||||
def registration_View(request):
|
||||
@@ -22,47 +23,57 @@ def registration_View(request):
|
||||
return HttpResponse(t.render(Dict, request))
|
||||
|
||||
|
||||
def create_route_for_customer_View(request):
|
||||
Dict = {}
|
||||
t = loader.get_template('pages/profile/p_user_profile.html')
|
||||
return HttpResponse(t.render(Dict, request))
|
||||
|
||||
|
||||
def create_route_for_mover_View(request):
|
||||
Dict = {}
|
||||
t = loader.get_template('pages/profile/p_user_profile.html')
|
||||
return HttpResponse(t.render(Dict, request))
|
||||
# def create_route_for_customer_View(request):
|
||||
# Dict = {}
|
||||
# t = loader.get_template('pages/profile/p_user_profile.html')
|
||||
# return HttpResponse(t.render(Dict, request))
|
||||
#
|
||||
#
|
||||
# def create_route_for_mover_View(request):
|
||||
# Dict = {}
|
||||
# t = loader.get_template('pages/profile/p_user_profile.html')
|
||||
# return HttpResponse(t.render(Dict, request))
|
||||
|
||||
|
||||
@login_required(login_url='/profile/login/')
|
||||
def chat_w_user_View(request, user_id=None):
|
||||
from ChatServiceApp.funcs import get_chat_page_content_Dict
|
||||
|
||||
# receivers = get_chat_receivers_for_user(request.user)
|
||||
|
||||
Dict = get_chat_page_content_Dict(request, user_id)
|
||||
|
||||
# cur_chat_msgs = None
|
||||
#
|
||||
# try:
|
||||
# cur_receiver = User.objects.get(id=user_id)
|
||||
# if not cur_receiver in receivers:
|
||||
# receivers.insert(0, cur_receiver)
|
||||
# cur_chat_msgs = get_msgs_for_chat_w_users(request.user, cur_receiver)
|
||||
# except User.DoesNotExist:
|
||||
# cur_receiver = None
|
||||
#
|
||||
#
|
||||
# Dict = {
|
||||
# 'page': 'chat',
|
||||
# 'cur_receiver': cur_receiver,
|
||||
# 'receivers': receivers,
|
||||
# 'messages':cur_chat_msgs
|
||||
# }
|
||||
def profile_page_View(request, page_name, id=None):
|
||||
Dict = {
|
||||
'page_html': get_profile_page_content_html(request, page_name, id)
|
||||
}
|
||||
|
||||
t = loader.get_template('pages/profile/p_user_profile.html')
|
||||
return HttpResponse(t.render(Dict, request))
|
||||
|
||||
|
||||
# @login_required(login_url='/profile/login/')
|
||||
# def chat_w_user_View(request, user_id=None):
|
||||
# from ChatServiceApp.funcs import get_chat_page_content_Dict
|
||||
#
|
||||
# # receivers = get_chat_receivers_for_user(request.user)
|
||||
#
|
||||
# Dict = get_chat_page_content_Dict(request, user_id)
|
||||
#
|
||||
# # cur_chat_msgs = None
|
||||
# #
|
||||
# # try:
|
||||
# # cur_receiver = User.objects.get(id=user_id)
|
||||
# # if not cur_receiver in receivers:
|
||||
# # receivers.insert(0, cur_receiver)
|
||||
# # cur_chat_msgs = get_msgs_for_chat_w_users(request.user, cur_receiver)
|
||||
# # except User.DoesNotExist:
|
||||
# # cur_receiver = None
|
||||
# #
|
||||
# #
|
||||
# # Dict = {
|
||||
# # 'page': 'chat',
|
||||
# # 'cur_receiver': cur_receiver,
|
||||
# # 'receivers': receivers,
|
||||
# # 'messages':cur_chat_msgs
|
||||
# # }
|
||||
#
|
||||
# t = loader.get_template('pages/profile/p_user_profile.html')
|
||||
# return HttpResponse(t.render(Dict, request))
|
||||
|
||||
@login_required(login_url='/profile/login/')
|
||||
def user_profile_View(request):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user