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

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

added access button dialog

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    c = {}
17    if obs_id:
18        record = _getCedaObservation(request, obs_id)
19        guid = Moles3EPB.retrieveGUIDFromInstance(record, request.moles_session)
20        c['guid'] = guid.id
21    c['abstract'] = record.inSupportOf.abstract
22    for v in record.identifier:
23        if v.authority.title == 'ceda_title':
24            c['title'] = v.code
25        if v.authority.title == 'moles2url':
26            c['moles2url'] = v.code
27    for v in record.relatedParty:
28        if v.role.name == 'cl_author':
29            c['author'] = v.party[0].name
30        if v.role.name == 'cl_pointofcontact':
31            c['email_contact_addr'] = v.party[0].contactInfo[0].address.electronicMailAddress[0];
32            c['email_contact_name'] = v.party[0].name;
33        if v.role.name == 'cl_publisher':
34            c['publisher'] = v.party[0].name
35        if v.role.name == 'cl_coinvestigator':
36            c['co_investigator'] = v.party[0].name;
37    pubyear = record.resultTime.position.dateTime8601.year;
38    c['citation'] = mark_safe(c['author'] + ";" + c['co_investigator'] + "(" + pubyear + ")" + c['title'] + " " + c['publisher'] + " Available from : <a href=\"http://www.ceda.ac.uk/datacat/" + c['guid'] + "\" target=\"_blank\">http://www.ceda.ac.uk/datacat/" + c['guid'] +"</a>");
39    c['status'] = record.publicationState.value
40    c['last_update_year'] = record.resultTime.position.dateTime8601.year
41    c['last_update_month'] = record.resultTime.position.dateTime8601.month
42    c['last_update_day'] = record.resultTime.position.dateTime8601.day
43    c['phenomenon_begin_year'] = record.phenomenonTime.begin.position.date8601.year;
44    c['phenomenon_begin_month'] = record.phenomenonTime.begin.position.date8601.month;
45    c['phenomenon_begin_day'] = record.phenomenonTime.begin.position.date8601.day;
46    c['phenomenon_end_year'] = record.phenomenonTime.end.position.date8601.year;
47    c['phenomenon_end_month'] = record.phenomenonTime.end.position.date8601.month;
48    c['phenomenon_end_day'] = record.phenomenonTime.end.position.date8601.day;
49    c['vertical_extent'] = record.verticalExtent;
50    c['resolution'] = record.resolution;
51    c['observed_property'] = record.observedProperty;
52    c['parameters'] = record.parameter;
53    c['project_details'] = record.inSupportOf.relatedParty;
54    c['procedure'] = record.procedure;
55    c['lineage'] = record.dataLineage;
56    c['archive_no_files'] = record.result.numberOfFiles
57    c['geographic_extentE'] = record.geographicExtent[0].eastBoundLongitude
58    c['geographic_extentW'] = record.geographicExtent[0].westBoundLongitude
59    c['geographic_extentN'] = record.geographicExtent[0].northBoundLatitude
60    c['geographic_extentS'] = record.geographicExtent[0].southBoundLatitude
61    c['related_data'] = record.relatedObservation;
62    c['quality_statement'] = record.resultQuality
63    c['keywords'] = record.keywords[0].keyword[0];
64    c['download_link'] = record.result.source[0].linkage
65    c['download_name'] = record.result.source[0].name
66    if len(record.permission.useLimitation[0]) != 0:
67        p = record.permission.useLimitation[0].split(' http://')
68        c['permission'] = mark_safe(p[0] + "  <a href=\"http://" + p[1] + "\" target=\"_blank\">" + p[1] + "<\a>");
69    else:
70        c['permission'] = "These data may be open access. Please contact the data centre to enquire about access to these data."
71    lk = []
72    for l in record.result.source:
73        ls = l.linkage.strip()
74        if len(ls) != 0:
75          lk.append(ls)
76    c['archive_linkage'] = lk
77    c['documentation'] = record.documentation
78    return render_to_response('cedaBrowse.html', c)
79
80def _getCedaObservation(request, obs_id):
81    return Moles3EPB.searchEager(CEDA_Observation, obs_id, request.moles_session)
Note: See TracBrowser for help on using the repository browser.