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 {}
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() }
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 {}
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()
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()
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)