diff options
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/oauth2/resources.py | 28 | ||||
-rw-r--r-- | wqflask/wqflask/templates/oauth2/view-resource.html | 6 |
2 files changed, 32 insertions, 2 deletions
diff --git a/wqflask/wqflask/oauth2/resources.py b/wqflask/wqflask/oauth2/resources.py index 1551dc8a..872a29c6 100644 --- a/wqflask/wqflask/oauth2/resources.py +++ b/wqflask/wqflask/oauth2/resources.py @@ -100,6 +100,34 @@ def link_data_to_resource(): return redirect(url_for( "oauth2.resource.view_resource", resource_id=form["resource_id"])) +@resources.route("/data/unlink", methods=["POST"]) +@require_oauth2 +def unlink_data_from_resource(): + """Unlink group data from a resource""" + form = request.form + try: + assert "resource_id" in form, "Resource ID not provided." + assert "dataset_id" in form, "Dataset ID not provided." + resource_id = form["resource_id"] + + def __error__(error): + err = process_error(error) + flash(f"{err['error']}: {err['error_description']}", "alert-danger") + return redirect(url_for( + "oauth2.resource.view_resource", resource_id=resource_id)) + + def __success__(success): + flash(f"Data unlinked from resource successfully", "alert-success") + return redirect(url_for( + "oauth2.resource.view_resource", resource_id=resource_id)) + return oauth2_post( + "oauth2/resource/data/unlink", data=dict(form)).either( + __error__, __success__) + except AssertionError as aserr: + flash(aserr.args[0], "alert-danger") + return redirect(url_for( + "oauth2.resource.view_resource", resource_id=form["resource_id"])) + @resources.route("/edit/<uuid:resource_id>", methods=["GET"]) @require_oauth2 def edit_resource(resource_id: uuid.UUID): diff --git a/wqflask/wqflask/templates/oauth2/view-resource.html b/wqflask/wqflask/templates/oauth2/view-resource.html index 04be2a4c..fb44560b 100644 --- a/wqflask/wqflask/templates/oauth2/view-resource.html +++ b/wqflask/wqflask/templates/oauth2/view-resource.html @@ -56,13 +56,15 @@ <tr> <td> <a href="https://gn1.genenetwork.org/webqtl/main.py?FormID=sharinginfo&GN_AccessionId={{data_item.accession_id}}&InfoPageName={{data_item.dataset_name}}" - title="Link to information on dataset '{{data_item.dataset_fullname}}'"> + title="Link to information on dataset '{{data_item.dataset_fullname}}'" + target="_blank"> {{data_item.dataset_name}} </a> </td> <td>{{data_item.dataset_fullname}}</td> <td> - <form action="#" method="POST"> + <form action="{{url_for('oauth2.resource.unlink_data_from_resource')}}" + method="POST"> <input type="hidden" name="resource_id" value="{{resource.resource_id}}" /> <input type="hidden" name="dataset_id" |