Commit c53871c3 authored by Cédric Bonhomme's avatar Cédric Bonhomme
parents b1d5bd4f 2f02e7a1
This diff is collapsed.
......@@ -27,6 +27,7 @@ python3.5 src/manager.py import_shelters_documents data/shelters/documents/
# Import of the translations
python3.5 src/manager.py import_translation data/translations/sheltersDataTraduction_FR_rev_ED.csv fr
python3.5 src/manager.py import_translation data/translations/sheltersDataTranslation_ES.csv es
# Create database triggers for materialized view table
python3.5 src/manager.py create_db_triggers
......@@ -100,7 +100,11 @@
$(function() {
var loc = window.location.pathname; // returns the full URL
if("" === loc || "/" === loc) {
// add landingpage class to header
$('header').addClass('landingpage');
// remove page class from main
$('main').removeClass();
}
});
</script>
......
......@@ -17,7 +17,7 @@
<h1 id="shelter-name">[UNKNOWN NAME]</h1>
</div>
</section>
<section class="shelterimg" onclick="modalOpen()" style="background-image: url('{{ url_for('static', filename = 'img/shelter.jpg') }}')">
<section id="coverpicture" class="shelterimg" onclick="modalOpen()" style="background-image: url('{{ url_for('static', filename = 'img/shelter.jpg') }}')">
<div class="dots">
<div class="dot selected"></div>
<div class="dot"></div>
......@@ -81,31 +81,14 @@
</div>
</section>
<section class="shelterimg" onclick="modalOpen()" style="background-image: url('{{ url_for('static', filename = 'img/shelter.jpg') }}')">
<div class="dots">
<div class="dot selected"></div>
<div class="dot"></div>
<div class="dot"></div>
</div>
</section>
{% endblock %}
{% block footer %}
<div class="mymodal">
<div class="mymodal-close" onclick="modalClose()"></div>
<div class="swipe">
<div class="panes">
<div class="pane" style="background-image: url('{{ url_for('static', filename = 'img/shelter.jpg') }}"></div>
<div class="pane" style="background-image: url('{{ url_for('static', filename = 'img/1.jpg') }}"></div>
<div class="pane" style="background-image: url('{{ url_for('static', filename = 'img/2.jpg') }}"></div>
<div class="pane" style="background-image: url('{{ url_for('static', filename = 'img/3.jpg') }}')"></div>
</div>
<div class="dots">
<div class="dot" onclick="show(0, 0, true)"></div>
<div class="dot" onclick="show(1, 0, true)"></div>
<div class="dot" onclick="show(2, 0, true)"></div>
<div class="dot" onclick="show(2, 0, true)"></div>
</div>
<div id="modalIdentificationPanes" class="panes"></div>
<div id="modalIdentificationDots" class="dots"></div>
</div>
</div>
......@@ -170,9 +153,61 @@
// Initiate leaflet map
var map = L.map('location-map').setView([lat, lon], 13);
// Add OSM base layer
L.tileLayer('http://a.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png').addTo(map);
// disable dragging and scrolling for mobile view
map.scrollWheelZoom.disable();
map.dragging.disable();
// add location of shelter to map
L.marker([lat, lon]).addTo(map);
// add pictures
addCoverPicture('#coverpicture', data[shelter_id]['Identification']);
addSwipePictures('#modalIdentification', data[shelter_id]['Identification']);
}
});
function addCoverPicture(elementId, section){
if(typeof section['Cover'] !== 'undefined' && section['Cover'].length > 0) {
$(elementId).css("background-image", "url('" + section['Cover'][0] + "')");
}
}
function addSwipePictures(elementId, section){
if(typeof section['Pictures'] !== 'undefined') {
//merge arrays
var d = section['Cover'].concat(section['Pictures']);
// add panes
d3.select(elementId + "Panes")
.selectAll("div")
.data(d)
.enter()
.append("div")
.attr("class","pane")
.attr("style",function (d){ return "background-image: url('" + d + "')";});
// add dots
// TODO increment show id
var dot = 0;
d3.select(elementId + "Dots")
.selectAll("div")
.data(d)
.enter()
.append("div")
.attr("class","dot")
.attr("onclick",function (d){
var r = "_swipe.show(" + dot + ",0,true)";
dot++;
return r;
});
}
}
function tabulate(table_id, d, columns) {
......
......@@ -81,7 +81,7 @@ def available_translations():
result = tree()
subquery = db.session.query(Translation.language_code).group_by(Translation.language_code).subquery()
available_languages = db.session.query(func.string_agg(subquery.c.language_code, ';')).first()
available_languages = db.session.query(func.array_agg(subquery.c.language_code)).first()
#for language in available_languages
result["languages"]= available_languages[0]
......@@ -148,7 +148,7 @@ def allshelters(shelter_id=None):
result = tree()
#shelter pictures folder path
picpath = 'data/shelters/pictures'
picpath = '/public/pictures/shelters'
Supercategory = db.aliased(Category)
......@@ -210,11 +210,11 @@ def allshelters(shelter_id=None):
for picture in shelter_pictures:
if picture.is_main_picture == True:
result[picture.shelter_id]["Identification"]["Cover"] = ["{}/{}/{}".format(picpath, result[picture.shelter_id]["Identification"]["Attributes"]["ID"], picture.filename)]
result[picture.shelter_id]["Identification"]["Cover"] = ["{}/{}/{}".format(picpath, picture.shelter_id, picture.filename)]
elif not result[picture.shelter_id][picture.name]["Pictures"]:
result[picture.shelter_id][picture.name]["Pictures"] = ["{}/{}/{}".format(picpath, result[picture.shelter_id]["Identification"]["Attributes"]["ID"], picture.filename)]
result[picture.shelter_id][picture.name]["Pictures"] = ["{}/{}/{}".format(picpath, picture.shelter_id, picture.filename)]
else:
result[picture.shelter_id][picture.name]["Pictures"].append("{}/{}/{}".format(picpath, result[picture.shelter_id]["Identification"]["Attributes"]["ID"], picture.filename))
result[picture.shelter_id][picture.name]["Pictures"].append("{}/{}/{}".format(picpath, picture.shelter_id, picture.filename))
else:
for shelter_property in shelter_properties:
......@@ -222,10 +222,10 @@ def allshelters(shelter_id=None):
for picture in shelter_pictures:
if picture.is_main_picture == True:
result[picture.shelter_id]["Identification"]["Cover"] = ["{}/{}/{}".format(picpath, result[picture.shelter_id]["Identification"]["Attributes"]["id"], picture.filename)]
result[picture.shelter_id]["Identification"]["Cover"] = ["{}/{}/{}".format(picpath, picture.shelter_id, picture.filename)]
elif not result[picture.shelter_id][picture.name]["Pictures"]:
result[picture.shelter_id][picture.name]["Pictures"] = ["{}/{}/{}".format(picpath, result[picture.shelter_id]["Identification"]["Attributes"]["id"], picture.filename)]
result[picture.shelter_id][picture.name]["Pictures"] = ["{}/{}/{}".format(picpath, picture.shelter_id, picture.filename)]
else:
result[picture.shelter_id][picture.name]["Pictures"].append("{}/{}/{}".format(picpath, result[picture.shelter_id]["Identification"]["Attributes"]["id"], picture.filename))
result[picture.shelter_id][picture.name]["Pictures"].append("{}/{}/{}".format(picpath, picture.shelter_id, picture.filename))
return jsonify(result)
\ No newline at end of file
return jsonify(result)
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