Commit 15dd7249 authored by Merret Buurman's avatar Merret Buurman
Browse files

Normal landing pages now show record as list of key-value pairs.

parent 4fd140dc
import xml.etree.ElementTree as ET
from landingpage.landingpageapp.config_and_defaults import DEFAULTS
import retrieval
### API
# Parsing any cmip6 handle records
def get_all_entries_as_dict(record, include_special_types=True):
return _get_all_entries_as_dict(record, include_special_types)
def _get_all_entries_as_dict(record, include_special_types=True):
special_types = DEFAULTS['special_types']
record_dict = {}
for entry in record['values']:
key = entry['type']
if key in special_types and not include_special_types:
record_dict[key] = str(get_value_from_record(record, key))
return record_dict
\ No newline at end of file
from django.template import loader
import requests
import landingpage.landingpageapp.handle.genericparser as parser
from landingpage.landingpageapp.handle import retrieval
import errorpages
def get_html_string(request, prefix, suffix):
template = loader.get_template('landingpage/normal_dkrz.html')
context = {
"handle": prefix+'/'+suffix
return template.render(context, request)
\ No newline at end of file
json_record = retrieval.get_handle_record_json(prefix+'/'+suffix)
except ValueError as e:
return errorpages.problem_page(request, prefix+'/'+suffix, e.message)
context = _get_context(json_record)
template = _get_template()
return template.render(context, request)
def _get_template():
return loader.get_template('landingpage/cmip6_dataset.html')
def _get_context(json_record):
context = {}
context['content'] = json_record
context['handle'] = json_record['handle']
context['values'] = parser.get_all_entries_as_dict(json_record)
return context
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment