|
|
|
@ -7,21 +7,13 @@ from django.http import Http404
|
|
|
|
|
# Create your views here.
|
|
|
|
|
def ticket_room(request, ticket_number):
|
|
|
|
|
ticket = get_object_or_404(Ticket, ticket_number=ticket_number)
|
|
|
|
|
|
|
|
|
|
print(ticket.get_all_ticket_staff())
|
|
|
|
|
if request.user.is_superuser:
|
|
|
|
|
base_template = "main.html"
|
|
|
|
|
elif hasattr(request.user, 'customerprofile') and request.user.customerprofile == ticket.customer:
|
|
|
|
|
base_template = "customer_main.html"
|
|
|
|
|
elif hasattr(request.user, 'staffprofile'):
|
|
|
|
|
latest_department = TicketDepartment.objects.filter(ticket=ticket).order_by('-date_added').first()
|
|
|
|
|
ticket_department_staffs = latest_department.department.get_staff()
|
|
|
|
|
ticket_staffs = TicketStaff.objects.filter(ticket=ticket)
|
|
|
|
|
if any(request.user.staffprofile == staff.staff for staff in ticket_staffs):
|
|
|
|
|
base_template = "main.html"
|
|
|
|
|
elif request.user.staffprofile in ticket_department_staffs:
|
|
|
|
|
elif hasattr(request.user, 'staffprofile') and request.user.staffprofile in ticket.get_all_ticket_staff():
|
|
|
|
|
base_template = "main.html"
|
|
|
|
|
else:
|
|
|
|
|
raise Http404("You are not authorized to view this ticket.")
|
|
|
|
|
else:
|
|
|
|
|
raise Http404("You are not authorized to view this ticket.")
|
|
|
|
|
|
|
|
|
@ -33,7 +25,7 @@ def ticket_room(request, ticket_number):
|
|
|
|
|
|
|
|
|
|
last_ticket_status = TicketStatus.objects.filter(ticket=ticket).last()
|
|
|
|
|
|
|
|
|
|
connections = TicketConnection.objects.all().order_by('-id')
|
|
|
|
|
connections = TicketConnection.objects.filter(terminated=False).order_by('-id')
|
|
|
|
|
|
|
|
|
|
context = {
|
|
|
|
|
'base_template': base_template,
|
|
|
|
|