Changeset 8507 for mauRepo/MolesManager


Ignore:
Timestamp:
10/08/12 15:32:06 (7 years ago)
Author:
mnagni
Message:

Incomplete - # 22534: Add versiojn number to the gui page
 http://team.ceda.ac.uk/trac/ceda/ticket/22534

Location:
mauRepo/MolesManager/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/MolesManager/trunk/cedaMoles/MolesManager/molesSessionMiddleware.py

    r8486 r8507  
    4242from django.core.context_processors import csrf 
    4343from django.shortcuts import render_to_response 
     44from cedaMoles import __version__ 
    4445 
    4546 
     
    8990    def process_response(self, request, response): 
    9091        if hasattr(request, "moles3EPB"):             
    91             request.moles3EPB.close() 
    92              
     92            request.moles3EPB.close()             
    9393        return response 
    9494 
     
    102102    if runMigration and not MolesSessionMiddleware._migrationThread.isAlive(): 
    103103        #t.setDaemon(False) 
    104         MolesSessionMiddleware._migrationThread.start()         
     104        MolesSessionMiddleware._migrationThread.start()     
     105         
     106 
     107def mm_render_to_response(request, context, page_to_render): 
     108    """ 
     109    Exploit a 'render_to_response' action. The advantage of this method 
     110    is to contains a number of operations that are expected to be  called 
     111    for each page rendering, for example passing the application version number 
     112      
     113    **Parameters**             
     114        * HttpRequest_ **request** 
     115            a django HttpRequest instance        
     116        * `dict` **context** 
     117            a dictionary where to pass parameter to the rendering function    
     118        * `string` **page_to_render** 
     119            the html page to render                          
     120    """ 
     121    if context is None or not isinstance(context, dict): 
     122        raise Exception("Cannot render an empty context") 
     123     
     124    context['version'] = __version__ 
     125    context.update(csrf(request)) 
     126    return render_to_response(page_to_render, context)             
  • mauRepo/MolesManager/trunk/cedaMoles/MolesManager/static/templates/base.html

    r8503 r8507  
    149149                        </div> <!-- End div footerLogos--> 
    150150                        <div class="grid_6 push_3 whiteFill omega" id="footerStatements"> 
    151                                 <p>Copyright &copy; 2011 STFC&nbsp;&nbsp;|&nbsp;&nbsp;All Rights Reserved</p> 
     151                                <p>Copyright &copy; 2011 STFC&nbsp;&nbsp;|&nbsp;&nbsp;All Rights Reserved - Version {{ version }} </p> 
    152152           
    153153                                <p class="credits">Based on 960.gs with design elements from <a href="http://1234.info/" title="Designer Homepage">1234.info</a> | <a href="http://validator.w3.org/check?uri=referer" title="Validate XHTML code">XHTML 1.0</a> | <a href="http://jigsaw.w3.org/css-validator/" title="Validate CSS code">CSS 2.0</a> </p> 
  • mauRepo/MolesManager/trunk/cedaMoles/MolesManager/views/cedaObservationView.py

    r8486 r8507  
    3636from ea_model.ceda_metadatamodel.ceda_observation.ceda_observation import CEDA_Observation 
    3737from cedaMoles.MolesManager.views.moles2gui import encodeCedaMoles2Json 
     38from cedaMoles.MolesManager.molesSessionMiddleware import mm_render_to_response 
    3839 
    3940 
     
    5051     
    5152def _finalizeResponse(request, record): 
    52     c = {} 
     53    context = {} 
    5354    if record: 
    54         c['coObs'] = encodeToJSON(record) 
     55        context['coObs'] = encodeToJSON(record) 
    5556         
    56         #c['new_coObs'] = encodeCedaMoles2Json(record) 
     57        context['new_coObs'] = encodeCedaMoles2Json(record) 
    5758         
    5859        guid = request.moles3EPB.retrieveGUIDFromInstance(record) 
    5960        if guid: 
    60             c['guid'] = guid.id 
    61             print c['guid'] 
    62         print c['coObs']  
    63      
    64     c.update(csrf(request)) 
    65     return render_to_response('cedaObservation.html', c) 
     61            context['guid'] = guid.id 
     62            print context['guid'] 
     63        print context['coObs']  
     64         
     65    return mm_render_to_response(request, 'cedaObservation.html', context) 
    6666 
    6767def _getCedaObservation(request, obs_id):     
  • mauRepo/MolesManager/trunk/cedaMoles/MolesManager/views/cedaSearch.py

    r8503 r8507  
    99import cedaObservationView 
    1010import cedaObservationCollectionView 
     11from cedaMoles.MolesManager.molesSessionMiddleware import mm_render_to_response 
    1112 
    1213def getResponseByGuid(request, guid): 
     
    4849 
    4950def coSearch(request): 
    50     c = {}     
     51    context = {}     
    5152    if 'searchTerm' in request.POST: 
    52         c['searchResults'] = __doSearch(request, request.POST['searchTerm']) 
     53        context['searchResults'] = __doSearch(request, request.POST['searchTerm']) 
    5354             
    54     c.update(csrf(request)) 
    55     if c == {} : 
    56         return render_to_response('cedaObservation.html', c 
     55    context.update(csrf(request)) 
     56    if context == {} : 
     57        return render_to_response('cedaObservation.html', context 
    5758    else : 
    5859        found = False 
    5960    try: 
    60         a = c['searchResults'] 
     61        a = context['searchResults'] 
    6162        found = True 
    6263    except Exception, ex: 
    6364        pass 
    6465    if not found: 
    65             return render_to_response('cedaSearch.html', c) 
    66     return render_to_response('cedaSearchResults.html', c) 
     66            return mm_render_to_response(request, context, 'cedaSearch.html') 
     67    return mm_render_to_response(request, context, 'cedaSearchResults.html') 
  • mauRepo/MolesManager/trunk/cedaMoles/MolesManager/views/moles2gui/__init__.py

    r8486 r8507  
    9595        if type(cedaObject) in cls.acceptedTypes:        
    9696            for item in cls.mapper.items(): 
    97                 setattr(instance, item[0], getData(cedaObject, item[1])) 
     97                if item[0] == 'resultTime' and item[1] == 'resultTime': 
     98                    print item[0] 
     99                try:                         
     100                    setattr(instance, item[0], getData(cedaObject, item[1])) 
     101                except Exception as e: 
     102                    print e 
    98103 
    99104    @classmethod 
     
    146151        setattr(adapter, '_adapter_module', adapter.__module__)         
    147152        setattr(adapter, '_adapter_clazz', adapter.__class__.__name__) 
    148              
    149153        cls._cedaObjToAdapterMapping(adapter, cedaObject) 
    150154        adapter.postCedaObjToAdapterMapping(cedaObject) 
     
    318322        encoder = dynamicallyLoadClass(module, clazz) 
    319323        return encoder.cedaObjToAdapter(cedaObj) 
     324 
    320325     
    321326    # Then is a non mapped class 
  • mauRepo/MolesManager/trunk/docs/source/src/index.rst

    r8476 r8507  
    22Ceda Moles3 API 
    33=============== 
     4.. _HttpRequest: https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest 
    45 
    56.. toctree:: 
Note: See TracChangeset for help on using the changeset viewer.