Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Merret Buurman
pidlandingpage
Commits
15dd7249
Commit
15dd7249
authored
Jun 06, 2016
by
Merret Buurman
Browse files
Normal landing pages now show record as list of key-value pairs.
parent
4fd140dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
landingpage/landingpageapp/handle/genericparser.py
0 → 100644
View file @
15dd7249
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
:
pass
else
:
record_dict
[
key
]
=
str
(
get_value_from_record
(
record
,
key
))
return
record_dict
\ No newline at end of file
landingpage/landingpageapp/pages/default.py
View file @
15dd7249
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
try
:
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment