Changeset 1178

Show
Ignore:
Timestamp:
03/07/10 15:49:29 (5 months ago)
Author:
erikj
Message:

add confirm_delete class attribute to ObjectAdmin?

Location:
trunk/camelot
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/camelot/admin/object_admin.py

    r1141 r1178  
    113113    searched.  For use with one2many, many2one or many2many fields, the same 
    114114    rules as for the list_filter attribute apply 
     115     
     116    .. attribute:: confirm_delete 
     117     
     118    Indicates if the deletion of an object should be confirmed by the user, defaults 
     119    to False.  Can be set to either True, False, or the message to display when asking 
     120    confirmation of the deletion. 
    115121 
    116122    .. attribute:: form_size 
     
    172178    list_actions = [] 
    173179    list_search = [] 
     180    confirm_delete = False 
    174181    list_size = (600, 400) 
    175182    form_size = (700, 500) 
     
    234241    def get_entity_admin(self, entity): 
    235242        return self.app_admin.get_entity_admin(entity) 
     243     
     244    def get_confirm_delete(self): 
     245        if self.confirm_delete: 
     246            if self.confirm_delete==True: 
     247                return _('Are you sure you want to delete this') 
     248            return self.confirm_delete 
     249        return False 
    236250 
    237251    @model_function 
  • trunk/camelot/view/controls/formview.py

    r1176 r1178  
    3838 
    3939class FormView( AbstractView ): 
     40 
    4041    def __init__( self, title, admin, model, index ): 
    4142        AbstractView.__init__( self ) 
  • trunk/camelot/view/controls/tableview.py

    r1164 r1178  
    372372        """delete the selected rows in this tableview""" 
    373373        logger.debug( 'delete selected rows called' ) 
    374         for row in set( map( lambda x: x.row(), self.table.selectedIndexes() ) ): 
    375             self._table_model.removeRow( row ) 
     374        confirmation_message = self.admin.get_confirm_delete() 
     375        confirmed = True 
     376        if confirmation_message: 
     377            if QtGui.QMessageBox.question(self,  
     378                                          _('Please confirm'),  
     379                                          unicode(confirmation_message),  
     380                                          QtGui.QMessageBox.Yes,  
     381                                          QtGui.QMessageBox.No) == QtGui.QMessageBox.No: 
     382                confirmed = False 
     383        if confirmed: 
     384            for row in set( map( lambda x: x.row(), self.table.selectedIndexes() ) ): 
     385                self._table_model.removeRow( row ) 
    376386       
    377387    @gui_function 
  • trunk/camelot/view/wizard/importwizard.py

    r1038 r1178  
    342342            row_data_admin.get_columns 
    343343        ) 
    344  
     344        self.setWindowTitle(_(self.window_title)) 
     345        self.add_pages(model, row_data_admin) 
     346        self.setOption(QtGui.QWizard.NoCancelButton) 
     347 
     348    def add_pages(self, model, row_data_admin): 
     349        """ 
     350        Add all pages to the import wizard, reimplement this method to add 
     351        custom pages to the wizard 
     352        :param model: the CollectionProxy that will be used to display the to be imported data 
     353        :param row_dat_admin: the admin interface to be used to display the model, this admin 
     354        is automatically derived from the admin of the data once it is imported 
     355        """ 
    345356        self.addPage(SelectFilePage(parent=self)) 
    346357        self.addPage( 
     
    351362            ) 
    352363        ) 
    353         self.addPage(FinalPage(parent=self, model=model)) 
    354         self.setWindowTitle(_(self.window_title)) 
    355  
    356         self.setOption(QtGui.QWizard.NoCancelButton) 
     364        self.addPage(FinalPage(parent=self, model=model))