aboutsummaryrefslogtreecommitdiff
path: root/scripts/authentication/editors.py
diff options
context:
space:
mode:
authorzsloan2022-01-14 18:22:32 +0000
committerzsloan2022-01-14 18:22:32 +0000
commit68ac19153b128f60b660e11365e5fd4304c95300 (patch)
tree198e03522af43a2d41f3c02cf3785bcfd4635fc4 /scripts/authentication/editors.py
parentf588ad96ae5045499860fa6e2740e101ad4410d7 (diff)
parent9ab0c3b6cc146e1711f1478242d4198eed720e4c (diff)
downloadgenenetwork2-68ac19153b128f60b660e11365e5fd4304c95300.tar.gz
Merge branch 'testing' of github.com:genenetwork/genenetwork2 into feature/add_rqtl_pairscan
Diffstat (limited to 'scripts/authentication/editors.py')
-rwxr-xr-xscripts/authentication/editors.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/authentication/editors.py b/scripts/authentication/editors.py
new file mode 100755
index 00000000..dc3b1075
--- /dev/null
+++ b/scripts/authentication/editors.py
@@ -0,0 +1,46 @@
+#!/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": ["8ad942fe-490d-453e-bd37-56f252e41603"],
+ "created_timestamp": timestamp,
+ "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!")