aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-05-18 16:31:10 +0300
committerFrederick Muriuki Muriithi2023-05-18 16:31:10 +0300
commit1ec8d9e6c1625b398bbcd806180000595214cf43 (patch)
treec7a15b4e765477111d3bdc1f519ad850f9da6f3e /wqflask
parent44bc42bfd12ab916cead02b1a088fa29f47bd8df (diff)
downloadgenenetwork2-1ec8d9e6c1625b398bbcd806180000595214cf43.tar.gz
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.
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/collect.py16
-rw-r--r--wqflask/wqflask/templates/collections/view.html24
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()}}
<h1>
<span id="collection_name">{{ uc.name }}</span>
- <input type="text" name="new_collection_name" style="font-size: 20px; display: none; width: 500px;" class="form-control" placeholder="{{ uc.name }}">
+ <form id="frm-change-collection-name"
+ method="POST"
+ action="{{url_for('change_collection_name')}}"
+ style="display:inline;">
+ <input type="hidden" name="collection_id" value="{{uc.id}}" />
+ <input type="text"
+ name="new_collection_name"
+ style="font-size: 20px; display: none; width: 500px;"
+ class="form-control"
+ placeholder="{{ uc.name }}" />
+ </form>
<button class="btn btn-default" style="display: inline;" id="change_collection_name">Change Collection Name</button>
<button class="btn btn-default" style="display: inline;" id="make_default">Make Default</button>
</h1>
@@ -359,15 +369,9 @@
$('input[name=new_collection_name]').css('display', 'inline');
$('#collection_name').css('display', 'none');
} else {
- new_name = $('input[name=new_collection_name]').val()
- $.ajax({
- type: "POST",
- url: "/collections/change_name",
- data: {
- collection_id: $('input[name=uc_id]').val(),
- new_name: new_name
- }
- });
+ new_name = $('input[name=new_collection_name]').val();
+ $('#frm-change-collection-name').submit();
+ console.debug("We really should not get here, but, whatever...");
$('input[name=new_collection_name]').css('display', 'none');
$('input[name=collection_name]').val(new_name);
$('#collection_name').text(new_name)