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