def add_row_perm(self, instance, perm): if self.has_row_perm(instance, perm): return False permission = Permission() permission.content_object = instance permission.group = self permission.name = perm permission.save() return True
def add_row_perm(self, instance, perm): if type(instance).__name__ == 'QuerySet': for object in instance: if self.has_row_perm(object, perm): pass permission = Permission() permission.content_object = object permission.user = self permission.name = perm permission.save() else: if self.has_row_perm(instance, perm): return False permission = Permission() permission.content_object = instance permission.group = self permission.name = perm permission.save() return True