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

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

update to browse

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