perf(application): 优化一些小细节

This commit is contained in:
Bai
2020-10-29 15:46:32 +08:00
committed by 老广
parent 4a09dc6e3e
commit c9065fd96e
11 changed files with 33 additions and 29 deletions

View File

@@ -27,8 +27,14 @@ class RemoteAppConnectionInfoApi(generics.RetrieveAPIView):
permission_classes = (IsAppUser, )
serializer_class = RemoteAppConnectionInfoSerializer
@staticmethod
def check_category_allowed(obj):
if not obj.category_is_remote_app:
raise JMSException(
'The request instance(`{}`) is not of category `remote_app`'.format(obj.category)
)
def get_object(self):
obj = super().get_object()
if not models.Category.is_remote_app(obj.category):
raise JMSException('The request instance is not of category `remote_app`')
self.check_category_allowed(obj)
return obj