示例#1
0
    def grant_perm(self, user, perm):
        """
        Grant user global permissions

        :param user:
        :param perm:
        """
        user = self._get_user(user)
        perm = self._get_perm(perm)
        # if this permission is already granted skip it
        _perm = UserToPerm.query()\
            .filter(UserToPerm.user == user)\
            .filter(UserToPerm.permission == perm)\
            .scalar()
        if _perm:
            return
        new = UserToPerm()
        new.user = user
        new.permission = perm
        self.sa.add(new)
        return new
示例#2
0
    def grant_perm(self, user, perm):
        """
        Grant user global permissions

        :param user:
        :param perm:
        """
        user = User.guess_instance(user)
        perm = Permission.guess_instance(perm)
        # if this permission is already granted skip it
        _perm = UserToPerm.query() \
            .filter(UserToPerm.user == user) \
            .filter(UserToPerm.permission == perm) \
            .scalar()
        if _perm:
            return
        new = UserToPerm()
        new.user = user
        new.permission = perm
        Session().add(new)
        return new
示例#3
0
    def grant_perm(self, user, perm):
        """
        Grant user global permissions

        :param user:
        :param perm:
        """
        user = User.guess_instance(user)
        perm = Permission.guess_instance(perm)
        # if this permission is already granted skip it
        _perm = UserToPerm.query() \
            .filter(UserToPerm.user == user) \
            .filter(UserToPerm.permission == perm) \
            .scalar()
        if _perm:
            return
        new = UserToPerm()
        new.user = user
        new.permission = perm
        Session().add(new)
        return new
示例#4
0
 def _make_perm(perm):
     new_perm = UserToPerm()
     new_perm.user = user
     new_perm.permission = Permission.get_by_key(perm)
     return new_perm
示例#5
0
 def _make_new(usr, perm_name):
     log.debug('Creating new permission:%s', perm_name)
     new = UserToPerm()
     new.user = usr
     new.permission = Permission.get_by_key(perm_name)
     return new
示例#6
0
 def _make_perm(perm):
     new_perm = UserToPerm()
     new_perm.user = user
     new_perm.permission = Permission.get_by_key(perm)
     return new_perm
示例#7
0
 def _make_new(usr, perm_name):
     log.debug('Creating new permission:%s' % (perm_name))
     new = UserToPerm()
     new.user = usr
     new.permission = Permission.get_by_key(perm_name)
     return new