Esempio n. 1
0
        def wrapper(project_url, *args, **kwargs):
            if isinstance(project_url, pillarsdk.Resource):
                # This is already a resource, so this call probably is from one
                # view to another. Assume the caller knows what he's doing and
                # just pass everything along.
                return wrapped(project_url, *args, **kwargs)

            api = pillar_api()

            project = pillarsdk.Project.find_by_url(
                project_url, {'projection': projections}, api=api)

            is_flamenco = current_flamenco.is_flamenco_project(project)
            if not is_flamenco:
                return error_project_not_setup_for_flamenco()

            session['flamenco_last_project'] = project.to_dict()

            project_id = bson.ObjectId(project['_id'])
            auth = current_flamenco.auth
            if not auth.current_user_may(action, project_id):
                log.info('Denying user %s access %s to Flamenco on project %s',
                         flask_login.current_user, action, project_id)
                return error_project_not_available()

            if extension_props:
                pprops = project.extension_props.flamenco
                return wrapped(project, pprops, *args, **kwargs)
            return wrapped(project, *args, **kwargs)
Esempio n. 2
0
        def wrapper(project_url, *args, **kwargs):
            if isinstance(project_url, pillarsdk.Resource):
                # This is already a resource, so this call probably is from one
                # view to another. Assume the caller knows what he's doing and
                # just pass everything along.
                return wrapped(project_url, *args, **kwargs)

            api = pillar_api()

            project = pillarsdk.Project.find_by_url(
                project_url,
                {'projection': projections},
                api=api)

            is_flamenco = current_flamenco.is_flamenco_project(project)
            if not is_flamenco:
                return error_project_not_setup_for_flamenco(project)

            session['flamenco_last_project'] = project.to_dict()

            project_id = bson.ObjectId(project['_id'])
            auth = current_flamenco.auth
            if not auth.current_user_may(action, project_id):
                if current_user.is_anonymous:
                    raise wz_exceptions.Forbidden('Login required for this URL')
                log.info('Denying user %s access %s to Flamenco on project %s',
                         flask_login.current_user, action, project_id)
                return error_project_not_available()

            if extension_props:
                pprops = project.extension_props.flamenco
                return wrapped(project, pprops, *args, **kwargs)
            return wrapped(project, *args, **kwargs)