From b2d3b101b7a44932632036146b7c271acfd67593 Mon Sep 17 00:00:00 2001 From: Adam Novak Date: Fri, 17 Apr 2020 13:07:18 -0700 Subject: Pull 'doc' from the schema through to the frontend --- bh20simplewebuploader/main.py | 9 ++++++++- bh20simplewebuploader/templates/form.html | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'bh20simplewebuploader') diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index 0db7d84..8c5c18c 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -68,7 +68,8 @@ def generate_form(schema, options): form section in the template) or an 'id', 'label', 'type', and 'required' (in which case we make a form field in the template). Non-heading dicts with type 'select' will have an 'options' field, with a list of (name, - value) tuples, and represent a form dropdown element. + value) tuples, and represent a form dropdown element. Non-heading dicts may + have a human-readable 'docstring' field describing them. Takes the deserialized metadata schema YAML, and also a deserialized YAML of option values. The option values are keyed on (unscoped) field name in @@ -110,8 +111,12 @@ def generate_form(schema, options): # For each field ref_iri = None + docstring = None if not isinstance(field_type, str): # If the type isn't a string + + # It may have documentation + docstring = field_type.get('doc', None) # See if it has a more info/what goes here URL predicate = field_type.get('jsonldPredicate', {}) @@ -156,6 +161,8 @@ def generate_form(schema, options): record['required'] = not optional and not subtree_optional if ref_iri: record['ref_iri'] = ref_iri + if docstring: + record['docstring'] = docstring if field_name in options: # The field will be a 'select' type no matter what its real diff --git a/bh20simplewebuploader/templates/form.html b/bh20simplewebuploader/templates/form.html index 012b9c5..166f51c 100644 --- a/bh20simplewebuploader/templates/form.html +++ b/bh20simplewebuploader/templates/form.html @@ -224,7 +224,7 @@ {{ record['label'] }} {{ "*" if record['required'] else "" }} {% if 'ref_iri' in record %} - ? + ? {% endif %} {% if record['type'] == 'select' %} -- cgit v1.2.3