def select_create_action(self): extent = self._extent if extent is not None: method_name = 'create' if method_name in extent.t: m_action = get_method_action(self._db, extent, 't', method_name, self._related) self.select_action(m_action)
def select_create_action(self): extent = self.get_selected() if extent is not None: method_name = 'create' if method_name in extent.t: m_action = action.get_method_action( self._db, extent, 't', method_name) self.select_action(m_action)
def select_update_action(self): selection = self.get_selected() if isinstance(selection, list): if len(selection) == 1: selection = selection[0] else: selection = None if selection is not None: method_name = 'update' if method_name in selection.t: m_action = get_method_action( self._db, selection, 't', method_name) self.select_action(m_action)
def select_delete_action(self): selection = self.get_selected() if isinstance(selection, list): if len(selection) == 1: selection = selection[0] # Pass through to 'if selection is not None' block # below. else: cls = commontype(selection) if cls is None: return method_name = 'delete_selected' if method_name in cls.t: m_action = get_method_action( self._db, cls, 't', method_name) m_action.selection = selection self.select_action(m_action) return if selection is not None: method_name = 'delete' if method_name in selection.t: m_action = get_method_action( self._db, selection, 't', method_name) self.select_action(m_action)
def on_update_clicked(dynamic_field, entity_to_update, done_cb=None): action = get_method_action(db, entity_to_update, 't', 'update') update_tx = action.method() dialog = get_tx_dialog( parent=window, db=db, tx=update_tx, action=action, get_value_handlers=get_value_handlers, set_field_handlers=set_field_handlers, ) dialog.run() tx_result = dialog.tx_result dialog.destroy() if tx_result is not None: if done_cb is not None: done_cb(tx_result) else: field.set(tx_result) field.x.control_widget.set_field(db, field) field.x.control_widget.grab_focus()
def on_create_clicked(dynamic_field, allowed_extents, done_cb=None): if len(allowed_extents) == 1: # If only one extent, simply use that extent. extent = allowed_extents[0] else: # If >1 extent, ask the user for an extent first. dialog = ExtentChoiceWindow(allowed_extents) dialog.set_modal(True) dialog.set_transient_for(window) dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT) dialog.set_title('Select type to create') dialog.run() extent = dialog.selected_extent dialog.destroy() # User may not have chosen an extent. Only continue if # they have. Otherwise do nothing. if extent is not None: action = get_method_action(db, extent, 't', 'create') create_tx = action.method() dialog = get_tx_dialog( parent=window, db=db, tx=create_tx, action=action, get_value_handlers=get_value_handlers, set_field_handlers=set_field_handlers, ) dialog.run() tx_result = dialog.tx_result dialog.destroy() if tx_result is not None: if done_cb is not None: done_cb(tx_result) else: field.set(tx_result) field.x.control_widget.set_field(db, field) field.x.control_widget.grab_focus()
def on_form_box__edit_clicked(self, form_box): model = form_box.model action = get_method_action(form_box.db, model, 't', 'update') update_tx = action.method() dialog = get_tx_dialog( parent=self, db=form_box.db, tx=update_tx, action=action, get_value_handlers=form_box.get_value_handlers, set_field_handlers=form_box.set_field_handlers, ) dialog.run() tx_result = dialog.tx_result dialog.destroy() # Only update field widgets if what we're viewing was what was # updated. if tx_result == model: self.set_fields( tx_result, tx_result.s.field_map().values(), form_box.get_value_handlers, form_box.set_field_handlers, )