This commit is contained in:
javad committed 2024-01-22 13:01:42 +03:30
commit 89a5d70512
284 files changed
+8364

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
from apps.ticket.models import Ticket as TicketModel, TicketComment as TicketCommentModel
from apps.cuser.models import CuserRole as CuserRoleModel
from rest_framework import exceptions
def list_ticket(cuser_role_uuid: str, workspace_uuid: str) -> TicketModel:
try:
role_type_name = CuserRoleModel.objects.get(uuid=cuser_role_uuid).role_type.role_name_en
if role_type_name == 'workspace_operator':
tickets = TicketModel.objects.filter(sys_ws__uuid=workspace_uuid).order_by('-created_at')
else:
tickets = TicketModel.objects.filter(cuser_role__uuid=cuser_role_uuid, sys_ws__uuid=workspace_uuid).order_by('-created_at')
return tickets
except Exception as exp:
message = f'Error Fetching List tickets: {exp}'
raise exceptions.ValidationError({'error': message})
def retrieve_ticket_comments(ticket_id: int, cuser_role_uuid: str, workspace_uuid: str) -> TicketCommentModel:
try:
role_type_name = CuserRoleModel.objects.get(uuid=cuser_role_uuid).role_type.role_name_en
if role_type_name == 'workspace_operator':
ticket = TicketModel.objects.get(id=ticket_id, sys_ws__uuid=workspace_uuid)
else:
ticket = TicketModel.objects.get(id=ticket_id, cuser_role__uuid=cuser_role_uuid, sys_ws__uuid=workspace_uuid)
ticket_comments = TicketCommentModel.objects.filter(ticket=ticket, sys_ws__uuid=workspace_uuid)
return ticket_comments
except Exception as exp:
message = f'Error Fetching List ticket comments: {exp}'
raise exceptions.ValidationError({'error': message})