Commit 76157fe6 authored by Merret Buurman's avatar Merret Buurman
Browse files

Finding out aggr.level was moved to handle parser.

parent cedfa6f2
......@@ -9,6 +9,22 @@ import retrieval
def get_aggregation_level(record):
return get_value_from_record(record, 'AGGREGATION_LEVEL')
def is_file(record):
if get_aggregation_level(record) == 'FILE':
return True
def is_dataset(record):
if get_aggregation_level(record) == 'DATASET':
return True
def get_title_from_record(record):
if is_file(record):
return get_filename_from_record(record)
elif is_dataset(record):
return get_drs_from_record(record)
else:
return None
###
### Parsing file handle records
###
......
......@@ -8,26 +8,24 @@ from landingpage.handle import retrieval, cmip6parser
def get_html_string(request, prefix, suffix):
json_record = retrieval.get_handle_record_json(prefix+'/'+suffix)
agg_level = cmip6parser.get_aggregation_level(json_record)
context = _get_context_for_aggregation_level(agg_level, json_record)
template = _get_template_for_aggregation_level(agg_level)
context = _get_context_for_aggregation_level(json_record)
template = _get_template_for_aggregation_level(json_record)
return template.render(context, request)
def _get_template_for_aggregation_level(aggregation_level):
if aggregation_level.lower() == 'file':
def _get_template_for_aggregation_level(json_record):
if cmip6parser.is_file(json_record):
return filelevel.get_template()
elif aggregation_level.lower() == 'dataset':
elif cmip6parser.is_dataset(json_record):
return loader.get_template('landingpage/cmip6_dataset.html') # TODO
else:
return loader.get_template('landingpage/cmip6_fallback.html') # TODO
def _get_context_for_aggregation_level(agg_level, json_record):
if agg_level.lower() == 'file':
def _get_context_for_aggregation_level(json_record):
if cmip6parser.is_file(json_record):
return filelevel.get_context(json_record)
elif agg_level.lower() == 'dataset':
elif cmip6parser.is_dataset(json_record):
return _get_handle_info_for_dataset(json_record) # TODO
else:
return _get_dict_generic(json_record) # TODO
......
Supports Markdown
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