diff options
Diffstat (limited to 'pyaggr3g470r/controllers')
-rw-r--r-- | pyaggr3g470r/controllers/abstract.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/pyaggr3g470r/controllers/abstract.py b/pyaggr3g470r/controllers/abstract.py index 29905c0c..9a9004af 100644 --- a/pyaggr3g470r/controllers/abstract.py +++ b/pyaggr3g470r/controllers/abstract.py @@ -1,5 +1,6 @@ import logging from bootstrap import db +from sqlalchemy import or_ from werkzeug.exceptions import Forbidden, NotFound logger = logging.getLogger(__name__) @@ -27,11 +28,11 @@ class AbstractController(object): name of the parameter ends with either "__gt", "__lt", "__ge", "__le", "__ne", "__in" ir "__like". """ - if self.user_id is not None: - filters[self._user_id_key] = self.user_id db_filters = set() for key, value in filters.items(): - if key.endswith('__gt'): + if key == '__or__': + db_filters.add(or_(*self._to_filters(**value))) + elif key.endswith('__gt'): db_filters.add(getattr(self._db_cls, key[:-4]) > value) elif key.endswith('__lt'): db_filters.add(getattr(self._db_cls, key[:-4]) < value) @@ -50,6 +51,8 @@ class AbstractController(object): return db_filters def _get(self, **filters): + if self.user_id is not None: + filters[self._user_id_key] = self.user_id return self._db_cls.query.filter(*self._to_filters(**filters)) def get(self, **filters): |