示例#1
0
    def add_row_perm(self, instance, perm):
        """
        Add permission 'perm' to user 'self' for object(s) instance.

        instance variable may be an object or a queryset.
        """
        from enhydris.permissions.models import Permission
        if type(instance).__name__ == 'QuerySet':
            for object in instance:
                if self.has_row_perm(object, perm, True):
                    pass
                permission = Permission()
                permission.content_object = object
                permission.user = self
                permission.name = perm
                permission.save()
        else:

            if self.has_row_perm(instance, perm, True):
                return False
            permission = Permission()
            permission.content_object = instance
            permission.user = self
            permission.name = perm
            permission.save()

        return True
示例#2
0
    def add_row_perm(self, instance, perm):
        """
        Add permission 'perm' to user 'self' for object(s) instance.

        instance variable may be an object or a queryset.
        """
        from enhydris.permissions.models import Permission
        if type(instance).__name__ == 'QuerySet':
            for object in instance:
                if self.has_row_perm(object, perm, True):
                    pass
                permission = Permission()
                permission.content_object = object
                permission.user = self
                permission.name = perm
                permission.save()
        else:

            if self.has_row_perm(instance, perm, True):
                return False
            permission = Permission()
            permission.content_object = instance
            permission.user = self
            permission.name = perm
            permission.save()

        return True
示例#3
0
 def add_row_perm(self, instance, perm):
     from enhydris.permissions.models import Permission
     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
示例#4
0
 def add_row_perm(self, instance, perm):
     from enhydris.permissions.models import Permission
     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