diff options
author | BonfaceKilz | 2021-10-06 21:44:51 +0300 |
---|---|---|
committer | BonfaceKilz | 2021-10-06 21:55:27 +0300 |
commit | 70f8ed53f85cfb42ca81ed6c3b4c9cf1060940e5 (patch) | |
tree | 0bc730ba05cd247d1441d417efec465472903f86 /scripts | |
parent | d5f6670836cbed804a00e02ec0258d0c87564006 (diff) | |
download | genenetwork2-70f8ed53f85cfb42ca81ed6c3b4c9cf1060940e5.tar.gz |
scripts: resource: Add option for specifying a groups uuid
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/authentication/resource.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/scripts/authentication/resource.py b/scripts/authentication/resource.py index 8fcf09d7..4996f34c 100644 --- a/scripts/authentication/resource.py +++ b/scripts/authentication/resource.py @@ -63,12 +63,16 @@ def recover_hash(name: str, file_path: str, set_function) -> bool: if __name__ == "__main__": # Initialising the parser CLI arguments parser = argparse.ArgumentParser() + parser.add_argument("--group-id", + help="Add the group id to all resources") parser.add_argument("--restore", help="Restore from a given backup") parser.add_argument("--enable-backup", action="store_true", help="Create a back up before edits") args = parser.parse_args() + if not args.group_id: + exit("Please specify the group-id!\n") if args.restore: if recover_hash(name="resources", file_path=args.back_up, @@ -92,8 +96,8 @@ if __name__ == "__main__": for resource_id, resource in RESOURCES.items(): _resource = json.loads(resource) # str -> dict conversion - _resource["group_masks"] = {"editors": {"metadata": "edit", - "data": "edit"}} + _resource["group_masks"] = {args.group_id: {"metadata": "edit", + "data": "edit"}} REDIS_CONN.hset("resources", resource_id, json.dumps(_resource)) |