Commit 15df3aa0 authored by Cédric Bonhomme's avatar Cédric Bonhomme

Fixed conflicts.

parents c684d7cb 56b170c6
......@@ -23,6 +23,7 @@ venv
build
# bower
src/web/static/lib/*
!src/web/static/lib/leaflet
!src/web/static/lib/dc
......@@ -38,3 +39,6 @@ node_modules
documentation/_build/
src/conf/conf.cfg
src/web/public/
# pycharm
.idea/
Shelter Database project news
<<<<<<< HEAD
0.3 (2016-08-02)
* merge the rodekruis repository (https://github.com/rodekruis/shelter-database)
in the LIST repository;
......@@ -9,3 +10,7 @@ Shelter Database project news
0.1 (2016-04-10)
* first stable prototype with base functionalities.
=======
0.1 (2015-03-30)
- initial release.
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
<<<<<<< HEAD
<<<<<<< HEAD
API
===
......@@ -21,6 +22,8 @@ Examples of requests to the Web Service
# Get the translations of a string
$ GET http://127.0.0.1:5000/api/translation?q={"filters":[{"name":"original","op":"eq","val":"Name of shelter"}]}
=======
=======
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
Web Services
============
......@@ -42,4 +45,7 @@ Example of requests to the Web Service
# Get the translations of a string
$ GET http://127.0.0.1:5000/api/translation?q={"filters":[{"name":"original","op":"eq","val":"Name of shelter"}]}
<<<<<<< HEAD
>>>>>>> 011351c71fefe44d232b84497307f51ee6d5b501
=======
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
<<<<<<< HEAD
<<<<<<< HEAD
API v0.1
========
......@@ -42,6 +43,8 @@ Examples
http://0.0.0.0:5000/api/v0.1/shelters/Kitchen type/open fire
#get all shelters which have a specific attribute value
=======
=======
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
Web Services
============
......@@ -85,4 +88,7 @@ Examples:
http://0.0.0.0:5000/api/v0.1/shelters/Kitchen type/open fire
#get all shelters which have a specific attribute value
<<<<<<< HEAD
>>>>>>> 011351c71fefe44d232b84497307f51ee6d5b501
=======
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
<<<<<<< HEAD
<<<<<<< HEAD
Deployment
==========
......@@ -410,6 +411,8 @@ Two layers are used by the Shelter Database application:
* `Köppen–Geiger climate classification system <https://shelter-database.org:8443/geoserver/shelters/wms?service=WMS&version=1.1.0&request=GetMap&layers=shelters:koeppen-geiger&styles=&bbox=-180.24500000476837,-90.2449951171875,180.2449951171875,84.22234392166138&width=768&height=371&srs=EPSG:4326&format=application/openlayers>`_;
* `Red Cross climate classification system <https://shelter-database.org:8443/geoserver/shelters/wms?service=WMS&version=1.1.0&request=GetMap&layers=shelters:redcross&styles=&bbox=-180.24500000476837,-90.2449951171875,180.2449951171875,84.22234392166138&width=768&height=371&srs=EPSG:4326&format=application/openlayers>`_.
=======
=======
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
Deployment
==========
......@@ -812,4 +815,7 @@ Two layers are used by the Shelter Database application:
* `Köppen–Geiger climate classification system <https://shelter-database.org:8443/geoserver/shelters/wms?service=WMS&version=1.1.0&request=GetMap&layers=shelters:koeppen-geiger&styles=&bbox=-180.24500000476837,-90.2449951171875,180.2449951171875,84.22234392166138&width=768&height=371&srs=EPSG:4326&format=application/openlayers>`_;
* `Red Cross climate classification system <https://shelter-database.org:8443/geoserver/shelters/wms?service=WMS&version=1.1.0&request=GetMap&layers=shelters:redcross&styles=&bbox=-180.24500000476837,-90.2449951171875,180.2449951171875,84.22234392166138&width=768&height=371&srs=EPSG:4326&format=application/openlayers>`_.
<<<<<<< HEAD
>>>>>>> 011351c71fefe44d232b84497307f51ee6d5b501
=======
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
.. Shelter Database documentation master file, created by
sphinx-quickstart on Sun Jun 19 21:53:46 2016.
You can adapt this file completely to your liking, but it should at least
......@@ -40,6 +43,7 @@ Web Services
:maxdepth: 2
api
<<<<<<< HEAD
api_v0.1
=======
.. Shelter Database documentation master file, created by
......@@ -84,3 +88,5 @@ Web Services
api
>>>>>>> 011351c71fefe44d232b84497307f51ee6d5b501
=======
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
......@@ -180,7 +180,11 @@
if(typeof section['Pictures'] !== 'undefined') {
//merge arrays
<<<<<<< HEAD
var d = section['Cover'].concat(section['Pictures']);
=======
var d = $.merge(section.Cover, section.Pictures);
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
// add panes
d3.select(elementId + "Panes")
......
......@@ -27,22 +27,36 @@ def tree():
return defaultdict(tree)
def queryfactory(model,join=False,filt=False,value=False):
<<<<<<< HEAD
=======
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
#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])
<<<<<<< HEAD
else:
return obj.filter(attrib.in_(val))
=======
else:
return obj.filter(attrib.in_(val))
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
def filter_and(obj,attrib,val):
"""Construct filtering methods recursively (AND)"""
list(val)
if len(val) == 1:
return obj.filter(attrib == val[0])
<<<<<<< HEAD
else:
=======
else:
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
return filter_and(obj.filter(attrib == val[len(val)-1]),attrib, val[0:len(val)-1])
if join and not filt:
......@@ -65,10 +79,17 @@ def apimessage():
def getattributes(attribute_name, safetext=False):
"""Returns available values for a given attribute name, separated by semicolons"""
result= tree()
<<<<<<< HEAD
attributes = Attribute.query.filter(Attribute.uniqueid==attribute_name).\
first().associated_values
=======
attributes = Attribute.query.filter(Attribute.uniqueid==attribute_name).\
first().associated_values
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
result[attribute_name] = ";".join([attribute.name for attribute in attributes])
return jsonify(result)
......@@ -77,15 +98,23 @@ def getattributes(attribute_name, safetext=False):
def allshelters():
"""Returns all shelters and their properties"""
result = tree()
<<<<<<< HEAD
#shelter pictures folder path
picpath = 'data/shelters/pictures'
=======
#shelter pictures folder path
picpath = 'data/shelters/pictures'
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
querybase = db.session.query(Property.shelter_id,Attribute.name,Attribute.uniqueid,func.string_agg(Value.name,';').label("value"))\
.join(Attribute)\
.join(Association,Property.id==Association.property_id)\
.join(Value, Association.value_id==Value.id)\
.group_by(Property.shelter_id, Attribute.name, Attribute.uniqueid)
<<<<<<< HEAD
picquerybase = db.session.query(ShelterPicture.shelter_id, ShelterPicture.file_name.label("filename"), Category.name)\
.join(Category, Category.id == ShelterPicture.category_id)
......@@ -97,11 +126,28 @@ def allshelters():
if request.args.getlist('attribute'):
attribute = request.args.getlist('attribute')
=======
picquerybase = db.session.query(ShelterPicture.shelter_id, ShelterPicture.file_name.label("filename"), Category.name)\
.join(Category, Category.id == ShelterPicture.category_id)
##queries if no request arguments
shelter_properties = querybase
shelter_pictures = picquerybase
if request.args.getlist('attribute'):
attribute = request.args.getlist('attribute')
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
subquery = db.session.query(Property.shelter_id)\
.join(Attribute, Attribute.id==Property.attribute_id)\
.filter(Attribute.uniqueid.in_(attribute))\
.group_by(Property.shelter_id)
<<<<<<< HEAD
=======
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
shelter_properties = querybase.filter(subquery.subquery().c.shelter_id==Property.shelter_id)
shelter_pictures = picquerybase.filter(subquery.subquery().c.shelter_id==ShelterPicture.shelter_id)
......@@ -114,6 +160,7 @@ def allshelters():
.group_by(Property.shelter_id)
else:
subquery = subquery.filter(Property.values.any(Value.name.in_(value)))
<<<<<<< HEAD
shelter_properties = querybase.filter(subquery.subquery().c.shelter_id==Property.shelter_id)
shelter_pictures = picquerybase.filter(subquery.subquery().c.shelter_id==ShelterPicture.shelter_id)
......@@ -125,22 +172,47 @@ def allshelters():
for shelter_property in shelter_properties:
result[shelter_property.shelter_id][shelter_property.name] = shelter_property.value
=======
shelter_properties = querybase.filter(subquery.subquery().c.shelter_id==Property.shelter_id)
shelter_pictures = picquerybase.filter(subquery.subquery().c.shelter_id==ShelterPicture.shelter_id)
#print(shelter_properties)
#print(shelter_pictures)
if request.args.get('format') == 'prettytext':
for shelter_property in shelter_properties:
result[shelter_property.shelter_id][shelter_property.name] = shelter_property.value
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
for picture in shelter_pictures:
if not result[picture.shelter_id]["shelterpicture"][picture.name]:
result[picture.shelter_id]["shelterpicture"][picture.name] = ["{}/{}/{}".format(picpath, result[picture.shelter_id]["ID"], picture.filename)]
else:
result[picture.shelter_id]["shelterpicture"][picture.name].append("{}/{}/{}".format(picpath, result[picture.shelter_id]["ID"], picture.filename))
<<<<<<< HEAD
else:
for shelter_property in shelter_properties:
result[shelter_property.shelter_id][shelter_property.uniqueid] = shelter_property.value
=======
else:
for shelter_property in shelter_properties:
result[shelter_property.shelter_id][shelter_property.uniqueid] = shelter_property.value
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
for picture in shelter_pictures:
if not result[picture.shelter_id]["shelterpicture"][picture.name]:
result[picture.shelter_id]["shelterpicture"][picture.name] = ["{}/{}/{}".format(picpath, result[picture.shelter_id]["id"], picture.filename)]
else:
result[picture.shelter_id]["shelterpicture"][picture.name].append("{}/{}/{}".format(picpath, result[picture.shelter_id]["id"], picture.filename))
<<<<<<< HEAD
=======
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
return jsonify(result)
......@@ -148,13 +220,21 @@ def allshelters():
def shelters(shelter_id):
"""Returns specific shelter with its properties"""
result = tree()
<<<<<<< HEAD
=======
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
## shelter picture query
shelter_pictures = db.session.query(ShelterPicture.shelter_id, func.string_agg(ShelterPicture.file_name,';').label("filename"), Category.name)\
.join(Category, Category.id == ShelterPicture.category_id)\
.group_by(ShelterPicture.shelter_id, Category.name)\
.filter(ShelterPicture.shelter_id==shelter_id)
<<<<<<< HEAD
=======
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
## shelter property query
shelter_properties = Property.query.filter(Property.shelter_id==shelter_id)
for shelter_property in shelter_properties:
......@@ -172,12 +252,21 @@ def attributes(attribute_name, 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))
<<<<<<< HEAD
for shelter_property in shelter_properties:
result[shelter_property.shelter_id][shelter_property.attribute.uniqueid] = shelter_property.get_values_as_string()
return jsonify(result)
=======
for shelter_property in shelter_properties:
result[shelter_property.shelter_id][shelter_property.attribute.uniqueid] = shelter_property.get_values_as_string()
return jsonify(result)
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
@api_bp.route('/shelters/search/<searchstring>', methods=['GET'])
def fulltext(searchstring):
"""Returns shelter id's which match the search criteria. Uses full text search'"""
......@@ -195,3 +284,7 @@ def fulltext(searchstring):
#print(shelter_property)
result[shelter_property.shelter_id]
return jsonify(result)
<<<<<<< HEAD
=======
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
......@@ -61,7 +61,11 @@ def authentication_required(e):
@current_app.route('/', methods=['GET'])
def index():
return render_template('index.html')
<<<<<<< HEAD
=======
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
@current_app.route('/map', methods=['GET'])
def map():
"""
......@@ -137,7 +141,11 @@ def shelters_for_map():
def dashboard():
# return render_template('dashboard0.html')
return render_template('dashboard.html')
<<<<<<< HEAD
=======
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
@current_app.route('/shelters', methods=['GET'])
def shelters():
shelters = Shelter.query.filter(Shelter.is_published==True).all()
......@@ -155,14 +163,22 @@ def stats():
@current_app.route('/knowledgebase', methods=['GET'])
def knowledgebase():
return render_template('knowledgebase.html')
<<<<<<< HEAD
=======
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
@current_app.route('/contribute', methods=['GET'])
def contribute():
"""
List of contributors.
"""
return render_template('contribute.html')
<<<<<<< HEAD
=======
>>>>>>> 56b170c62373521aae3518c6fece0335e0e06ec5
@current_app.route('/contributors', methods=['GET'])
def contributors():
"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment