From 1ec8d9e6c1625b398bbcd806180000595214cf43 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 18 May 2023 16:31:10 +0300 Subject: auth: Change collection name Enable the changing of the collection names. * wqflask/wqflask/collect.py: Send data to GN3 API * wqflask/wqflask/templates/collections/view.html: Use an actual form and submit it. --- wqflask/wqflask/collect.py | 16 ++++++++-------- wqflask/wqflask/templates/collections/view.html | 24 ++++++++++++++---------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/wqflask/wqflask/collect.py b/wqflask/wqflask/collect.py index dc9a7154..eaed239d 100644 --- a/wqflask/wqflask/collect.py +++ b/wqflask/wqflask/collect.py @@ -376,11 +376,11 @@ def view_collection(): @app.route("/collections/change_name", methods=('POST',)) def change_collection_name(): - params = request.form - - collection_id = params['collection_id'] - new_name = params['new_name'] - - g.user_session.change_collection_name(collection_id, new_name) - - return new_name + collection_id = request.form['collection_id'] + resp = redirect(url_for("view_collection", uc_id=collection_id)) + return client.post( + f"oauth2/user/collections/{collection_id}/rename", + json={ + "anon_id": str(session_info()["anon_id"]), + "new_name": request.form["new_collection_name"] + }).either(with_flash_error(resp), with_flash_success(resp)) diff --git a/wqflask/wqflask/templates/collections/view.html b/wqflask/wqflask/templates/collections/view.html index b06c9951..c850e163 100644 --- a/wqflask/wqflask/templates/collections/view.html +++ b/wqflask/wqflask/templates/collections/view.html @@ -14,7 +14,17 @@ {{flash_me()}}