source: mauRepo/MolesManager/trunk/src/MolesManager/views/cedaBrowse.py @ 8307

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/MolesManager/trunk/src/MolesManager/views/cedaBrowse.py@8307
Revision 8307, 2.4 KB checked in by jhorton, 7 years ago (diff)

added textareas etc

Line 
1'''
2@created on 8 may 2012
3@author jah
4'''
5from django.shortcuts import render_to_response
6from django.core.context_processors import csrf
7from ea_model.ceda_metadatamodel.ceda_observation.ceda_observation import CEDA_Observation
8from MolesManager.moles3epb import Moles3EPB
9from MolesManager.djencoder import DJEncoder
10from django.utils.safestring import mark_safe
11
12def browseView(request, obs_id_str):
13    obs_id = int(obs_id_str)
14    record = None
15    guid = None
16    if obs_id:
17        record = _getCedaObservation(request, obs_id)
18        guid = Moles3EPB.retrieveGUIDFromInstance(record, request.moles_session)
19    c = {}
20    c['abstract'] = record.inSupportOf.abstract
21    for v in record.identifier:
22        if v.authority.title == 'ceda_title':
23            c['title'] = v.code
24    for v in record.relatedParty:
25        if v.role.name == 'cl_author':
26            c['author'] = v.party[0].name
27    c['status'] = record.publicationState.value
28    c['last_update_year'] = record.resultTime.position.dateTime8601.year
29    c['last_update_month'] = record.resultTime.position.dateTime8601.month
30    c['last_update_day'] = record.resultTime.position.dateTime8601.day
31    c['phenomenon_begin_year'] = record.phenomenonTime.begin.position.date8601.year;
32    c['phenomenon_begin_month'] = record.phenomenonTime.begin.position.date8601.month;
33    c['phenomenon_begin_day'] = record.phenomenonTime.begin.position.date8601.day;
34    c['phenomenon_end_year'] = record.phenomenonTime.end.position.date8601.year;
35    c['phenomenon_end_month'] = record.phenomenonTime.end.position.date8601.month;
36    c['phenomenon_end_day'] = record.phenomenonTime.end.position.date8601.day;
37    c['vertical_extent'] = record.verticalExtent;
38    c['resolution'] = record.resolution;
39    c['observed_property'] = record.observedProperty;
40    c['parameters'] = record.parameter;
41    c['project_details'] = record.inSupportOf.relatedParty;
42    c['procedure'] = record.procedure;
43    c['lineage'] = record.dataLineage;
44    c['archive_no_files'] = record.result.numberOfFiles
45    lk = []
46    for l in record.result.source:
47        ls = l.linkage.strip()
48        if len(ls) != 0:
49          lk.append(ls)
50    c['archive_linkage'] = lk
51    c['documentation'] = record.documentation
52    return render_to_response('cedaBrowse.html', c)
53
54def _getCedaObservation(request, obs_id):
55    return Moles3EPB.searchEager(CEDA_Observation, obs_id, request.moles_session)
Note: See TracBrowser for help on using the repository browser.