From a36cc719efaee3f945cf13c95f1411da9b2d87c8 Mon Sep 17 00:00:00 2001 From: coolneng Date: Sun, 14 Jun 2020 00:14:09 +0200 Subject: [PATCH] Shorten form choices labels --- app/data_request.py | 2 +- app/forms.py | 5 ++--- app/templates/visualization.html | 3 +-- constants.py | 12 ++++++------ tests/preprocessing_test.py | 2 +- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/app/data_request.py b/app/data_request.py index bd29f3b..60e477a 100644 --- a/app/data_request.py +++ b/app/data_request.py @@ -2,7 +2,7 @@ from json import dump from requests import get -from constants import FILES, URL +from constants import URL def format_url(dataset) -> str: diff --git a/app/forms.py b/app/forms.py index 82fe86b..6631a79 100644 --- a/app/forms.py +++ b/app/forms.py @@ -1,9 +1,8 @@ -from constants import DATASETS +from constants import CHOICES from flask_wtf import FlaskForm from wtforms import SelectField, SubmitField -# NOTE The choices should be shorter class DatasetForm(FlaskForm): - dataset = SelectField(choices=DATASETS) + dataset = SelectField(choices=CHOICES) submit = SubmitField("Submit") diff --git a/app/templates/visualization.html b/app/templates/visualization.html index 0d3dd28..bde06ff 100644 --- a/app/templates/visualization.html +++ b/app/templates/visualization.html @@ -3,7 +3,6 @@ {% block app_content %}

Dataset visualization

-Plot Placeholder -Map Placeholder +{{ table|safe }}

Back

{% endblock %} diff --git a/constants.py b/constants.py index ffe862f..8ae10eb 100644 --- a/constants.py +++ b/constants.py @@ -5,12 +5,6 @@ DATASETS = [ "deconfinement-rues-amenagees-pour-pietons", ] URL = "https://opendata.paris.fr/api/records/1.0/search/?dataset={}&q=&rows=-1" -FILES = { - "deconfinement-pistes-cyclables-temporaires": "data/cycling-paths.json", - "deconfinement-parking-relais-doublement-des-places": "data/relay-parking.json", - "coronavirus-commercants-parisiens-livraison-a-domicile": "data/home-delivery.json", - "deconfinement-rues-amenagees-pour-pietons": "data/pedestrian-streets.json", -} COLUMNS = { "deconfinement-pistes-cyclables-temporaires": [ "fields.geo_shape.coordinates", @@ -47,5 +41,11 @@ COLUMNS = { "record_timestamp", ], } +CHOICES = [ + ("coronavirus-commercants-parisiens-livraison-a-domicile", "home-delivery"), + ("deconfinement-pistes-cyclables-temporaires", "cycling-paths"), + ("deconfinement-parking-relais-doublement-des-places", "relay-parking"), + ("deconfinement-rues-amenagees-pour-pietons", "pedestrian-streets"), +] SECRET_KEY = "trolaso" COORDINATES = [48.864716, 2.349014] diff --git a/tests/preprocessing_test.py b/tests/preprocessing_test.py index 21c11ae..08f74d0 100644 --- a/tests/preprocessing_test.py +++ b/tests/preprocessing_test.py @@ -3,7 +3,7 @@ from requests import get from app.preprocessing import create_dataframe from app.data_request import request_dataset -from constants import COLUMNS, DATASETS, FILES, URL +from constants import COLUMNS, DATASETS, URL def test_dataset_request():