Пример #1
0
 def get_context_data(self, **kwargs):
     if not TagAccess(self.request.user, None).create():
         raise BridgeException(_("You don't have an access to upload tags"))
     if 'file' not in self.request.FILES:
         raise BridgeException()
     CreateTagsFromFile(self.request.user, self.request.FILES['file'],
                        self.kwargs['type'])
     return {}
Пример #2
0
 def get_context_data(self, **kwargs):
     return {
         'title':
         _('Safe tags')
         if self.kwargs['type'] == 'safe' else _('Unsafe tags'),
         'tags_type':
         self.kwargs['type'],
         'tags':
         GetTagsData(self.kwargs['type'],
                     user=self.request.user).table.data,
         'can_create':
         TagAccess(self.request.user, None).create()
     }
Пример #3
0
 def get_context_data(self, **kwargs):
     if not TagAccess(self.request.user, self.object).delete():
         raise BridgeException(
             _("You don't have an access to remove this tag"))
     self.object.delete()
     return {}
Пример #4
0
 def perform_destroy(self, instance):
     if not TagAccess(self.request.user, instance).delete:
         raise exceptions.PermissionDenied(
             _("You don't have an access to delete this tag"))
     super().perform_destroy(instance)
     UpdateUnsafeMarksTags()
Пример #5
0
 def perform_update(self, serializer):
     if not TagAccess(self.request.user, serializer.instance).edit:
         raise exceptions.PermissionDenied(
             _("You don't have an access to edit this tag"))
     serializer.save(author=self.request.user)
     UpdateUnsafeMarksTags()
Пример #6
0
 def perform_create(self, serializer):
     parent = serializer.validated_data.get('parent')
     if not TagAccess(self.request.user, parent).create:
         raise exceptions.PermissionDenied(
             _("You don't have an access to create this tag"))
     serializer.save(author=self.request.user)