Exemple #1
0
    def notifications(self):
        """Returns a dict of dicts, in the following layout:
		{
			'reposname1': {'vcs': 'git', 'enabled': False},
			'repos2': {'vcs': 'svn', 'enabled': True}
		}
		"""
        from submin.models.permissions import list_by_user
        notifications = {}
        for perms in list_by_user(self._name):
            reposname = perms['repository']
            if reposname in notifications:
                continue

            if perms['permission'] not in ('r', 'rw'):
                continue

            notification = {
                'vcs': perms['vcs'],
                'enabled': storage.notification(self._id, reposname,
                                                perms['vcs'])
            }
            notifications[perms['repository']] = notification

        return notifications
    def list(session_user):
        repositories = Repository.list_all()

        if session_user.is_admin:
            return repositories

        filtered = []
        # because we iterate multiple times over perms, make it into a list, otherwise
        # it will be empty after the first time
        perms = list(permissions.list_by_user(session_user.name))
        for repository in repositories:
            name = repository['name']
            status = repository['status']
            vcs = repository['vcs']
            if _userHasReadPermissions(perms, name, vcs):
                filtered.append({"name": name, "status": status, "vcs": vcs})

        return filtered
Exemple #3
0
	def list(session_user):
		repositories = Repository.list_all()

		if session_user.is_admin:
			return repositories

		filtered = []
		# because we iterate multiple times over perms, make it into a list, otherwise
		# it will be empty after the first time
		perms = list(permissions.list_by_user(session_user.name))
		for repository in repositories:
			name = repository['name']
			status = repository['status']
			vcs = repository['vcs']
			if _userHasReadPermissions(perms, name, vcs):
				filtered.append({"name": name, "status": status, "vcs": vcs})

		return filtered
Exemple #4
0
    def show(self, req, path, localvars):
        if len(path) < 1:
            return ErrorResponse('Invalid path', request=req)

        is_admin = req.session['user']['is_admin']
        if not is_admin and path[0] != req.session['user']['name']:
            raise Unauthorized('Permission denied to view this user')

        try:
            u = user.User(path[0])
        except (IndexError, UnknownUserError):
            return ErrorResponse('This user does not exist.', request=req)

        localvars['user'] = u
        if 'change_password_hint' in req.session:
            localvars['change_password_hint'] = True

        p = list(permissions.list_by_user(u.name))
        localvars['permissions'] = p
        localvars['enabled_git'] = 'git' in options.value('vcs_plugins', '')
        localvars['external'] = u.is_external

        formatted = evaluate_main('users.html', localvars, request=req)
        return Response(formatted)
Exemple #5
0
	def notifications(self):
		"""Returns a dict of dicts, in the following layout:
		{
			'reposname1': {'vcs': 'git', 'enabled': False},
			'repos2': {'vcs': 'svn', 'enabled': True}
		}
		"""
		from submin.models.permissions import list_by_user
		notifications = {}
		for perms in list_by_user(self._name):
			reposname = perms['repository']
			if reposname in notifications:
				continue

			if perms['permission'] not in ('r', 'rw'):
				continue

			notification = {
				'vcs': perms['vcs'],
				'enabled': storage.notification(self._id, reposname, perms['vcs'])
			}
			notifications[perms['repository']] = notification

		return notifications
def userHasReadPermissions(username, reposname, vcs):
    perms = permissions.list_by_user(username)
    return _userHasReadPermissions(perms, reposname, vcs)
Exemple #7
0
def userHasReadPermissions(username, reposname, vcs):
	perms = permissions.list_by_user(username)
	return _userHasReadPermissions(perms, reposname, vcs)