aboutsummaryrefslogtreecommitdiff
path: root/scripts/authentication
diff options
context:
space:
mode:
authorBonfaceKilz2021-11-05 13:40:44 +0300
committerBonfaceKilz2021-11-05 13:40:44 +0300
commitf75ffe73e592bc79f4decf268d50b225ade43488 (patch)
tree4683e0bc3c4968ba7f1f9ee799f49bace4a4c242 /scripts/authentication
parent1e3092ced9489c50a18e403c56958694609130f7 (diff)
downloadgenenetwork2-f75ffe73e592bc79f4decf268d50b225ade43488.tar.gz
Add script for manually adding "editors" to each resource
Diffstat (limited to 'scripts/authentication')
-rwxr-xr-xscripts/authentication/editors.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/scripts/authentication/editors.py b/scripts/authentication/editors.py
new file mode 100755
index 00000000..12f48872
--- /dev/null
+++ b/scripts/authentication/editors.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python3
+"""Manually add editors users"""
+import redis
+import json
+import uuid
+import datetime
+
+if __name__ == "__main__":
+ conn = redis.Redis(decode_responses=True)
+ group_uid = ""
+ for guid in conn.hgetall("groups"):
+ group_details = json.loads(conn.hget("groups", guid))
+ if group_details.get("name") == "editors":
+ group_uid = guid
+ break
+
+ if not group_uid:
+ group_uid = str(uuid.uuid4())
+ timestamp = datetime.datetime.utcnow().strftime('%b %d %Y %I:%M%p')
+ conn.hset(
+ "groups",
+ group_uid,
+ json.dumps(
+ {
+ "name": "editors",
+ "admins": [],
+ "members": ["labwilliams@gmail.com"],
+ "changed_timestamp": timestamp,
+ }))
+
+ for resource in conn.hgetall("resources"):
+ _resource = json.loads(conn.hget("resources", resource))
+ _resource["default_mask"] = {
+ 'data': 'view',
+ 'metadata': 'view',
+ 'admin': 'not-admin',
+ }
+ _resource["group_masks"] = {
+ group_uid: {
+ 'metadata': 'edit',
+ 'data': 'edit',
+ 'admin': 'edit-admins',
+ }}
+ conn.hset("resources", resource, json.dumps(_resource))
+ print("Done adding editor's group to resources!")