def packager_info(packager): ''' Display the information about the specified packager. ''' eol = flask.request.args.get('eol', False) packages_co = pkgdblib.get_package_maintained( SESSION, packager=packager, poc=False, eol=eol, ) packages = pkgdblib.get_package_maintained( SESSION, packager=packager, poc=True, eol=eol, ) packages_watch = pkgdblib.get_package_watch( SESSION, packager=packager, eol=eol, ) # Filter out from the watch list packaged where user has commit rights packages_obj = set([it[0] for it in packages_co]) packages_obj = packages_obj.union(set([it[0] for it in packages])) packages_watch = [ it for it in packages_watch if it[0] not in packages_obj] if not packages and not packages_co and not packages_watch: flask.flash('No packager of this name found.', 'errors') return flask.render_template('msg.html') return flask.render_template( 'packager.html', select='packagers', packager=packager, packages=packages, packages_co=packages_co, packages_watch=packages_watch, )
def packager_info(packager): ''' Display the information about the specified packager. ''' eol = flask.request.args.get('eol', False) packages_co = pkgdblib.get_package_maintained( SESSION, packager=packager, poc=False, eol=eol, ) packages = pkgdblib.get_package_maintained( SESSION, packager=packager, poc=True, eol=eol, ) packages_watch = pkgdblib.get_package_watch( SESSION, packager=packager, eol=eol, ) # Filter out from the watch list packaged where user has commit rights packages_obj = set([it[0] for it in packages_co]) packages_obj = packages_obj.union(set([it[0] for it in packages])) packages_watch = [it for it in packages_watch if it[0] not in packages_obj] if not packages and not packages_co and not packages_watch: flask.flash('No packager of this name found.', 'errors') return flask.render_template('msg.html') return flask.render_template( 'packager.html', select='packagers', packager=packager, packages=packages, packages_co=packages_co, packages_watch=packages_watch, )
def api_packager_package(packagername=None): ''' User's packages --------------- List the packages of the user. :: /api/packager/package/<fas_username>/ /api/packager/package/?packagername=<username> Accepts GET queries only. :arg packagername: String of the packager name. :kwarg eol: a boolean to specify whether to include results for EOL collections or not. Defaults to False. If ``True``, it will return results for all collections (including EOL). If ``False``, it will return results only for non-EOL collections. Sample response: :: /api/packager/acl/pingou { "output": "ok", "co-maintained": [ { "acls": [], "status": "Approved", "upstream_url": null, "description": null, "summary": "Data of T- and B-cell Acute Lymphocytic " "Leukemia", "creation_date": 1384775354.0, "review_url": null, "name": "R-ALL" } ], "watch": [], "point of contact": [ { "status": "Approved", "upstream_url": null, "description": null, "summary": "Data of T- and B-cell Acute Lymphocytic " "Leukemia", "creation_date": 1384775354.0, "review_url": null, "name": "R-ALL", "acls": [] } ] } /api/packager/package/?packagername=random { "output": "notok", "co-maintained": [], "point of contact": [], "watch": [], "error": "No ACLs found for that user" } ''' httpcode = 200 output = {'output': 'ok'} packagername = flask.request.args.get('packagername', None) or packagername branches = flask.request.args.getlist('branches', None) eol = flask.request.args.get('eol', False) if not branches: branches = [None] packages = [] packages_co = [] packages_watch = [] for branch in branches: tmp = pkgdblib.get_package_maintained( SESSION, packager=packagername, poc=False, branch=branch, eol=eol, ) for pkg in tmp: if pkg[0] not in packages_co: packages_co.append(pkg[0]) tmp_co = pkgdblib.get_package_maintained( SESSION, packager=packagername, poc=True, branch=branch, eol=eol, ) for pkg in tmp_co: if pkg[0] not in packages: packages.append(pkg[0]) tmp_w = pkgdblib.get_package_watch( SESSION, packager=packagername, branch=branch, eol=eol, ) for pkg in tmp_w: if pkg[0] not in packages_watch: packages_watch.append(pkg[0]) output['point of contact'] = [pkg.to_json(acls=False) for pkg in packages] output['co-maintained'] = [pkg.to_json(acls=False) for pkg in packages_co] output['watch'] = [ pkg.to_json(acls=False) for pkg in packages_watch if pkg not in packages and pkg not in packages_co ] if not packages and not packages_co and not packages_watch: output['output'] = 'notok' output['error'] = 'No ACLs found for that user' httpcode = 404 jsonout = flask.jsonify(output) jsonout.status_code = httpcode return jsonout
def api_packager_package(packagername=None): ''' User's packages --------------- List the packages of the user. :: /api/packager/package/<fas_username>/ /api/packager/package/?packagername=<username> Accept GET queries only. :arg packagername: String of the packager name. :kwarg eol: a boolean to specify whether to include results for EOL collections or not. Defaults to False. If ``True``, it will return results for all collections (including EOL). If ``False``, it will return results only for non-EOL collections. Sample response: :: /api/packager/acl/pingou { "output": "ok", "co-maintained": [ { "acls": [], "status": "Approved", "upstream_url": null, "description": null, "summary": "Data of T- and B-cell Acute Lymphocytic " "Leukemia", "creation_date": 1384775354.0, "review_url": null, "name": "R-ALL" } ], "watch": [], "point of contact": [ { "status": "Approved", "upstream_url": null, "description": null, "summary": "Data of T- and B-cell Acute Lymphocytic " "Leukemia", "creation_date": 1384775354.0, "review_url": null, "name": "R-ALL", "acls": [] } ] } /api/packager/package/?packagername=random { "output": "notok", "co-maintained": [], "point of contact": [], "watch": [], "error": "No ACLs found for that user" } ''' httpcode = 200 output = {'output': 'ok'} packagername = flask.request.args.get('packagername', None) or packagername eol = flask.request.args.get('eol', False) packages_co = pkgdblib.get_package_maintained( SESSION, packager=packagername, poc=False, eol=eol, ) seen = [] for pkg in packages_co: if pkg[0] not in seen: seen.append(pkg[0]) packages_co = seen packages = pkgdblib.get_package_maintained( SESSION, packager=packagername, poc=True, eol=eol, ) seen = [] for pkg in packages: if pkg[0] not in seen: seen.append(pkg[0]) packages = seen packages_watch = pkgdblib.get_package_watch( SESSION, packager=packagername, eol=eol, ) seen = [] for pkg in packages_watch: if pkg[0] not in seen: seen.append(pkg[0]) packages_watch = seen output['point of contact'] = [pkg.to_json(acls=False) for pkg in packages] output['co-maintained'] = [pkg.to_json(acls=False) for pkg in packages_co] output['watch'] = [pkg.to_json(acls=False) for pkg in packages_watch] if not packages and not packages_co and not packages_watch: output['output'] = 'notok' output['error'] = 'No ACLs found for that user' httpcode = 404 jsonout = flask.jsonify(output) jsonout.status_code = httpcode return jsonout