Changeset 4725 for MILK


Ignore:
Timestamp:
05/01/09 09:53:59 (11 years ago)
Author:
cbyrom
Message:

Use webhelpers to set up drop down lists - rather than custom code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • MILK/trunk/milk_server/milk_server/lib/htmlUtilities.py

    r4668 r4725  
    33# 
    44import logging 
    5  
     5from webhelpers import * 
    66GRANULE_ASSOCIATION = 1 
    77DEPLOYMENT_ASSOCIATION = 2 
     
    6060    ''' 
    6161    Given a vocab term item, return the select value for use in a drop down list 
     62    - NB, this avoids check for current version of the term ID 
    6263    @param vti: a VocabTermItem 
    6364    @return: select value - in format, vti.vocabURL--vti.termID 
     
    7374    @keyword defaultVal: an additional item to add - to represent a default - e.g. 
    7475    'all' or 'none' 
     76    @return r: html select string - with all required options added 
    7577    ''' 
    7678    logging.debug("Setting up drop down list for data") 
     
    7981    r='' 
    8082     
     83    vals = [] 
    8184    if defaultVal: 
    82         r+='<option value="%s">%s</option>' %(getVocabTermDataSelectValue(defaultVal), \ 
    83                                               defaultVal.title or defaultVal.termID) 
     85        vals.append([defaultVal.title or defaultVal.termID, \ 
     86                     getVocabTermDataSelectValue(defaultVal)]) 
    8487 
    8588    # NB, need to include both vocabURL and term ID for the data to be 
    8689    # meaningful 
     90    select = None 
    8791    for val in list: 
    88         default='' 
     92        optionVal = getVocabTermDataSelectValue(val) 
     93        vals.append([val.title or val.termID, optionVal]) 
     94 
    8995        # NB, the selected val will be the full, latest term url - so only 
    9096        # compare the start and end for match 
    9197        if selected and selected.endswith(val.termID) and \ 
    9298            selected.startswith(val.vocabURL): 
    93             default='selected="selected"' 
    94         r+='<option value="%s" %s>%s</option>' %(getVocabTermDataSelectValue(val), \ 
    95                                                  default, val.title or val.termID) 
     99            select = optionVal 
     100 
     101    options = options_for_select(vals, select) 
     102    logging.debug("- produced drop down contents: '%s'" %r) 
     103    return options 
    96104     
    97     logging.debug("- produced drop down contents: '%s'" %r) 
    98     return r 
    99      
Note: See TracChangeset for help on using the changeset viewer.