diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index 4c7905b4..bb768c73 100644 Binary files a/osinaweb/db.sqlite3 and b/osinaweb/db.sqlite3 differ diff --git a/osinaweb/static/js/tickets/tickets-room.js b/osinaweb/static/js/tickets/tickets-room.js index 19b3b96f..206600fd 100644 --- a/osinaweb/static/js/tickets/tickets-room.js +++ b/osinaweb/static/js/tickets/tickets-room.js @@ -63,7 +63,7 @@ function app(socket) { function initializeWebSocket() { const ticketId = document.getElementById('ticketId').textContent.trim(); - const wsUrl = `ws://${window.location.host}/ws/ticketroom/${ticketId}/`; + const wsUrl = `wss://${window.location.host}/ws/ticketroom/${ticketId}/`; const socket = new WebSocket(wsUrl); socket.onopen = () => { diff --git a/osinaweb/support/__pycache__/urls.cpython-310.pyc b/osinaweb/support/__pycache__/urls.cpython-310.pyc index de29f7e6..2e10f86e 100644 Binary files a/osinaweb/support/__pycache__/urls.cpython-310.pyc and b/osinaweb/support/__pycache__/urls.cpython-310.pyc differ diff --git a/osinaweb/support/__pycache__/views.cpython-310.pyc b/osinaweb/support/__pycache__/views.cpython-310.pyc index 0304ad4b..228ae55e 100644 Binary files a/osinaweb/support/__pycache__/views.cpython-310.pyc and b/osinaweb/support/__pycache__/views.cpython-310.pyc differ diff --git a/osinaweb/support/add/__pycache__/urls.cpython-310.pyc b/osinaweb/support/add/__pycache__/urls.cpython-310.pyc new file mode 100644 index 00000000..6932733b Binary files /dev/null and b/osinaweb/support/add/__pycache__/urls.cpython-310.pyc differ diff --git a/osinaweb/support/add/__pycache__/views.cpython-310.pyc b/osinaweb/support/add/__pycache__/views.cpython-310.pyc new file mode 100644 index 00000000..7edaf795 Binary files /dev/null and b/osinaweb/support/add/__pycache__/views.cpython-310.pyc differ diff --git a/osinaweb/support/add/urls.py b/osinaweb/support/add/urls.py new file mode 100644 index 00000000..1ada3519 --- /dev/null +++ b/osinaweb/support/add/urls.py @@ -0,0 +1,10 @@ +from django.urls import path +from . import views +from django.conf.urls.static import static +from django.conf import settings + +urlpatterns = [ + path('tickets//department/', views.add_ticket_department_modal, name='addticketdepartmentmodal'), + path('tickets//member/', views.add_ticket_member_modal, name='addticketmembermodal'), +] + diff --git a/osinaweb/support/add/views.py b/osinaweb/support/add/views.py new file mode 100644 index 00000000..3749dd9a --- /dev/null +++ b/osinaweb/support/add/views.py @@ -0,0 +1,27 @@ + + +from django.shortcuts import render, get_object_or_404 +from support.models import * +from osinacore.decorators import * + + + +def add_ticket_department_modal(request): + + context = { + + } + + return render(request, 'add_templates/add-ticket-department-modal.html', context) + + + + +def add_ticket_member_modal(request): + + context = { + + } + + return render(request, 'add_templates/add-ticket-member-modal.html', context) + diff --git a/osinaweb/support/urls.py b/osinaweb/support/urls.py index d6d9e493..50316e7d 100644 --- a/osinaweb/support/urls.py +++ b/osinaweb/support/urls.py @@ -20,11 +20,11 @@ from django.conf.urls.static import static from django.conf import settings urlpatterns = [ + path('add/', include('support.add.urls')), path('tickets//', views.ticket_room, name='ticketroom'), path('tickets//settings/', views.ticket_settings, name='ticketsettings'), - path('add-ticket-department', views.add_ticket_department_modal, name='addticketdepartmentmodal'), - path('add-ticket-member', views.add_ticket_member_modal, name='addticketmembermodal'), + ] urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ No newline at end of file diff --git a/osinaweb/support/views.py b/osinaweb/support/views.py index 19b0911c..22fe05ca 100644 --- a/osinaweb/support/views.py +++ b/osinaweb/support/views.py @@ -2,15 +2,30 @@ from django.shortcuts import render, get_object_or_404 from .models import * from .decorators import * from osinacore.decorators import * +from django.http import Http404 # Create your views here. -@ticket_member_required def ticket_room(request, ticket_number): - if hasattr(request.user, 'customerprofile'): + ticket = get_object_or_404(Ticket, ticket_number=ticket_number) + + if hasattr(request.user, 'customerprofile') and request.user.customerprofile == ticket.customer: base_template = "customer_main.html" - else: + 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: + base_template = "main.html" + else: + raise Http404("You are not authorized to view this ticket.") + elif request.user.is_superuser: base_template = "main.html" - ticket = get_object_or_404(Ticket, ticket_number=ticket_number) + else: + raise Http404("You are not authorized to view this ticket.") + + ticket_updates = TicketUpdate.objects.filter(ticket=ticket).order_by('id') for update in TicketUpdate.objects.filter(ticket=ticket).exclude(added_by=request.user).order_by('id'): if not TicketRead.objects.filter(ticket_update=update, user=request.user).exists(): @@ -79,23 +94,3 @@ def ticket_settings(request, ticket_number): -@ticket_member_required -def add_ticket_department_modal(request): - - context = { - - } - - return render(request, 'add_templates/add-ticket-department-modal.html', context) - - - -@ticket_member_required -def add_ticket_member_modal(request): - - context = { - - } - - return render(request, 'add_templates/add-ticket-member-modal.html', context) -