mirror of https://github.com/jumpserver/jumpserver
perf: 修改细节
parent
cef93abb2f
commit
24b1c87121
|
@ -1,11 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
|
||||
from rest_framework import viewsets
|
||||
|
||||
from users.models import User
|
||||
from common.permissions import IsValidUser
|
||||
from common.exceptions import JMSException
|
||||
from users.models import User
|
||||
from orgs.utils import get_org_by_id
|
||||
from .. import serializers
|
||||
|
||||
|
@ -20,7 +19,8 @@ class AssigneeViewSet(viewsets.ReadOnlyModelViewSet):
|
|||
org_id = self.request.query_params.get('org_id')
|
||||
org = get_org_by_id(org_id)
|
||||
if not org:
|
||||
raise JMSException('The organization `{}` does not exist'.format(org_id))
|
||||
error = ('The organization `{}` does not exist'.format(org_id))
|
||||
raise JMSException(error)
|
||||
return org
|
||||
|
||||
def get_queryset(self):
|
||||
|
|
|
@ -15,7 +15,7 @@ __all__ = ['CommentViewSet']
|
|||
|
||||
class CommentViewSet(mixins.CreateModelMixin, viewsets.ReadOnlyModelViewSet):
|
||||
serializer_class = serializers.CommentSerializer
|
||||
permission_classes = (IsSwagger| IsAssignee | IsApplicant,)
|
||||
permission_classes = (IsSwagger | IsAssignee | IsApplicant,)
|
||||
|
||||
@lazyproperty
|
||||
def ticket(self):
|
||||
|
|
|
@ -5,12 +5,13 @@ from rest_framework import viewsets
|
|||
from rest_framework.decorators import action
|
||||
from rest_framework.exceptions import MethodNotAllowed
|
||||
|
||||
from common.const.http import POST, PUT
|
||||
from common.mixins.api import CommonApiMixin
|
||||
from common.permissions import IsValidUser, IsOrgAdmin
|
||||
from common.const.http import POST, PUT
|
||||
from tickets import serializers, const
|
||||
from tickets.permissions.ticket import IsAssignee, NotClosed
|
||||
|
||||
from tickets import serializers
|
||||
from tickets.models import Ticket
|
||||
from tickets.permissions.ticket import IsAssignee, NotClosed
|
||||
|
||||
|
||||
__all__ = ['TicketViewSet']
|
||||
|
@ -67,7 +68,6 @@ class TicketViewSet(CommonApiMixin, viewsets.ModelViewSet):
|
|||
def get_dynamic_mapping_fields_mapping_rule(self):
|
||||
from tickets.serializers.ticket.meta import get_meta_field_mapping_rule_by_view
|
||||
meta_field_mapping_rule = get_meta_field_mapping_rule_by_view(self)
|
||||
fields_mapping_rule = {
|
||||
return {
|
||||
'meta': meta_field_mapping_rule,
|
||||
}
|
||||
return fields_mapping_rule
|
||||
|
|
|
@ -76,7 +76,12 @@ def migrate_tickets_fields_name(apps, schema_editor):
|
|||
ticket.type = migrate_field_type(ticket.type)
|
||||
ticket.meta = migrate_field_meta(ticket.type, ticket.meta)
|
||||
ticket.meta['body'] = ticket.body
|
||||
ticket.save()
|
||||
|
||||
fields = [
|
||||
'applicant', 'applicant_display', 'processor', 'processor_display',
|
||||
'assignees_display_new', 'action', 'type', 'meta'
|
||||
]
|
||||
ticket_model.origin_objects.bulk_update(tickets, fields)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
|
|
@ -135,7 +135,7 @@ class Ticket(TicketModelMixin, CommonModelMixin, OrgModelMixin):
|
|||
self.set_action_close()
|
||||
self.save()
|
||||
|
||||
#
|
||||
# ticket
|
||||
def has_assignee(self, assignee):
|
||||
return self.assignees.filter(id=assignee.id).exists()
|
||||
|
||||
|
|
|
@ -9,5 +9,4 @@ class IsAssignee(permissions.BasePermission):
|
|||
|
||||
class NotClosed(permissions.BasePermission):
|
||||
def has_object_permission(self, request, view, obj):
|
||||
return True
|
||||
return not obj.status_closed
|
||||
|
|
Loading…
Reference in New Issue