Skip to content

Commit

Permalink
all_perspectives template fix
Browse files Browse the repository at this point in the history
  • Loading branch information
A. Tapekhin committed Nov 12, 2015
1 parent 2e5a776 commit c32e862
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lingvodoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def configure_routes(config):
# API #GET
# Perspective list
# 1. Filter by:
# a) template
# b) state
# a) template (param is_template=true/false)
# b) state (param state=<state>)
config.add_route('all_perspectives', '/perspectives')
config.add_route('users', '/users')

Expand Down
13 changes: 9 additions & 4 deletions lingvodoc/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
and_
)
from sqlalchemy.orm import joinedload, subqueryload, noload, join, joinedload_all
from sqlalchemy.sql.expression import case
from sqlalchemy.sql.expression import case, true, false

from collections import deque

Expand Down Expand Up @@ -1743,10 +1743,15 @@ def perspectives_list(request):
except:
pass
persps = DBSession.query(DictionaryPerspective)
if is_template:
persps = persps.filter(DictionaryPerspective).filter_by(is_template=is_template)
if is_template is not None:
if type(is_template) == str:
if is_template.lower() == 'true':
is_template = True
else:
is_template = False
persps = persps.filter(DictionaryPerspective.is_template == is_template)
if state:
persps = persps.filter(DictionaryPerspective).filter_by(state=state)
persps = persps.filter(DictionaryPerspective.state==state)
perspectives = []
for perspective in persps:
path = request.route_url('perspective',
Expand Down

0 comments on commit c32e862

Please sign in to comment.