From 265710fa607c4faf79f304cbf323b6fb1a152949 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 7 Jan 2022 16:34:32 -0800 Subject: [PATCH] Move all Turbot-created sheets down one level (in google drive) The new folder is named "turbot" --- turbot/events.py | 13 +++++++++++-- turbot/sheets.py | 5 ++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/turbot/events.py b/turbot/events.py index eb5bcc4..25c8323 100644 --- a/turbot/events.py +++ b/turbot/events.py @@ -125,8 +125,17 @@ def hunt_channel_created(turb, channel_name, channel_id): "Welcome to the channel for the {} hunt! ".format(hunt['name']) + "Please wait a moment or two while I create some backend resources.") - # Create a new folder within Google drive for the hunt - hunt['folder_id'] = sheets_create_folder(turb, hunt['hunt_id']) + # Create a new folder within Google drive for the hunt in two parts: + + # ... first, a top-level folder named for the hunt + hunt_folder = sheets_create_folder(turb, hunt['hunt_id']) + + # ... second, a folder within that named "turbot" + # + # The concept here is that non-turbot related content could + # be placed adjacent to the turbot folder. + hunt['folder_id'] = sheets_create_folder(turb, "turbot", + parents = [hunt_folder]) # Create a sheet for the hunt sheet = sheets_create(turb, hunt['name'], hunt['folder_id']) diff --git a/turbot/sheets.py b/turbot/sheets.py index c042b4d..76515ca 100644 --- a/turbot/sheets.py +++ b/turbot/sheets.py @@ -2,7 +2,7 @@ PUZZLE_TEMPLATE_ID = "1drSoyrE4gM3JaGweDkOybwXWdKPIDTfUmB1gQCYS3Uw" PUZZLE_TEMPLATE_SHEETS = ["Text", "Square grid", "Hex Grid", "Formula reference: indexing"] -def sheets_create_folder(turb, folder_name): +def sheets_create_folder(turb, folder_name, parents = None): """Create a new folder within Google Drive Returns the id of the created folder.""" @@ -12,6 +12,9 @@ def sheets_create_folder(turb, folder_name): "mimeType": "application/vnd.google-apps.folder" } + if parents: + body["parents"] = parents + folder = turb.files.create(body=body, fields='id').execute() return folder.get('id') -- 2.43.0