fix some more usecase

This commit is contained in:
boyska 2022-01-17 01:00:15 +01:00
parent cd94d032e3
commit 803a01357d

View file

@ -24,12 +24,12 @@ class ReadOnlyException(ValueError):
def only_main(f):
'''assumes first argument is id, and must be "main"'''
def wrapper(self, *args):
def wrapper(self, *args, **kwargs):
_id = args[0]
db, db_id = EventModel.parse_id(_id)
if db != 'main':
raise ReadOnlyException('You called a write operation on a readonly db')
return f(self, db_id, *args[1:])
return f(self, db_id, *args[1:], **kwargs)
return wrapper
@ -79,7 +79,7 @@ class EventModel(object):
int(eid_or_aid)
except ValueError:
return eid_or_aid
return 'main:%d' % eid_or_aid
return 'main:%d' % int(eid_or_aid)
@staticmethod
def parse_id(eid_or_aid: Union[str, int]) -> Tuple[str, int]:
@ -121,7 +121,9 @@ class EventModel(object):
def get_all_actions(self) -> list:
out = []
for db in self._dbs:
out.extend(self._dbs[db].table('actions').all())
for action in self._dbs[db].table('actions').all():
action.doc_id = '%s:%s' % (db, action.doc_id)
out.append(action)
return out
def get_all_alarms_expanded(self):