Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Shelter Database
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
CHARISM
Shelter Database
Commits
befc7c6c
Commit
befc7c6c
authored
Aug 24, 2016
by
Aron Gergely
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed deprecated code
parent
eb6eb791
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
43 deletions
+0
-43
src/web/views/shelterapiv02.py
src/web/views/shelterapiv02.py
+0
-43
No files found.
src/web/views/shelterapiv02.py
View file @
befc7c6c
...
...
@@ -25,33 +25,6 @@ apiv02_bp = Blueprint('development api v0.2', __name__, url_prefix='/api/v0.2')
def
tree
():
return
defaultdict
(
tree
)
def
queryfactory
(
model
,
join
=
False
,
filt
=
False
,
value
=
False
):
#helper functions to construct queries
def
filter_or
(
obj
,
attrib
,
val
):
"""Construct filtering method (OR)"""
list
(
val
)
if
len
(
val
)
==
1
:
return
obj
.
filter
(
attrib
==
val
[
0
])
else
:
return
obj
.
filter
(
attrib
.
in_
(
val
))
def
filter_and
(
obj
,
attrib
,
val
):
"""Construct filtering methods recursively (AND)"""
list
(
val
)
if
len
(
val
)
==
1
:
return
obj
.
filter
(
attrib
==
val
[
0
])
else
:
return
filter_and
(
obj
.
filter
(
attrib
==
val
[
len
(
val
)
-
1
]),
attrib
,
val
[
0
:
len
(
val
)
-
1
])
if
join
and
not
filt
:
return
model
.
query
.
join
(
join
)
elif
filt
and
join
:
return
filter_or
(
model
.
query
.
join
(
join
),
filt
,
value
)
elif
filt
and
not
join
:
return
filter_or
(
model
.
in_
(
value
))
else
:
return
"error"
@
apiv02_bp
.
route
(
'/'
,
methods
=
[
'GET'
])
def
apimessage
():
...
...
@@ -169,19 +142,3 @@ def allshelters(shelter_id=None):
return
jsonify
(
result
)
@
apiv02_bp
.
route
(
'/shelters/<attribute_name>'
,
methods
=
[
'GET'
])
@
apiv02_bp
.
route
(
'/shelters/<attribute_name>/<attribute_value>'
,
methods
=
[
'GET'
])
def
attributes
(
attribute_name
,
attribute_value
=
''
):
"""Returns all shelters which match a specific attribute name or attribute name + value"""
result
=
tree
()
if
not
attribute_value
:
shelter_properties
=
Property
.
query
.
filter
(
Property
.
attribute
.
has
(
uniqueid
=
attribute_name
))
else
:
shelter_properties
=
Property
.
query
.
filter
(
Property
.
attribute
.
has
(
uniqueid
=
attribute_name
),
Property
.
values
.
any
(
name
=
attribute_value
))
for
shelter_property
in
shelter_properties
:
result
[
shelter_property
.
shelter_id
][
shelter_property
.
attribute
.
uniqueid
]
=
shelter_property
.
get_values_as_string
()
return
jsonify
(
result
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment