Parcourir la source

Handle roof field. Fix #1

opi il y a 10 ans
Parent
commit
73128fbe53
2 fichiers modifiés avec 7 ajouts et 3 suppressions
  1. 1 0
      assets/map.js
  2. 6 3
      backend.py

+ 1 - 0
assets/map.js

@@ -32,6 +32,7 @@ $( document ).ready(function() {
                 feature.properties.popupContent += '<ul>';
                 if (feature.properties.place.floor) feature.properties.popupContent += '<li>Étage: '+feature.properties.place.floor+'</li>';
                 if (feature.properties.place.orientations[0]) feature.properties.popupContent += '<li>Orientation: '+feature.properties.place.orientations.join(', ')+'</li>';
+                if (feature.properties.place.roof) feature.properties.popupContent += '<li>Accès au toît'+'</li>';
                 feature.properties.popupContent += '</ul>'
             }
 

+ 6 - 3
backend.py

@@ -40,6 +40,7 @@ DB_COLS = (
 ('share_part', 'REAL'),
 ('floor', 'INTEGER'),
 ('orientations', 'TEXT'),
+('roof', 'INTEGER'),
 ('comment', 'TEXT'),
 ('privacy_name', 'INTEGER'),
 ('privacy_email', 'INTEGER'),
@@ -67,9 +68,9 @@ def save_to_db(db, dic):
     tosave['date'] = utils.formatdate()
     return db.execute("""
 INSERT INTO {}
-(name, contrib_type, latitude, longitude, phone, email, access_type, bandwidth, share_part, floor, orientations, comment,
+(name, contrib_type, latitude, longitude, phone, email, access_type, bandwidth, share_part, floor, orientations, roof, comment,
 privacy_name, privacy_email, privacy_place_details, privacy_coordinates, privacy_comment, date)
-VALUES (:name, :contrib_type, :latitude, :longitude, :phone, :email, :access_type, :bandwidth, :share_part, :floor, :orientations, :comment,
+VALUES (:name, :contrib_type, :latitude, :longitude, :phone, :email, :access_type, :bandwidth, :share_part, :floor, :orientations, :roof, :comment,
         :privacy_name, :privacy_email, :privacy_place_details, :privacy_coordinates, :privacy_comment, :date)
 """.format(TABLE_NAME), tosave)
 
@@ -131,6 +132,7 @@ def submit_wifi_form():
                 'share_part'           : d.get('share-part'),
                 'floor'                : d.get('floor'),
                 'orientations'         : ','.join(d.getall('orientation')),
+                'roof'         : d.get('roof'),
                 'comment'              : d.get('comment'),
                 'privacy_name'         : 'name' in d.getall('privacy'),
                 'privacy_email'        : 'email' in d.getall('privacy'),
@@ -209,6 +211,7 @@ def build_geojson():
                 "place" : {
                     'floor' : row['floor'],
                     'orientations' : row['orientations'].split(','),
+                    'roof' : row['roof'],
                 },
                 "comment" : row['comment']
              }
@@ -240,7 +243,7 @@ def build_geojson():
             public_feature['properties']['place'] = {
                 'floor' : row['floor'],
                 'orientations' : row['orientations'].split(','),
-                # 'roof' : row['roof'],
+                'roof' : row['roof'],
             }
 
         # Add to public features list