emile 10 months ago
parent ab4c829792
commit ca53009a9d

Binary file not shown.

@ -12,7 +12,7 @@
<!-- TICKETS -->
<div class="w-full h-fit bg-white p-3 rounded-md shadow-md">
<div class="w-full h-fit bg-white p-3 rounded-md shadow-md {% if not open_tickets %} hidden {% endif %}" id="tickets-div">
<div class="overflow-x-auto border border-gray-300 rounded-md tableContainer" id="openTickets">
<table class="min-w-full divide-y">
<!-- TABLE HEADER -->
@ -301,6 +301,10 @@
newTicketsSocket.onmessage = function(e) {
const data = JSON.parse(e.data);
if (data.event_type === 'new_ticket') {
const ticketsDiv = document.getElementById('tickets-div');
if (ticketsDiv.classList.contains('hidden')) {
ticketsDiv.classList.remove('hidden');
}
const html = data.html;
document.getElementById('tickets').insertAdjacentHTML('afterbegin', html);
}
@ -325,6 +329,11 @@
newTicketUpdatesSocket.onmessage = function(e) {
const data = JSON.parse(e.data);
if (data.event_type === 'new_ticket_update_group') {
const ticketsDiv = document.getElementById('tickets-div');
if (ticketsDiv.classList.contains('hidden')) {
ticketsDiv.classList.remove('hidden');
}
const html = data.html;
const ticketId = data.ticket_id;
console.log(ticketId);

@ -211,21 +211,26 @@ class NewTicketConsumer(WebsocketConsumer):
def new_ticket_event(self, event):
ticket_id = event['ticket_id']
ticket = Ticket.objects.get(id=ticket_id)
is_staff_or_superuser = (
is_ticketstaff_member = (
hasattr(self.user, 'staffprofile') and
(self.user.staffprofile in ticket.get_all_ticket_staff() or self.user.is_superuser)
)
if is_staff_or_superuser:
is_ticket_customer = (
hasattr(self.user, 'customerprofile') and
(self.user.customerprofile == ticket.customer))
if is_ticketstaff_member or is_ticket_customer:
context = {'ticket': ticket, 'new': True}
html = render_to_string("details_templates/partials/ticket-display.html", context)
if is_ticketstaff_member:
html = render_to_string("details_templates/partials/staff-ticket-display.html", context)
else:
html = render_to_string("details_templates/partials/customer-ticket-display.html", context)
self.send(text_data=json.dumps({
'event_type': 'new_ticket',
'html': html
'html': html,
'ticket_id': ticket_id
}))
class NewTicketUpdateConsumer(WebsocketConsumer):
def connect(self):
self.user = self.scope['user']

Loading…
Cancel
Save