Exemple #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
Exemple #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
Exemple #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
Exemple #4
0
 def _make_perm(perm):
     new_perm = UserToPerm()
     new_perm.user = user
     new_perm.permission = Permission.get_by_key(perm)
     return new_perm
Exemple #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
Exemple #6
0
 def _make_perm(perm):
     new_perm = UserToPerm()
     new_perm.user = user
     new_perm.permission = Permission.get_by_key(perm)
     return new_perm
Exemple #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