0.1.19
support tickets routines
This commit is contained in:
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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user