Changeset 5000


Ignore:
Timestamp:
3 Feb 2010, 16:13:41 (15 years ago)
Author:
uli
Message:

Allow only mode of pending file when batchprocessing is started with a pending file that provides some mode info in filename.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/browser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py

    r4997 r5000  
    381381    mode = 'create'
    382382    importer = None
     383    mode_locked = False
    383384
    384385    def getPreviewHeader(self):
     
    410411            dict(title=x.name, name=x.util_name) for x in importers]
    411412        return importers
    412        
    413    
     413
     414    def getModeFromFilename(self, filename):
     415        """Lookup filename or path and return included mode name or None.
     416        """
     417        if not filename.endswith('.pending.csv'):
     418            return None
     419        base = os.path.basename(filename)
     420        parts = base.rsplit('.', 3)
     421        if len(parts) != 4:
     422            return None
     423        if parts[1] not in ['create', 'update', 'remove']:
     424            return None
     425        return parts[1]
     426
    414427    def update(self, mode=None, importer=None,
    415428               back1=None, cancel=None, proceed=None):
     
    425438            return
    426439        self.mode = mode or session.get('import_mode', self.mode)
     440        filename_mode = self.getModeFromFilename(self.filename)
     441        if filename_mode is not None:
     442            self.mode = filename_mode
     443            self.mode_locked = True
    427444        self.importer = importer or session.get('import_importer', None)
    428445        session['import_mode'] = self.mode
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/datacenterimport2page.pt

    r4858 r5000  
    6161
    6262    <input type="radio" name="mode" value="create" checked="checked"
    63            tal:attributes="checked python: view.mode == 'create' and 'checked' or ''" /> Create
     63           tal:attributes="checked python: view.mode == 'create' and 'checked' or '';
     64                           disabled python: view.mode != 'create' and view.mode_locked and 'disabled' or ''" /> Create
    6465    &nbsp;&nbsp;
    6566    <input type="radio" name="mode" value="update"
    66            tal:attributes="checked python: view.mode == 'update' and 'checked' or ''" /> Update
     67           tal:attributes="checked python: view.mode == 'update' and 'checked' or '';
     68                           disabled python: view.mode != 'update' and view.mode_locked and 'disabled' or ''" /> Update
    6769    &nbsp;&nbsp;
    6870    <input type="radio" name="mode" value="remove"
    69            tal:attributes="checked python: view.mode == 'remove' and 'checked' or ''" /> Remove
     71           tal:attributes="checked python: view.mode == 'remove' and 'checked' or '';
     72                           disabled python: view.mode != 'remove' and view.mode_locked and 'disabled' or ''" /> Remove
    7073
    7174    <p>&nbsp;</p>
Note: See TracChangeset for help on using the changeset viewer.