Changeset 1178

Show
Ignore:
Timestamp:
07/25/08 05:32:59
Author:
piv
Message:

fixed action adding

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/plonetabs.py

    r1177 r1178  
    117117        """ Manage method to add a new action to given category, 
    118118            if category doesn't exist, create it """ 
    119         cat_name = form['category'] 
     119        # extract posted data 
     120        id, cat_name, data = self.parseAddForm(form) 
    120121         
    121122        # validate posted data 
    122         errors = self.validateActionFields(cat_name, form
     123        errors = self.validateActionFields(cat_name, data
    123124         
    124125        # if not errors find (or create) category and set action to it 
     
    136137        """ Manage Method to update action """ 
    137138        # extract posted data 
    138         id, cat_name, data = self.parseForm(form) 
     139        id, cat_name, data = self.parseEditForm(form) 
    139140         
    140141        # get category and action to edit 
     
    158159        """ Manage Method to delete action """ 
    159160        # extract posted data 
    160         id, cat_name, data = self.parseForm(form) 
     161        id, cat_name, data = self.parseEditForm(form) 
    161162         
    162163        # get category and action to delete 
     
    590591        return result 
    591592     
    592     def parseForm(self, form): 
    593         """ Extract all needed fields """ 
     593    def parseEditForm(self, form): 
     594        """ Extract all needed fields from edit form """ 
    594595        # get original id and category 
    595596        info = {} 
     
    606607        for attr in ACTION_ATTRS: 
    607608            info[attr] = form['%s_%s' % (attr, id)] 
     609         
     610        return (id, category, info) 
     611     
     612    def parseAddForm(self, form): 
     613        """ Extract all needed fields from add form """ 
     614        info = {} 
     615        id = form['id'] 
     616        category = form['category'] 
     617         
     618        # preprocess 'visible' field (checkbox needs special checking) 
     619        if form.has_key('visible'): 
     620            form['visible'] = True 
     621        else: 
     622            form['visible'] = False 
     623         
     624        # collect all action fields 
     625        for attr in ACTION_ATTRS: 
     626            info[attr] = form[attr] 
    608627         
    609628        return (id, category, info)