source: mauRepo/MolesManager/trunk/src/MolesManager/views/cedaObservationView.py @ 8408

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

# 22505: Use the CedaMoles? python package
removed the ceda_moles folders and verified the imports

Line 
1'''
2Created on 1 Nov 2011
3
4@author: mnagni
5'''
6from django.shortcuts import render_to_response
7from django.core.context_processors import csrf
8from ea_model.ceda_metadatamodel.ceda_observation.ceda_observation import CEDA_Observation
9from MolesManager.djencoder import DJEncoder
10from django.utils.safestring import mark_safe
11
12
13def coView(request, obs_id_str):
14    obs_id = int(obs_id_str)
15    return splash(request, obs_id)   
16
17def splash(request, obs_id):
18    """
19        Processes and display a given CEDA_Observation id
20        @param request: an HTTP request
21        @param obs_id: the CEDA_Observation id
22        @return: an HTTPResponse 
23    """
24    record = None
25    if obs_id:
26        record = _getCedaObservation(request, obs_id)
27    return _finalizeResponse(request, record)
28   
29def _finalizeResponse(request, record):
30    c = {}
31    if record:
32        c['coObs'] = mark_safe(DJEncoder().encode(record))
33        guid = request.moles3EPB.retrieveGUIDFromInstance(record)
34        if guid:
35            c['guid'] = guid.id
36            print c['guid']
37        print c['coObs'] 
38   
39    c.update(csrf(request))
40    return render_to_response('cedaObservation.html', c)
41
42def _getCedaObservation(request, obs_id):   
43    eagerloadthese = ['identifier.authority', 'resultTime.position.dateTime8601.month', \
44                      'resultAccumulation', 'relatedParty.party', 'result.source.function', 'permission', \
45                      'geographicExtent', 'phenomenonTime', 'keywords', 'description', \
46                      'inSupportOf.abstract', 'dataLineage']
47    return request.moles3EPB.searchSelectiveLoad(CEDA_Observation, obs_id, eagerloadthese)
48    #return Moles3EPB.searchEager(CEDA_Observation, obs_id)
Note: See TracBrowser for help on using the repository browser.