mirror of https://github.com/jumpserver/jumpserver
commit
7578bda588
|
@ -206,10 +206,12 @@ class Ticket(CommonModelMixin, OrgModelMixin):
|
|||
self.save()
|
||||
post_change_ticket_action.send(sender=self.__class__, ticket=self, action=action)
|
||||
|
||||
# ticket
|
||||
def has_assignee(self, assignee):
|
||||
def has_current_assignee(self, assignee):
|
||||
return self.ticket_steps.filter(ticket_assignees__assignee=assignee, level=self.approval_step).exists()
|
||||
|
||||
def has_all_assignee(self, assignee):
|
||||
return self.ticket_steps.filter(ticket_assignees__assignee=assignee).exists()
|
||||
|
||||
@classmethod
|
||||
def get_user_related_tickets(cls, user):
|
||||
queries = Q(applicant=user) | Q(ticket_steps__ticket_assignees__assignee=user)
|
||||
|
|
|
@ -15,4 +15,7 @@ class IsApplicant(permissions.BasePermission):
|
|||
|
||||
class IsAssignee(permissions.BasePermission):
|
||||
def has_permission(self, request, view):
|
||||
return view.ticket.has_assignee(request.user)
|
||||
if view.action == 'list':
|
||||
return view.ticket.has_all_assignee(request.user)
|
||||
elif view.action == 'create':
|
||||
return view.ticket.has_current_assignee(request.user)
|
||||
|
|
|
@ -3,7 +3,7 @@ from rest_framework import permissions
|
|||
|
||||
class IsAssignee(permissions.BasePermission):
|
||||
def has_object_permission(self, request, view, obj):
|
||||
return obj.has_assignee(request.user)
|
||||
return obj.has_current_assignee(request.user)
|
||||
|
||||
|
||||
class IsApplicant(permissions.BasePermission):
|
||||
|
|
Loading…
Reference in New Issue