Allow for multiple status selection in the API
This commit is contained in:
1 parent
b8fb68f05d
commit
85c3b16e69
2 files changed
+8
-4
No files matched your search
@@ -5,6 +5,7 @@ from couchpotato.core.helpers.request import getParams, jsonified
|
|||||||
from couchpotato.core.plugins.base import Plugin
|
from couchpotato.core.plugins.base import Plugin
|
||||||
from couchpotato.core.settings.model import Movie
|
from couchpotato.core.settings.model import Movie
|
||||||
from couchpotato.environment import Env
|
from couchpotato.environment import Env
|
||||||
|
from sqlalchemy.sql.expression import or_
|
||||||
from urllib import urlencode
|
from urllib import urlencode
|
||||||
|
|
||||||
|
|
||||||
@@ -32,9 +33,12 @@ class MoviePlugin(Plugin):
|
|||||||
params = getParams()
|
params = getParams()
|
||||||
db = get_session()
|
db = get_session()
|
||||||
|
|
||||||
results = db.query(Movie).filter(
|
# Make a list from string
|
||||||
Movie.status.has(identifier = params.get('status', 'active'))
|
status = params.get('status', ['active'])
|
||||||
).all()
|
if not isinstance(status, (list, tuple)):
|
||||||
|
status = [status]
|
||||||
|
|
||||||
|
results = db.query(Movie).filter(or_(*[Movie.status.has(identifier = s) for s in status])).all()
|
||||||
|
|
||||||
movies = []
|
movies = []
|
||||||
for movie in results:
|
for movie in results:
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ Page.Wanted = new Class({
|
|||||||
|
|
||||||
// Wanted movies
|
// Wanted movies
|
||||||
self.wanted = new MovieList({
|
self.wanted = new MovieList({
|
||||||
'status': 'active',
|
'status': ['active', 'snatched'],
|
||||||
'actions': WantedActions
|
'actions': WantedActions
|
||||||
});
|
});
|
||||||
$(self.wanted).inject(self.el);
|
$(self.wanted).inject(self.el);
|
||||||
|
|||||||
Reference in new issue
Block a user