From 01c4d4a04d40ed5888a3d3eef11c5cee3c5375e7 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 21 Feb 2023 16:25:55 +0300 Subject: oauth2: resources: List resource data. List unlinked data. List a particular resource's data. List any unlinked data that can be attached to a particular resource. --- wqflask/wqflask/oauth2/resources.py | 13 ++- .../wqflask/templates/oauth2/view-resource.html | 93 +++++++++++++++++++++- 2 files changed, 102 insertions(+), 4 deletions(-) diff --git a/wqflask/wqflask/oauth2/resources.py b/wqflask/wqflask/oauth2/resources.py index db23fc75..2a79f6cd 100644 --- a/wqflask/wqflask/oauth2/resources.py +++ b/wqflask/wqflask/oauth2/resources.py @@ -54,11 +54,20 @@ def view_resource(resource_id: uuid.UUID): # Display the resource's details # Provide edit/delete options # Metadata edit maybe? + def __resource_success__(resource): + dataset_type = resource["resource_category"]["resource_category_key"] + return oauth2_get(f"oauth2/resource/{dataset_type}/unlinked-data").either( + lambda err: render_template( + "oauth2/view-resource.html", resource=resource, + unlinked_error=process_error(err)), + lambda unlinked: render_template( + "oauth2/view-resource.html", resource=resource, error=None, + unlinked_data=unlinked)) + return oauth2_get(f"oauth2/resource/view/{resource_id}").either( lambda err: render_template("oauth2/view-resource.html", resource=None, error=process_error(err)), - lambda resource: render_template( - "oauth2/view-resource.html", resource=resource, error=None)) + __resource_success__) @resources.route("/edit/", methods=["GET"]) @require_oauth2 diff --git a/wqflask/wqflask/templates/oauth2/view-resource.html b/wqflask/wqflask/templates/oauth2/view-resource.html index 0ebd7f7a..4ae276f8 100644 --- a/wqflask/wqflask/templates/oauth2/view-resource.html +++ b/wqflask/wqflask/templates/oauth2/view-resource.html @@ -1,5 +1,6 @@ {%extends "base.html"%} {%from "oauth2/profile_nav.html" import profile_nav%} +{%from "oauth2/display_error.html" import display_error%} {%block title%}View User{%endblock%} {%block content%}
@@ -36,11 +37,99 @@ - -

List the resource's data here...

{%endif%}
+
+ + + + + + + + + + + + {%for data_item in resource.resource_data:%} + + + + + + {%else%} + + + + {%endfor%} + +
Resource Data
NameFull NameActions
+ + {{data_item.dataset_name}} + + {{data_item.dataset_fullname}} +
+ + + +
+
+ + +   + No linked data. +
+
+ +
+ + + + + + + + + + {%if unlinked_error is defined%} + display_error("Unlinked Data Error", unlinked_error) + {%else%} + {%for data_item in unlinked_data:%} + + + + + {%else%} + + +   + No data to link. + {%endfor%} + {%endif%} + +
Link Data
NameActions
+ + {{data_item.dataset_fullname}} + + +
+ + + +
+
+
+ -- cgit v1.2.3