changed getadmins into a generic function for both for admins and other roles.
[plcrt.git] / getpersons.py
diff --git a/getpersons.py b/getpersons.py
new file mode 100644 (file)
index 0000000..4ed2427
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/env plcsh
+
+import sys
+
+p = GetPersons(None, ['email', 'first_name', 'last_name', 'roles', 'site_ids'])
+
+admins = filter(lambda x: sys.argv[1] in x['roles'], p)
+
+for a in admins:
+       s = GetSites(a['site_ids'], ['name'])
+       if len(s) > 0:
+               organization = s[0]['name']
+       else:
+               organization = "Unknown"
+       a['name'] = organization
+       print "%(email)s,%(first_name)s %(last_name)s,%(name)s" % a