Fix some minor bugs in event connection/locking
This commit is contained in:
parent
38563a6593
commit
9c091b29e9
2 changed files with 13 additions and 7 deletions
|
|
@ -254,7 +254,7 @@ class CmdEvent(COMMAND_DEFAULT_CLASS):
|
|||
row.append("Yes" if event.get("valid") else "No")
|
||||
table.add_row(*row)
|
||||
|
||||
self.msg(table)
|
||||
self.msg(unicode(table))
|
||||
else:
|
||||
names = list(set(list(types.keys()) + list(events.keys())))
|
||||
table = EvTable("Event name", "Number", "Description",
|
||||
|
|
@ -271,7 +271,7 @@ class CmdEvent(COMMAND_DEFAULT_CLASS):
|
|||
description = description.splitlines()[0]
|
||||
table.add_row(name, no, description)
|
||||
|
||||
self.msg(table)
|
||||
self.msg(unicode(table))
|
||||
|
||||
def add_event(self):
|
||||
"""Add an event."""
|
||||
|
|
@ -292,6 +292,11 @@ class CmdEvent(COMMAND_DEFAULT_CLASS):
|
|||
# Open the editor
|
||||
event = self.handler.add_event(obj, event_name, "",
|
||||
self.caller, False, parameters=self.parameters)
|
||||
|
||||
# Lock this event right away
|
||||
self.handler.db.locked.append((obj, event_name, event["number"]))
|
||||
|
||||
# Open the editor for this event
|
||||
self.caller.db._event = event
|
||||
EvEditor(self.caller, loadfunc=_ev_load, savefunc=_ev_save,
|
||||
quitfunc=_ev_quit, key="Event {} of {}".format(
|
||||
|
|
@ -456,7 +461,7 @@ class CmdEvent(COMMAND_DEFAULT_CLASS):
|
|||
updated_on = "|gUnknown|n"
|
||||
|
||||
table.add_row(obj.id, type_name, obj, name, by, updated_on)
|
||||
self.msg(table)
|
||||
self.msg(unicode(table))
|
||||
return
|
||||
|
||||
# An object was specified
|
||||
|
|
@ -517,7 +522,7 @@ class CmdEvent(COMMAND_DEFAULT_CLASS):
|
|||
delta = time_format((future - now).total_seconds(), 1)
|
||||
table.add_row(task_id, key, event_name, delta)
|
||||
|
||||
self.msg(table)
|
||||
self.msg(unicode(table))
|
||||
|
||||
# Private functions to handle editing
|
||||
def _ev_load(caller):
|
||||
|
|
|
|||
|
|
@ -114,9 +114,10 @@ def connect_event_types():
|
|||
if script.ndb.event_types is None:
|
||||
return
|
||||
|
||||
while event_types:
|
||||
t_event_types = list(event_types)
|
||||
while t_event_types:
|
||||
typeclass_name, event_name, variables, help_text, \
|
||||
custom_add, custom_call = event_types[0]
|
||||
custom_add, custom_call = t_event_types[0]
|
||||
|
||||
# Get the event types for this typeclass
|
||||
if typeclass_name not in script.ndb.event_types:
|
||||
|
|
@ -126,7 +127,7 @@ def connect_event_types():
|
|||
# Add or replace the event
|
||||
help_text = dedent(help_text.strip("\n"))
|
||||
types[event_name] = (variables, help_text, custom_add, custom_call)
|
||||
del event_types[0]
|
||||
del t_event_types[0]
|
||||
|
||||
# Custom callbacks for specific event types
|
||||
def get_next_wait(format):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue