fix some more usecase
This commit is contained in:
parent
cd94d032e3
commit
803a01357d
1 changed files with 6 additions and 4 deletions
|
@ -24,12 +24,12 @@ class ReadOnlyException(ValueError):
|
||||||
|
|
||||||
def only_main(f):
|
def only_main(f):
|
||||||
'''assumes first argument is id, and must be "main"'''
|
'''assumes first argument is id, and must be "main"'''
|
||||||
def wrapper(self, *args):
|
def wrapper(self, *args, **kwargs):
|
||||||
_id = args[0]
|
_id = args[0]
|
||||||
db, db_id = EventModel.parse_id(_id)
|
db, db_id = EventModel.parse_id(_id)
|
||||||
if db != 'main':
|
if db != 'main':
|
||||||
raise ReadOnlyException('You called a write operation on a readonly db')
|
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
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ class EventModel(object):
|
||||||
int(eid_or_aid)
|
int(eid_or_aid)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return eid_or_aid
|
return eid_or_aid
|
||||||
return 'main:%d' % eid_or_aid
|
return 'main:%d' % int(eid_or_aid)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse_id(eid_or_aid: Union[str, int]) -> Tuple[str, int]:
|
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:
|
def get_all_actions(self) -> list:
|
||||||
out = []
|
out = []
|
||||||
for db in self._dbs:
|
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
|
return out
|
||||||
|
|
||||||
def get_all_alarms_expanded(self):
|
def get_all_alarms_expanded(self):
|
||||||
|
|
Loading…
Reference in a new issue