コード例 #1
0
 def get_permissions(self):
     # we need to use AllowAny() / IsAuthenticated() to instantiate an object
     # rather than using AllowAny / IsAuthenticated such class names
     if self.action == 'create':
         return [IsAuthenticated()]
     if self.action in ['destroy', 'update']:
         return [IsAuthenticated(), IsObjectOwner()]
     return [AllowAny()]
コード例 #2
0
ファイル: views.py プロジェクト: samguan2020/my_twitter
 def get_permissions(self):
     # 注意要加用 AllowAny() / IsAuthenticated() 实例化出对象
     # 而不是 AllowAny / IsAuthenticated 这样只是一个类名
     if self.action == 'create':
         return [IsAuthenticated()]
     if self.action in ['destroy', 'update']:
         return [IsAuthenticated(), IsObjectOwner()]
     return [AllowAny()]
コード例 #3
0
 def get_permissions(self):
     # AllowAny() / IsAuthenticated() generate an object instance
     # not AllowAny / IsAuthenticated, this is just a class name
     if self.action == 'create':
         return [IsAuthenticated()]
     if self.action in ['destroy', 'update']:
         return [IsAuthenticated(), IsObjectOwner()]
     return [AllowAny()]
コード例 #4
0
 def get_permissions(self):
     # To instantiate an object, parens are needed
     # AllowAny() / IsAuthenticated()
     # not just class names like  AllowAny / IsAuthenticated
     if self.action == 'create':
         return [IsAuthenticated()]
     if self.action in ['update', 'destroy']:
         return [IsAuthenticated(), IsObjectOwner()]
     return [AllowAny()]
コード例 #5
0
ファイル: views.py プロジェクト: wendyfly/django-twitter
 def get_permissions(self):
     # 注意要加用 AllowAny() / IsAuthenticated() 实例化出对象
     # 而不是 AllowAny / IsAuthenticated 这样只是一个类名
     if self.action == 'create':
         return [IsAuthenticated()]
     if self.action in ['update', 'destroy']:
         # note: you need to verify you have login firstly
         return [IsAuthenticated(), IsObjectOwner()]
     return [AllowAny()]
コード例 #6
0
 def get_permissions(self):
     # return instance of AllowAny() or IsAuthenticated()
     if self.action == 'create':
         return [IsAuthenticated()]
     if self.action in [
             'destroy',
             'update',
     ]:
         return [IsAuthenticated(), IsObjectOwner()]
     return [AllowAny()]
コード例 #7
0
ファイル: views.py プロジェクト: bz866/django-twitter
 def get_permissions(self):
     if self.action == 'create':
         return [
             IsAuthenticated(),
         ]
     elif self.action in ['update', 'destroy']:
         return [
             IsAuthenticated(),
             IsObjectOwner(),
         ]
     elif self.action == 'list':
         return [
             IsAuthenticated(),
         ]
     return [
         AllowAny(),
     ]