diff --git a/oml/changelog.py b/oml/changelog.py index 5483af6..935656e 100644 --- a/oml/changelog.py +++ b/oml/changelog.py @@ -171,14 +171,16 @@ class Changelog(db.Model): if not meta[key] and i.meta.get('primaryid', [''])[0] == key: logger.debug('remove id mapping %s %s', i.id, primary) i.update_primaryid(*primary) + i.modified = ts2datetime(timestamp) elif meta[key] and i.meta.get('primaryid') != primary: logger.debug('edit mapping %s %s', i.id, primary) i.update_primaryid(*primary) + i.modified = ts2datetime(timestamp) else: if 'primaryid' in i.meta: return True i.update_meta(meta) - i.modified = ts2datetime(timestamp) + i.modified = ts2datetime(timestamp) i.save() return True diff --git a/oml/nodes.py b/oml/nodes.py index f8db3f1..1d7b1dd 100644 --- a/oml/nodes.py +++ b/oml/nodes.py @@ -251,6 +251,7 @@ class Node(Thread): with self._app.app_context(): last = Changelog.query.filter_by(user_id=self.user_id).order_by('-revision').first() from_revision = last.revision + 1 if last else 0 + logger.debug('pullChanges %s from %s', self.user.name, from_revision) changes = self.request('pullChanges', from_revision) if not changes: return False diff --git a/oml/queryparser.py b/oml/queryparser.py index 0fbeb05..6d8eba5 100644 --- a/oml/queryparser.py +++ b/oml/queryparser.py @@ -126,7 +126,7 @@ class Parser(object): l = None if l: v = l.find_id - if l and l._query: + if l and l.type == 'smart': data = l._query q = self.parse_conditions(data.get('conditions', []), data.get('operator', '&')) diff --git a/oml/user/api.py b/oml/user/api.py index 6d861d6..943b789 100644 --- a/oml/user/api.py +++ b/oml/user/api.py @@ -117,13 +117,19 @@ def getLists(data): actions.register(getLists) def validate_query(query): - for condition in query['conditions']: - if not list(sorted(condition.keys())) in ( - ['conditions', 'operator'], - ['key', 'operator', 'value'] - ): - raise Exception('invalid query condition', condition) + validate_conditions(query['conditions']) +def validate_conditions(conditions): + for c in conditions: + if 'conditions' in c: + if list(sorted(c.keys())) != ['conditions', 'operator']: + raise Exception('invalid query condition', c) + validate_conditions(c) + else: + if list(sorted(c.keys())) != ['key', 'operator', 'value']: + raise Exception('invalid query condition', c) + if c['key'] == 'list' and ':' not in c['value']: + raise Exception('invalid query condition', c) def addList(data): ''' @@ -161,7 +167,9 @@ def editList(data): name = l.name if 'name' in data: l.name = data['name'] - if 'query' in data: + if 'query' in data and l.type != 'smart': + raise Exception('query only for smart lists') + if 'query' in data and l.type == 'smart': validate_query(data['query']) l._query = data['query'] if l.type == 'static' and name != l.name: diff --git a/static/js/listDialog.js b/static/js/listDialog.js index 8898e1b..a24be28 100644 --- a/static/js/listDialog.js +++ b/static/js/listDialog.js @@ -91,7 +91,7 @@ oml.ui.listDialog = function() { }], operator: '&' } - }); + }, false); }); }); }