Changeset 4668 for MILK


Ignore:
Timestamp:
16/12/08 17:03:18 (11 years ago)
Author:
cbyrom
Message:

Refactor to reflect updates to ndgUtils structure.
Pull out various constants from controllers to separate file - so these
can be referenced easily by tests.
Implement test_listatom.py - to test the listatom controller.

Location:
MILK/trunk/milk_server
Files:
3 added
7 edited

Legend:

Unmodified
Added
Removed
  • MILK/trunk/milk_server/milk_server/controllers/atom_editor/editatom.py

    r4625 r4668  
    2424from ndgUtils.models.MolesEntity import MolesEntity as ME 
    2525from ndgUtils.lib.utilities import escapeSpecialCharacters 
    26 from ndgUtils.vocabtermdata import VocabTermData as VTD 
     26from ndgUtils.models.vocabtermdata import VocabTermData as VTD 
    2727from ndgUtils.lib.granulite import granulite 
    2828 
  • MILK/trunk/milk_server/milk_server/controllers/atom_editor/listatom.py

    r4625 r4668  
    1313import ndgUtils.lib.existdbclient as edc 
    1414from ndgUtils.models.MolesEntity import MolesEntity as ME 
    15 from ndgUtils.vocabtermdata import VocabTermData as VTD, VocabTermItem as VTI 
     15from ndgUtils.models.vocabtermdata import VocabTermData as VTD, VocabTermItem as VTI 
    1616from milk_server.lib.base import * 
     17from editorconstants import * 
    1718import milk_server.lib.htmlUtilities as utils 
    1819from milk_server.lib.atomutilities import savePageAndRender 
    1920from editatom import EditatomController as ec 
    2021 
    21  
     22    
    2223class ListatomController(BaseController): 
    2324    '''  
     
    4647        ''' 
    4748        logging.info("Rendering atom home page") 
    48         c.title = "Atom Editor Home Page" 
     49        c.title = ATOM_HOME_TITLE 
    4950        return savePageAndRender(self.pathInfo, "atom_editor/atom_home") 
    5051 
     
    5556        ''' 
    5657        logging.info("Rendering example granulite file page") 
    57         c.title = "Example granulite file" 
     58        c.title = EXAMPLE_GRANULITE_TITLE 
    5859        return savePageAndRender(self.pathInfo, "atom_editor/granulite_example") 
    5960     
     
    6566        - display a filter + display any results + if an atomID is 
    6667        provided, allow atoms to be linked to this 
     68        @keyword searchData: if '1' do a search, if '0' just display search filter 
    6769        @keyword associatedAtomID: the ID of an atom to which other atoms 
    6870        should be linked - via deployments  
     
    98100            logging.info("Rendering atom listings page") 
    99101            c.errors = {} 
    100             c.title='Browse atoms' 
     102            c.title = LIST_ATOM_TITLE 
    101103            c.assocAtomType = associatedAtomType 
    102104            c.associateLink = "" 
     
    119121                val = int(associationType) 
    120122                if val == utils.GRANULE_ASSOCIATION: 
    121                     c.title += ' - to create associations with granule data' 
     123                    c.title += GRANULE_ASSOCIATION_TITLE 
    122124                    listVals = [g.vtd.TERM_DATA[g.vtd.GRANULE_TERM]] 
    123125                elif val == utils.DEPLOYMENT_ASSOCIATION: 
    124                     c.title += ' - to create associations with deployment data' 
     126                    c.title += DEPLOYMENTS_ASSOCIATION_TITLE 
    125127                    listVals = [g.vtd.TERM_DATA[g.vtd.DEPLOYMENT_TERM]] 
    126128                elif val == utils.ENTITY_ASSOCIATION: 
    127                     c.title += ' - to create associations with activity/data production tool/observation station data' 
     129                    c.title += DEPLOYMENTS_DATA_ASSOCIATION_TITLE 
    128130                    listVals = g.vtd.getValidTypes(g.vtd.DEPLOYABLE_ATOM_CATEGORY) 
    129131                    defaultVal = allVal 
  • MILK/trunk/milk_server/milk_server/controllers/browse/retrieve.py

    r4625 r4668  
    1010import logging 
    1111from ndgUtils.models.Atom import Atom 
    12 from ndgUtils.vocabtermdata import VocabTermData as VTD 
     12from ndgUtils.models.vocabtermdata import VocabTermData as VTD 
    1313from ndgUtils import DocumentRetrieve 
    1414 
  • MILK/trunk/milk_server/milk_server/lib/app_globals.py

    r4348 r4668  
    11from pylons import config 
    2 from ndgUtils.vocabtermdata import VocabTermData as VTD 
     2from ndgUtils.models.vocabtermdata import VocabTermData as VTD 
    33 
    44class Globals(object): 
  • MILK/trunk/milk_server/milk_server/lib/htmlUtilities.py

    r4469 r4668  
    5656    else: 
    5757        return t 
    58      
     58 
     59def getVocabTermDataSelectValue(vti): 
     60    ''' 
     61    Given a vocab term item, return the select value for use in a drop down list 
     62    @param vti: a VocabTermItem 
     63    @return: select value - in format, vti.vocabURL--vti.termID 
     64    ''' 
     65    return "%s--%s" %(vti.vocabURL, vti.termID) 
     66 
    5967 
    6068def getVocabTermDataDropdown(list, selected=None, defaultVal=None): 
     
    7280     
    7381    if defaultVal: 
    74         r+='<option value="%s--%s">%s</option>' %(defaultVal.vocabURL, \ 
    75             defaultVal.termID, defaultVal.title or defaultVal.termID) 
     82        r+='<option value="%s">%s</option>' %(getVocabTermDataSelectValue(defaultVal), \ 
     83                                              defaultVal.title or defaultVal.termID) 
    7684 
    7785    # NB, need to include both vocabURL and term ID for the data to be 
     
    8492            selected.startswith(val.vocabURL): 
    8593            default='selected="selected"' 
    86         r+='<option value="%s--%s" %s>%s</option>' %(val.vocabURL, \ 
    87             val.termID, default, val.title or val.termID) 
     94        r+='<option value="%s" %s>%s</option>' %(getVocabTermDataSelectValue(val), \ 
     95                                                default, val.title or val.termID) 
    8896     
    8997    logging.debug("- produced drop down contents: '%s'" %r) 
  • MILK/trunk/milk_server/milk_server/templates/atom_editor/atom_list.html

    r4626 r4668  
    88        <title py:content="c.title">title</title> 
    99    </head> 
     10    <?python from milk_server.controllers.atom_editor.editorconstants import *?> 
     11     
    1012  <body class="submit"> 
    1113      <panelTab>Editor</panelTab> 
    1214      <div id="contents"> 
    1315            <div class="metadata"> 
    14                             <h3><a href="${h.url_for(controller='atom_editor/listatom',action='atomHome')}">Home</a></h3> 
     16                            <h3><a href="${h.url_for('atomHome')}">Home</a></h3> 
    1517                            <h3>  $c.title  
    1618                            <span py:replace="helpIcon('list_help', 'div')"/> 
     
    6062                        <div class="headingblock"> 
    6163                                <table py:if="not c.results"> 
    62                                         <tr><td>No data found for search selections</td></tr> 
     64                                        <tr><td>$NO_SEARCH_RESULTS</td></tr> 
    6365                                </table> 
    6466                                <form action="${c.associateLink}" method="post"> 
  • MILK/trunk/milk_server/test.ini

    r4466 r4668  
    1919 
    2020# Add additional test specific configuration options as necessary. 
     21configfile = test.config 
Note: See TracChangeset for help on using the changeset viewer.