X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Facl.py;h=e19b26912dd8234dc5148186431154a566f28b38;hb=362ea497d3c9ee5891fca772132269d809a0547a;hp=075c722b5842bfd05f3b3269818480369c115a87;hpb=b45b7f3a0a5c175e591590c80133ce35f960517e;p=dak.git diff --git a/dak/acl.py b/dak/acl.py index 075c722b..e19b2691 100644 --- a/dak/acl.py +++ b/dak/acl.py @@ -23,9 +23,17 @@ from daklib.config import Config from daklib.dbconn import DBConn, Fingerprint, Uid, ACL def usage(): - print """Usage: dak acl set-fingerprints + print """Usage: + dak acl set-fingerprints + dak acl export-per-source -Reads list of fingerprints from stdin and sets the ACL to these. + set-fingerprints: + Reads list of fingerprints from stdin and sets the ACL to these. + Accepted input formats are "uid:", "name:" and + "fpr:". + + export-per-source: + Export per source upload rights for ACL . """ def get_fingerprint(entry, session): @@ -76,14 +84,17 @@ def acl_export_per_source(acl_name): session = DBConn().session() acl = session.query(ACL).filter_by(name=acl_name).one() - query = """ + query = r""" SELECT f.fingerprint, (SELECT COALESCE(u.name, '') || ' <' || u.uid || '>' FROM uid u JOIN fingerprint f2 ON u.id = f2.uid WHERE f2.id = f.id) AS name, - STRING_AGG(a.source, ' ' ORDER BY a.source) + STRING_AGG( + a.source + || COALESCE(' (' || (SELECT fingerprint FROM fingerprint WHERE id = a.created_by_id) || ')', ''), + E',\n ' ORDER BY a.source) FROM acl_per_source a JOIN fingerprint f ON a.fingerprint_id = f.id LEFT JOIN uid u ON f.uid = u.id