def _add_production(self): pr = NewProduction() info = pr.edit_traits() db = self.db with db.session_ctx(): while 1: if info.result: if db.get_irradiation_production(pr.name): if self.confirmation_dialog( 'Production Ratio "{}" already exists. Would you like to enter an new name?' ): info = pr.edit_traits() continue else: if self.selected_production: pp = self.selected_production.clone_traits() else: pp = IrradiationProduction() db.add_irradiation_production( name=pr.name, last_modified=datetime.now()) pp.name = pr.name self.productions.append(pp) self.selected_production = next( (pp for pp in self.productions if pp.name == pr.name), None) self.selected_production.editable = True break
def _add_production(self): pr = NewProduction() info = pr.edit_traits() db = self.db with db.session_ctx(): while 1: if info.result: if db.get_irradiation_production(pr.name): if self.confirmation_dialog( 'Production Ratio "{}" already exists. Would you like to enter an new name?'): info = pr.edit_traits() continue else: if self.selected_production: pp = self.selected_production.clone_traits() else: pp = IrradiationProduction() db.add_irradiation_production(name=pr.name, last_modified=datetime.now()) pp.name = pr.name self.productions.append(pp) self.selected_production = next((pp for pp in self.productions if pp.name == pr.name), None) self.selected_production.editable = True break