from django.urls import path

from tickets.views import *
from tickets.api import views as apiviews


app_name = "tickets"

urlpatterns = [
    path("", TicketListView.as_view(), name="ticket_list_list"),
    path("search/", search, name="search"),
    path("my_tickets/", ticket_list_detail, {"my_tickets": True}, name="my_tickets"),
    path("assignments/", ticket_list_detail, {"assignments": True}, name="assignments"),

    path("<int:pk>/", ticket_list_detail, name="ticket_list_detail"),
    path("<int:pk>/ticket_create/", TicketCreateView.as_view(), name="ticket_create"),
    
    path("ticket/<int:pk>/", TicketDetailView.as_view(), name="ticket_detail"),
    path("ticket/<int:pk>/edit", TicketEditView.as_view(), name="ticket_edit"),
    path("ticket/<int:pk>/delete", TicketDeleteView.as_view(), name="ticket_delete"),
    path("attachment/remove/<int:attachment_id>/", remove_attachment, name="remove_attachment"),

    # API
    path("api/ticket_list/", apiviews.TicketListListAPIView.as_view()),
    path("api/ticket_list/my/", apiviews.TicketListDetailAPIView.as_view(), {"my": True}),
    path("api/ticket_list/<int:pk>", apiviews.TicketListDetailAPIView.as_view()),
    path("api/ticket/", apiviews.TicketCreateAPIView.as_view()),
    path("api/ticket/<int:pk>", apiviews.TicketDetailAPIView.as_view()),
    path("api/ticket/<int:pk>/status", apiviews.TicketStatusAPIView.as_view()),
]