Example #1
0
    def get_queryset(self, ignore_filters=False):

        # raise exception if no permission
        check_permission(self.model, 'view')

        queryset = super().get_queryset()
        if ignore_filters is False:
            queryset = queryset.filter(self.get_filter())
        return queryset
Example #2
0
    def save(self,
             force_insert=False,
             force_update=False,
             using=None,
             update_fields=None,
             *args,
             **kwargs):

        if self.pk is None:
            check_permission(self, 'add')
        else:
            check_permission(self, 'change')

        super().save(force_insert=force_insert,
                     force_update=force_update,
                     using=using,
                     update_fields=update_fields)
Example #3
0
    def delete(self, using=None, keep_parents=False, *args, **kwargs):

        check_permission(self, 'delete')

        super().delete(using=using, keep_parents=keep_parents)
Example #4
0
 def update(self, **kwargs):
     # raise exception if no permission
     check_permission(self.model, 'change')
     return super().update(**kwargs)
Example #5
0
 def bulk_update(self, objs, fields, batch_size=None):
     # raise exception if no permission
     check_permission(self.model, 'change')
     return super().update(objs, fields, batch_size=batch_size)
Example #6
0
 def bulk_create(self, objs, batch_size=None, ignore_conflicts=False):
     # raise exception if no permission
     check_permission(self.model, 'add')
     return super().bulk_create(objs,
                                batch_size=batch_size,
                                ignore_conflicts=ignore_conflicts)
Example #7
0
 def delete(self):
     # raise exception if no permission
     check_permission(self.model, 'delete')
     return super().delete()