aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/controllers/abstract.py
diff options
context:
space:
mode:
authorFrançois Schmidts <francois.schmidts@gmail.com>2015-04-16 08:58:11 +0200
committerFrançois Schmidts <francois.schmidts@gmail.com>2015-04-16 11:37:57 +0200
commita3c2bd47e6d9a64539000d4921ee58eed1ea3968 (patch)
tree479560e61f85ba2546ddb85f9a319a7625f85f9d /pyaggr3g470r/controllers/abstract.py
parentredoing full text search (diff)
downloadnewspipe-a3c2bd47e6d9a64539000d4921ee58eed1ea3968.tar.gz
newspipe-a3c2bd47e6d9a64539000d4921ee58eed1ea3968.tar.bz2
newspipe-a3c2bd47e6d9a64539000d4921ee58eed1ea3968.zip
introducing the or filter component
Diffstat (limited to 'pyaggr3g470r/controllers/abstract.py')
-rw-r--r--pyaggr3g470r/controllers/abstract.py9
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):
bgstack15