def spfin_ctrl_action_activate_cb(self, entry, data=None): """Perform current action on bibs listed.""" rlist = entry.get_text() acode = self.action_model.get_value( self.ctrl_action_combo.get_active_iter(), 1) if acode == 'add': rlist = strops.reformat_riderlist(rlist, self.meet.rdb, self.series) for bib in rlist.split(): for cr in self.contests: self.addrider(bib) entry.set_text('') elif acode == 'del': rlist = strops.reformat_riderlist(rlist, self.meet.rdb, self.series) for bib in rlist.split(): self.delrider(bib) entry.set_text('') elif acode == 'com': self.add_comment(rlist) entry.set_text('') return True else: self.log.error('Ignoring invalid action.') return False glib.idle_add(self.delayed_announce)
def do_properties(self): """Run race properties dialog.""" b = gtk.Builder() b.add_from_file(os.path.join(metarace.UI_PATH, 'omnium_properties.ui')) dlg = b.get_object('properties') dlg.set_transient_for(self.meet.window) se = b.get_object('race_series_entry') se.set_text(self.series) re = b.get_object('race_events_entry') re.set_text(self.events) ne = b.get_object('race_nicks_entry') ne.set_text(' '.join(self.nicknames)) as_e = b.get_object('auto_starters_entry') as_e.set_text(self.autospec) response = dlg.run() if response == 1: # id 1 set in glade for "Apply" self.log.debug('Updating race properties.') # update event config self.events = re.get_text() self.nicknames = ne.get_text().split() # update series ns = se.get_text() if ns != self.series: self.series = ns self.event[u'seri'] = ns # update auto startlist spec nspec = as_e.get_text() if nspec != self.autospec: self.autospec = nspec self.event[u'auto'] = nspec if not self.onestart: if self.autospec: self.meet.autostart_riders(self, self.autospec) # xfer starters if not empty slist = strops.reformat_riderlist( b.get_object('race_starters_entry').get_text(), self.meet.rdb, self.series).split() for s in slist: self.addrider(s) self.recalculate() glib.idle_add(self.delayed_announce) else: self.log.debug('Edit race properties cancelled.') # if prefix is empty, grab input focus if self.prefix_ent.get_text() == '': self.prefix_ent.grab_focus() dlg.destroy()
def do_properties(self): """Run race properties dialog.""" b = gtk.Builder() b.add_from_file(os.path.join(metarace.UI_PATH, 'spfin_properties.ui')) dlg = b.get_object('properties') dlg.set_transient_for(self.meet.window) rt = b.get_object('race_score_type') if self.timetype != '200m': rt.set_active(0) else: rt.set_active(1) di = b.get_object('race_dist_entry') if self.distance is not None: di.set_text(str(self.distance)) else: di.set_text('') du = b.get_object('race_dist_type') if self.units == 'metres': du.set_active(0) else: du.set_active(1) se = b.get_object('race_series_entry') se.set_text(self.series) as_e = b.get_object('auto_starters_entry') as_e.set_text(self.autospec) response = dlg.run() if response == 1: # id 1 set in glade for "Apply" self.log.debug('Updating race properties.') if rt.get_active() == 0: self.set_timetype('start/finish') else: self.set_timetype('200m') dval = di.get_text() if dval.isdigit(): self.distance = int(dval) if du.get_active() == 0: self.units = 'metres' else: self.units = 'laps' # update series ns = se.get_text() if ns != self.series: self.series = ns self.event[u'seri'] = ns # update auto startlist spec nspec = as_e.get_text() if nspec != self.autospec: self.autospec = nspec self.event[u'auto'] = nspec if self.autospec: self.meet.autostart_riders(self, self.autospec, self.seedsrc) if self.evtype == 'handicap': self.reorder_handicap() # xfer starters if not empty slist = strops.reformat_riderlist( b.get_object('race_starters_entry').get_text(), self.meet.rdb, self.series).split() for s in slist: for cr in self.contests: self.addrider(s) glib.idle_add(self.delayed_announce) else: self.log.debug('Edit race properties cancelled.') # if prefix is empty, grab input focus if self.prefix_ent.get_text() == '': self.prefix_ent.grab_focus() dlg.destroy()