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
56b170c6
Commit
56b170c6
authored
Sep 06, 2016
by
Maarten van der Veen
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/rodekruis/shelter-database
parents
db718593
d26559bf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
27 deletions
+23
-27
src/web/views/shelterapiv02.py
src/web/views/shelterapiv02.py
+23
-27
No files found.
src/web/views/shelterapiv02.py
View file @
56b170c6
...
@@ -164,6 +164,7 @@ def allshelters(shelter_id=None):
...
@@ -164,6 +164,7 @@ def allshelters(shelter_id=None):
.
join
(
Category
,
Category
.
id
==
ShelterPicture
.
category_id
)
.
join
(
Category
,
Category
.
id
==
ShelterPicture
.
category_id
)
catquery
=
db
.
session
.
query
(
Category
.
name
).
filter
(
Category
.
section_id
!=
None
)
catquery
=
db
.
session
.
query
(
Category
.
name
).
filter
(
Category
.
section_id
!=
None
)
##queries if no request arguments
##queries if no request arguments
shelter_properties
=
querybase
shelter_properties
=
querybase
shelter_pictures
=
picquerybase
shelter_pictures
=
picquerybase
...
@@ -171,7 +172,7 @@ def allshelters(shelter_id=None):
...
@@ -171,7 +172,7 @@ def allshelters(shelter_id=None):
if
shelter_id
:
if
shelter_id
:
shelter_properties
=
shelter_properties
.
filter
(
Property
.
shelter_id
==
shelter_id
)
shelter_properties
=
shelter_properties
.
filter
(
Property
.
shelter_id
==
shelter_id
)
shelter_pictures
=
shelter_pictures
.
filter
(
ShelterPicture
.
shelter_id
==
shelter_id
)
shelter_pictures
=
shelter_pictures
.
filter
(
ShelterPicture
.
shelter_id
==
shelter_id
)
if
request
.
args
.
getlist
(
'attribute'
):
if
request
.
args
.
getlist
(
'attribute'
):
attribute
=
request
.
args
.
getlist
(
'attribute'
)
attribute
=
request
.
args
.
getlist
(
'attribute'
)
...
@@ -182,7 +183,7 @@ def allshelters(shelter_id=None):
...
@@ -182,7 +183,7 @@ def allshelters(shelter_id=None):
shelter_properties
=
shelter_properties
.
filter
(
subquery
.
subquery
().
c
.
shelter_id
==
Property
.
shelter_id
)
shelter_properties
=
shelter_properties
.
filter
(
subquery
.
subquery
().
c
.
shelter_id
==
Property
.
shelter_id
)
shelter_pictures
=
shelter_pictures
.
filter
(
subquery
.
subquery
().
c
.
shelter_id
==
ShelterPicture
.
shelter_id
)
shelter_pictures
=
shelter_pictures
.
filter
(
subquery
.
subquery
().
c
.
shelter_id
==
ShelterPicture
.
shelter_id
)
if
request
.
args
.
getlist
(
'value'
):
if
request
.
args
.
getlist
(
'value'
):
value
=
request
.
args
.
getlist
(
'value'
)
value
=
request
.
args
.
getlist
(
'value'
)
if
not
request
.
args
.
getlist
(
'attribute'
):
if
not
request
.
args
.
getlist
(
'attribute'
):
...
@@ -204,33 +205,28 @@ def allshelters(shelter_id=None):
...
@@ -204,33 +205,28 @@ def allshelters(shelter_id=None):
#print(shelter_properties)
#print(shelter_properties)
#print(shelter_pictures)
#print(shelter_pictures)
print
(
catquery
)
if
request
.
args
.
get
(
'format'
)
==
'prettytext'
:
for
shelter_property
in
shelter_properties
:
for
shelter_property
in
shelter_properties
:
if
not
result
[
shelter_property
.
shelter_id
]:
if
not
result
[
shelter_property
.
shelter_id
]:
for
category
in
catquery
:
for
category
in
catquery
:
if
category
.
name
==
"Identification"
:
if
category
.
name
==
"Identification"
:
result
[
shelter_property
.
shelter_id
][
category
.
name
][
"Cover"
]
result
[
shelter_property
.
shelter_id
][
category
.
name
][
"Cover"
]
result
[
shelter_property
.
shelter_id
][
category
.
name
][
"Attributes"
]
result
[
shelter_property
.
shelter_id
][
category
.
name
][
"Attributes"
]
result
[
shelter_property
.
shelter_id
][
category
.
name
][
"Pictures"
]
result
[
shelter_property
.
shelter_id
][
category
.
name
][
"Pictures"
]
result
[
shelter_property
.
shelter_id
][
shelter_property
.
supercategory_name
][
"Attributes"
][
shelter_property
.
name
]
=
shelter_property
.
value
else
:
if
request
.
args
.
get
(
'format'
)
==
'prettytext'
:
for
shelter_property
in
shelter_properties
:
result
[
shelter_property
.
shelter_id
][
shelter_property
.
supercategory_name
][
"Attributes"
][
shelter_property
.
name
]
=
shelter_property
.
value
if
not
result
[
shelter_property
.
shelter_id
]:
else
:
for
category
in
catquery
:
if
category
.
name
==
"Identification"
:
result
[
shelter_property
.
shelter_id
][
category
.
name
][
"Cover"
]
result
[
shelter_property
.
shelter_id
][
category
.
name
][
"Attributes"
]
result
[
shelter_property
.
shelter_id
][
category
.
name
][
"Pictures"
]
result
[
shelter_property
.
shelter_id
][
shelter_property
.
supercategory_name
][
"Attributes"
][
shelter_property
.
uniqueid
]
=
shelter_property
.
value
result
[
shelter_property
.
shelter_id
][
shelter_property
.
supercategory_name
][
"Attributes"
][
shelter_property
.
uniqueid
]
=
shelter_property
.
value
for
picture
in
shelter_pictures
:
if
picture
.
is_main_picture
==
True
:
for
picture
in
shelter_pictures
:
result
[
picture
.
shelter_id
][
"Identification"
][
"Cover"
]
=
[
"{}/{}/{}"
.
format
(
picpath
,
picture
.
shelter_id
,
picture
.
filename
)]
if
picture
.
is_main_picture
==
True
:
elif
not
result
[
picture
.
shelter_id
][
picture
.
name
][
"Pictures"
]:
result
[
picture
.
shelter_id
][
"Identification"
][
"Cover"
]
=
[
"{}/{}/{}"
.
format
(
picpath
,
picture
.
shelter_id
,
picture
.
filename
)]
result
[
picture
.
shelter_id
][
picture
.
name
][
"Pictures"
]
=
[
"{}/{}/{}"
.
format
(
picpath
,
picture
.
shelter_id
,
picture
.
filename
)]
elif
not
result
[
picture
.
shelter_id
][
picture
.
name
][
"Pictures"
]:
else
:
result
[
picture
.
shelter_id
][
picture
.
name
][
"Pictures"
]
=
[
"{}/{}/{}"
.
format
(
picpath
,
picture
.
shelter_id
,
picture
.
filename
)]
result
[
picture
.
shelter_id
][
picture
.
name
][
"Pictures"
].
append
(
"{}/{}/{}"
.
format
(
picpath
,
picture
.
shelter_id
,
picture
.
filename
))
else
:
result
[
picture
.
shelter_id
][
picture
.
name
][
"Pictures"
].
append
(
"{}/{}/{}"
.
format
(
picpath
,
picture
.
shelter_id
,
picture
.
filename
))
return
jsonify
(
result
)
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