0.1.19
support tickets routines
This commit is contained in:
@@ -40,14 +40,23 @@ def support_tickets_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
from ChatServiceApp.models import MsgGroup
|
||||
tickets = MsgGroup.objects.filter(enable=True, owner=request.user)
|
||||
if request.user.is_staff:
|
||||
from ChatServiceApp.funcs import get_tickets_for_manager, get_tickets_wo_manager
|
||||
Dict = {
|
||||
'tickets_wo_manager': get_tickets_wo_manager(),
|
||||
'tickets_for_manager': get_tickets_for_manager(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)
|
||||
|
||||
Dict = {
|
||||
'tickets': tickets
|
||||
}
|
||||
Dict = {
|
||||
'tickets': tickets
|
||||
}
|
||||
tpl_name = 'blocks/profile/b_support_tickets.html'
|
||||
|
||||
html = render_to_string('blocks/profile/b_support_tickets.html', Dict, request=request)
|
||||
html = render_to_string(tpl_name, Dict, request=request)
|
||||
return JsonResponse({'html': html}, status=200)
|
||||
|
||||
|
||||
|
||||
13
ChatServiceApp/funcs.py
Normal file
13
ChatServiceApp/funcs.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from .models import *
|
||||
|
||||
def get_tickets_wo_manager():
|
||||
|
||||
tickets = MsgGroup.objects.filter(enable=True, manager=None)
|
||||
|
||||
return tickets
|
||||
|
||||
def get_tickets_for_manager(user):
|
||||
|
||||
tickets = MsgGroup.objects.filter(enable=True, manager=user)
|
||||
|
||||
return tickets
|
||||
@@ -9,6 +9,5 @@ from RoutesApp.js_views import new_route_view_ajax
|
||||
urlpatterns = [
|
||||
path('support_create_ticket_form/', support_create_ticket_form_ajax, name='support_create_ticket_form_ajax'),
|
||||
path('create_ticket/', create_ticket_ajax, name='create_ticket_ajax'),
|
||||
# path('create_/', registration_ajax, name='registration_ajax'),
|
||||
|
||||
path('support_show_chat_by_ticket/', support_show_chat_by_ticket_ajax, name='support_show_chat_by_ticket_ajax'),
|
||||
]
|
||||
@@ -11,10 +11,33 @@ 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 *
|
||||
import json
|
||||
|
||||
@login_required(login_url='/profile/login/')
|
||||
def support_show_chat_by_ticket_ajax(request):
|
||||
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
try:
|
||||
|
||||
data = json.loads(request.body)
|
||||
|
||||
obj = MsgGroup.objects.get(id=data['ticket_id'])
|
||||
|
||||
Dict = {
|
||||
'ticket': obj
|
||||
}
|
||||
|
||||
tpl_name = 'blocks/profile/b_support_chat.html'
|
||||
|
||||
html = render_to_string(tpl_name, Dict, request=request)
|
||||
return JsonResponse({'html': html}, status=200)
|
||||
|
||||
except Exception as e:
|
||||
msg = f'support_show_chat_by_ticket_ajax Error = {str(e)}'
|
||||
return JsonResponse({'error': msg}, status=400)
|
||||
|
||||
|
||||
@login_required(login_url='/profile/login/')
|
||||
@@ -24,11 +47,13 @@ def support_create_ticket_form_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
|
||||
Dict = {
|
||||
'form': TicketForm()
|
||||
}
|
||||
tpl_name = 'blocks/profile/b_create_ticket.html'
|
||||
|
||||
html = render_to_string('blocks/profile/b_create_ticket.html', Dict, request=request)
|
||||
html = render_to_string(tpl_name, Dict, request=request)
|
||||
return JsonResponse({'html': html}, status=200)
|
||||
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ def get_routes_ajax(request):
|
||||
|
||||
|
||||
|
||||
def create_or_change_route_ajax(request, route_id):
|
||||
def create_or_change_route_ajax(request, route_id=None):
|
||||
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
@@ -5,39 +5,54 @@
|
||||
|
||||
<div class="container-messenger">
|
||||
<div class="name_ticket">
|
||||
<span>Название темы</span>
|
||||
<span>{{ ticket.name }}</span>
|
||||
</div>
|
||||
<div class="block-chat">
|
||||
<div class="container-header-chat">
|
||||
<div class="header-chat-left-part">
|
||||
<img class="chat-avatar" src="{% static "delete_later/Avatar.png" %}">
|
||||
<span class="chat-username">Сергейко Сергей</span>
|
||||
{% if user.is_staff or ticket.manager %}
|
||||
<div class="container-header-chat">
|
||||
<div class="header-chat-left-part">
|
||||
<img class="chat-avatar" src="{% static "delete_later/Avatar.png" %}">
|
||||
<span class="chat-username">{{ ticket.manager.last_name }} {{ ticket.manager.first_name }}</span>
|
||||
</div>
|
||||
<div class="header-chat-right-part">
|
||||
<img class="header-icons-right-part-padding" src="{% static "img/svg/phone.svg" %}">
|
||||
<img class="header-icons-right-part-padding" src="{% static "img/svg/info.svg" %}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="header-chat-right-part">
|
||||
<img class="header-icons-right-part-padding" src="{% static "img/svg/phone.svg" %}">
|
||||
<img class="header-icons-right-part-padding" src="{% static "img/svg/info.svg" %}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-messages">
|
||||
|
||||
{% include "widgets/w_message.html" %}
|
||||
|
||||
</div>
|
||||
<div class="footer-chat">
|
||||
<div class="left-part-block-enter-message">
|
||||
<input class="enter-message-inp" placeholder="Отправить сообщение">
|
||||
<div class="container-messages">
|
||||
{% include "widgets/w_message.html" %}
|
||||
</div>
|
||||
<div class="right-part-block-enter-message">
|
||||
<button class="attach-file-btn-message" onclick="attachFilemeassge()"></button>
|
||||
<button class="send-message"></button>
|
||||
<div class="footer-chat">
|
||||
<div class="left-part-block-enter-message">
|
||||
<input class="enter-message-inp" placeholder="Отправить сообщение">
|
||||
</div>
|
||||
<div class="right-part-block-enter-message">
|
||||
<button class="attach-file-btn-message" onclick="attachFilemeassge()"></button>
|
||||
<button class="send-message"></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="block-list-of-users">
|
||||
<span class="title-list-of-users">Пользователи</span>
|
||||
<div class="insert_users">
|
||||
{% include "widgets/w_tab_user.html" %}
|
||||
</div>
|
||||
{% if user.is_staff %}
|
||||
<div class="block-list-of-users">
|
||||
<span class="title-list-of-users">Неразобранные тикеты</span>
|
||||
<div class="insert_users">
|
||||
{% if tickets_wo_manager %}
|
||||
{% for ticket in tickets_wo_manager %}
|
||||
{% include "widgets/w_tab_user.html" %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="block-list-of-users">
|
||||
<span class="title-list-of-users">Тикеты в работе</span>
|
||||
{% if tickets_for_manager %}
|
||||
{% for ticket in tickets_for_manager %}
|
||||
{% include "widgets/w_tab_user.html" %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
@@ -6,8 +6,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="center-part-tab-user">
|
||||
<span class="user_name_messenger">Сергейко Сергей</span>
|
||||
<span class="last-message-messenger-user-tab">Текст сообщения</span>
|
||||
<span class="user_name_messenger">{{ ticket.owner.last_name }} {{ ticket.owner.first_name }}</span>
|
||||
<span class="last-message-messenger-user-tab">{{ ticket.name }}</span>
|
||||
</div>
|
||||
<div class="right-part-tab-user">
|
||||
<div class="cost-messages-in-user-tab-messenger"></div>
|
||||
|
||||
Reference in New Issue
Block a user