Changeset 8289
- Timestamp:
- 23/04/12 16:44:17 (9 years ago)
- Location:
- mauRepo/MolesManager/trunk/src/MolesManager
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
mauRepo/MolesManager/trunk/src/MolesManager/static/js/cedaSearch.js
r8280 r8289 1 define(['dojo'], function(dojo){ 2 console.log("loads cedaSearch.js") 3 // function <nameOfFunction>(parameter, parameter2..etc coming in){ 4 // write operations to prepare value to return 5 // 6 // return(<value>); 7 // } 1 ''' 2 Created on 1 Nov 2011 8 3 9 require(['dojo/ready', 'dojo/parser', 'dijit/registry', 'dojo/_base/json', 'dojo/store/Memory', 10 'dijit/Tree', 'dijit/form/Button'], function(ready, parser, registry, Tree){ 11 ready(function () { 12 13 //---------------------------------------------- 14 //----- Initializes the necessary widgets ------ 15 //---------------------------------------------- 16 //var obs_id = new dijit.form.TextBox({ 17 // value: '' /* no or empty value! */ 18 //}, 'obs_id'); 19 //obs_id.startup(); 20 21 var button = new dijit.form.Button({ 22 type: "submit", 23 label: "Search", 24 // onClick: function(){ console.log("First button was clicked!"); } 25 }, "search_obs"); 26 button.startup(); 27 28 var records_dataLineage = new dijit.form.Textarea({ 29 value: "" 30 }, "records_dataLineage"); 31 records_dataLineage.startup(); 4 @author: mnagni 5 ''' 6 from django.shortcuts import render_to_response, redirect 7 from django.core.context_processors import csrf 8 from MolesManager.views import cedaObservationView 9 from MolesManager.ceda_guid import CedaGUID 10 from MolesManager.moles3epb import Moles3EPB 32 11 33 //----------------------------------------------34 //---------- Loads the widgets values ----------35 //----------------------------------------------36 37 var json = dojo.byTitle('coSearch_id').value;38 var coObs = dojo.fromJson(json);39 dojo.attr("title_id", 'value', '');40 });41 });42 });43 12 13 """ 14 def __getResponseByGuid(request, guid): 15 ceda_guid = Moles3EPB.search(CedaGUID, guid, request.moles_session) 16 if ceda_guid and ceda_guid.ceda_observation: 17 return redirect(cedaObservationView.coView, ceda_guid.ceda_observation) 18 """ 19 20 def __doSearch(request, keywords): 21 ''' 22 @param request: an HttpRequest 23 @param keywords: an list of strings 24 @return: the first Observation or None 25 ''' 26 obsevations = Moles3EPB.extractObservationByTitleKeywords(keywords, request.moles_session) 27 titles = [] 28 for o in obsevations: 29 titles.append(o.identifier[0].authority.title) 30 #return obsevations.first() 31 return titles 32 33 34 def coSearch(request): 35 c = {} 36 if 'searchTerm' in request.POST: 37 c['searchResults'] = __doSearch(request, request.POST['searchTerm']) 38 39 c.update(csrf(request)) 40 if c == {} : 41 print "AAA" 42 return render_to_response('cedaObservation.html', c) 43 else : 44 print "BBB" 45 found = False 46 try: 47 a = c['searchResults'] 48 found = True 49 except Exception, ex: 50 pass 51 #for a in c: 52 # b=c[a] 53 # print "b=", b, "a=", a 54 # if a != "csrf_token": 55 # print b.result 56 # #if b.hasattr("__key__"): 57 # # print b.__key__ 58 if not found: 59 return render_to_response('cedaSearch.html', c) 60 return render_to_response('cedaSearchResults.html', c) -
mauRepo/MolesManager/trunk/src/MolesManager/static/templates/cedaSearchResults.html
r8211 r8289 14 14 {% csrf_token %} 15 15 <div id="searchResults"> 16 <ol> 16 17 {% for result in searchResults %} 17 <li> {{ result.identifier[0].authority.title }}</li>18 <li><a href="{{ result }}">{{ result }}</a></li> 18 19 {% endfor %} 20 </ol> 19 21 </div> <!-- End of div myForm --> 20 22 </div> <!-- End of div claro --> -
mauRepo/MolesManager/trunk/src/MolesManager/views/cedaSearch.py
r8282 r8289 20 20 def __doSearch(request, keywords): 21 21 ''' 22 @param request: an HttpRequest 23 @param keywords: an list of strings 24 @return: the first Observation or None 25 ''' 26 obsevations = Moles3EPB.extractObservationByTitleKeywords(keywords, request.moles_session) 27 return obsevations.first() 22 @param request: an HttpRequest 23 @param keywords: an list of strings 24 @return: the first Observation or None 25 ''' 26 obsevations = Moles3EPB.extractObservationByTitleKeywords(keywords, request.moles_session) 27 titles = [] 28 ids = [] 29 baseCov = "http://127.0.0.1:8000/cov/" 30 for o in obsevations: 31 titles.append("".join( 32 [baseCov, 33 str(o.id)#, 34 #'">', 35 #o.identifier[0].code, 36 ])) 37 ids.append(o.id) 38 #return obsevations.first() 39 return titles 28 40 29 41 … … 31 43 c = {} 32 44 if 'searchTerm' in request.POST: 33 c[' records'] = __doSearch(request, request.POST['searchTerm'])45 c['searchResults'] = __doSearch(request, request.POST['searchTerm']) 34 46 35 47 c.update(csrf(request)) 36 48 if c == {} : 49 print "AAA" 37 50 return render_to_response('cedaObservation.html', c) 38 51 else : 39 return render_to_response('cedaSearch.html', c) 52 print "BBB" 53 found = False 54 try: 55 a = c['searchResults'] 56 found = True 57 except Exception, ex: 58 pass 59 #for a in c: 60 # b=c[a] 61 # print "b=", b, "a=", a 62 # if a != "csrf_token": 63 # print b.result 64 # #if b.hasattr("__key__"): 65 # # print b.__key__ 66 if not found: 67 return render_to_response('cedaSearch.html', c) 68 return render_to_response('cedaSearchResults.html', c)
Note: See TracChangeset
for help on using the changeset viewer.