Exemplo n.º 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 {}
Exemplo n.º 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()
     }
Exemplo n.º 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 {}
Exemplo n.º 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()
Exemplo n.º 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()
Exemplo n.º 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)