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

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

added extra widgets

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['lineage'] = record.dataLineage
38    return render_to_response('cedaBrowse.html', c)
39
40def _getCedaObservation(request, obs_id):
41    return Moles3EPB.searchEager(CEDA_Observation, obs_id, request.moles_session)
Note: See TracBrowser for help on using the repository browser.