def pending_acl_deny(): ''' Deny all the pending acls for the user logged in. ''' form = pkgdb2.forms.ConfirmationForm() if form.validate_on_submit(): pending_acls = pkgdblib.get_pending_acl_user( SESSION, flask.g.fas_user.username) try: for acl in pending_acls: pkgdblib.set_acl_package( SESSION, namespace=acl['namespace'], pkg_name=acl['package'], pkg_branch=acl['collection'], pkg_user=acl['user'], acl=acl['acl'], status='Denied', user=flask.g.fas_user ) SESSION.commit() flask.flash('All ACLs denied') # Let's keep this in although we should never see it except pkgdblib.PkgdbException, err: # pragma: no cover SESSION.rollback() flask.flash(str(err), 'error')
def pending_acl_deny(): ''' Deny all the pending acls for the user logged in. ''' form = pkgdb2.forms.ConfirmationForm() if form.validate_on_submit(): pending_acls = pkgdblib.get_pending_acl_user(SESSION, flask.g.fas_user.username) try: for acl in pending_acls: pkgdblib.set_acl_package(SESSION, namespace=acl['namespace'], pkg_name=acl['package'], pkg_branch=acl['collection'], pkg_user=acl['user'], acl=acl['acl'], status='Denied', user=flask.g.fas_user) SESSION.commit() flask.flash('All ACLs denied') # Let's keep this in although we should never see it except PkgdbException as err: # pragma: no cover SESSION.rollback() flask.flash(str(err), 'error') return flask.redirect(flask.url_for('.pending_acl'))
def pending_acl(): ''' List the pending acls for the user logged in. ''' pending_acls = pkgdblib.get_pending_acl_user(SESSION, flask.g.fas_user.username) return flask.render_template( 'acl_pending.html', pending_acls=pending_acls, )
def pending_acl(): ''' List the pending acls for the user logged in. ''' pending_acls = pkgdblib.get_pending_acl_user( SESSION, flask.g.fas_user.username) return flask.render_template( 'acl_pending.html', pending_acls=pending_acls, )
def inject_is_admin(): """ Inject whether the user is a pkgdb2 admin or not in every page (every template). """ justlogedin = flask.session.get('_justlogedin', False) if justlogedin: # pragma: no cover flask.g.pending_acls = pkgdblib.get_pending_acl_user( SESSION, flask.g.fas_user.username) flask.session['_justlogedin'] = None return dict(is_admin=is_pkgdb_admin(flask.g.fas_user), version=__version__)
def pending_acl(): ''' List the pending acls for the user logged in. ''' pending_acls = pkgdblib.get_pending_acl_user( SESSION, flask.g.fas_user.username) form = pkgdb2.forms.ConfirmationForm() return flask.render_template( 'acl_pending.html', pending_acls=pending_acls, form=form, )
def pending_acl(): ''' List the pending acls for the user logged in. ''' pending_acls = pkgdblib.get_pending_acl_user(SESSION, flask.g.fas_user.username) form = pkgdb2.forms.ConfirmationForm() return flask.render_template( 'acl_pending.html', pending_acls=pending_acls, form=form, )
def inject_is_admin(): """ Inject whether the user is a pkgdb2 admin or not in every page (every template). """ justlogedin = flask.session.get('_justlogedin', False) if justlogedin: flask.g.pending_acls = pkgdblib.get_pending_acl_user( SESSION, flask.g.fas_user.username) flask.session['_justlogedin'] = None return dict(is_admin=is_pkgdb_admin(flask.g.fas_user), version=__version__)
def api_pendingacls(): ''' Pending ACLs requests --------------------- Return the list ACLs request that are ``Awaiting Approval``. :: /api/pendingacls :kwarg username: Return the list of pending ACL requests requiring action from the specified user. :kwarg format: Specify if the output if text or json. ''' out_format = flask.request.args.get('format', 'text') username = flask.request.args.get('username', None) if out_format not in ('text', 'json'): out_format = 'text' if request_wants_json(): out_format = 'json' output = {} pending_acls = pkgdblib.get_pending_acl_user( SESSION, username) if out_format == 'json': output = {"pending_acls": pending_acls} output['total_requests_pending'] = len(pending_acls) return flask.jsonify(output) else: pending_acls.sort(key=lambda it: it['package']) output = [ "# Number of requests pending: %s" % len(pending_acls)] for entry in pending_acls: output.append( "%(package)s:%(collection)s has %(user)s waiting for " "%(acl)s" % (entry)) return flask.Response( '\n'.join(output), content_type="text/plain;charset=UTF-8" )
def api_pendingacls(): ''' Pending ACLs requests --------------------- Return the list ACLs request that are ``Awaiting Approval``. :: /api/pendingacls :kwarg username: Return the list of pending ACL requests requiring action from the specified user. :kwarg format: Specify if the output if text or json. ''' out_format = flask.request.args.get('format', 'text') username = flask.request.args.get('username', None) if out_format not in ('text', 'json'): out_format = 'text' if request_wants_json(): out_format = 'json' output = {} pending_acls = pkgdblib.get_pending_acl_user( SESSION, username) if out_format == 'json': output = {"pending_acls": pending_acls} output['total_requests_pending'] = len(pending_acls) return flask.jsonify(output) else: pending_acls.sort(key=lambda it: it['package']) output = [ "# Number of requests pending: %s" % len(pending_acls)] for entry in pending_acls: output.append( "%(package)s:%(collection)s has %(user)s waiting for " "%(acl)s since %(since)s" % (entry)) return flask.Response( '\n'.join(output), content_type="text/plain;charset=UTF-8" )
def inject_is_admin(): """ Inject whether the user is a pkgdb2 admin or not in every page (every template). """ justlogedin = flask.session.get('_justloggedin', False) if justlogedin: # pragma: no cover flask.g.pending_acls = pkgdblib.get_pending_acl_user( SESSION, flask.g.fas_user.username) flask.session['_justloggedin'] = None justlogedout = flask.session.get('_justloggedout', False) if justlogedout: flask.session['_justloggedout'] = None namespaces = pkgdblib.get_status(SESSION, 'namespaces')['namespaces'] return dict( is_admin=is_pkgdb_admin(flask.g.fas_user), version=__version__, namespaces=namespaces, )