aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBonfaceKilz2021-09-23 15:39:32 +0300
committerBonfaceKilz2021-10-04 13:00:53 +0300
commitc585945c5516092b362efecc16325ad9ecc54291 (patch)
tree8e742e55302094610696d673c2669d32c87daecb
parent6e0ea75ca427721aed0a5f394b501b2cde9bf769 (diff)
downloadgenenetwork2-c585945c5516092b362efecc16325ad9ecc54291.tar.gz
Add script that adds "editors" group to all resources in Redis
-rw-r--r--scripts/authentication/resource.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/authentication/resource.py b/scripts/authentication/resource.py
new file mode 100644
index 00000000..75ef9e93
--- /dev/null
+++ b/scripts/authentication/resource.py
@@ -0,0 +1,25 @@
+"""A script that adds the group: 'editors' to every
+resource. 'editors' should have the right to edit both metadata and
+data.
+
+To use this script, simply run:
+
+.. code-block:: python
+ python resource.py
+
+"""
+import json
+import redis
+
+
+if __name__ == "__main__":
+ REDIS_CONN = redis.Redis()
+ resources = REDIS_CONN.hgetall("resources_clone")
+ for resource_id, resource in resources.items():
+ deserialized_resource = json.loads(resource)
+ deserialized_resource["group_masks"] = {
+ "editors": {"metadata": "edit",
+ "data": "edit"}}
+ REDIS_CONN.hset("resources_clone",
+ resource_id,
+ json.dumps(deserialized_resource))