From fbaa24b9aaf3ff643bc5555b7a910c20947362d7 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 7 Feb 2014 10:13:49 +0000 Subject: [PATCH] support nested smart edit queries --- pandora/edit/models.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/pandora/edit/models.py b/pandora/edit/models.py index 06939dc88..f2f270221 100644 --- a/pandora/edit/models.py +++ b/pandora/edit/models.py @@ -220,15 +220,23 @@ class Edit(models.Model): return clips def clip_query(self): - query = { - 'conditions': [], + def get_conditions(conditions): + clip_conditions = [] + for condition in conditions: + if 'conditions' in condition: + clip_conditions.append({ + 'operator': condition.get('operator', '&'), + 'conditions': get_conditions(condition['conditions']) + }) + elif condition['key'] == 'annotations' or \ + get_by_id(settings.CONFIG['layers'], condition['key']): + clip_conditions.append(condition) + return clip_conditions + + return { + 'conditions': get_conditions(self.query.get('conditions', [])), 'operator': self.query.get('operator', '&') } - for condition in self.query.get('conditions', []): - if condition['key'] == 'annotations' or \ - get_by_id(settings.CONFIG['layers'], condition['key']): - query['conditions'].append(condition) - return query def update_icon(self): frames = []