コード例 #1
0
ファイル: user.py プロジェクト: msabramo/kallithea
    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
ファイル: user.py プロジェクト: NexMirror/Kallithea
    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
ファイル: user.py プロジェクト: t-kenji/kallithea-mirror
    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
ファイル: permission.py プロジェクト: msabramo/kallithea
 def _make_perm(perm):
     new_perm = UserToPerm()
     new_perm.user = user
     new_perm.permission = Permission.get_by_key(perm)
     return new_perm
コード例 #7
0
ファイル: permission.py プロジェクト: msabramo/kallithea
 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