Skip to content

Commit

Permalink
code clean up and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometrein committed Jan 15, 2022
1 parent d267d17 commit fdd112e
Show file tree
Hide file tree
Showing 26 changed files with 769 additions and 711 deletions.
2 changes: 1 addition & 1 deletion gunicorn_config.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
bind = "0.0.0.0:8080"
workers = 2
workers = 2
10 changes: 6 additions & 4 deletions tests/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

import unittest

from website import create_app

# Import from parent folder
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0, parentdir)

from website import create_app


class BasicTests(unittest.TestCase):

# Executed before to each test
Expand Down Expand Up @@ -44,6 +45,7 @@ def test_support_page(self):
"""
response = self.app.get('/support', follow_redirects=True)
self.assertEqual(response.status_code, 200)



if __name__ == "__main__":
unittest.main()
unittest.main()
Binary file modified website/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion website/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
from flask import Flask, render_template


# Create the Flask app
def create_app():
"""
Expand All @@ -27,4 +28,3 @@ def page_not_found(e):
app = init_dashboard(app)

return app

12 changes: 7 additions & 5 deletions website/dashmap/layouts/navbar/navbar.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from dash import html
import dash_bootstrap_components as dbc


def init_navbar():
"""
Initialize the navbar inside te dash app.
Expand Down Expand Up @@ -29,7 +30,7 @@ def init_navbar():
children=[
html.Img(
src='assets/help.gif',
style = {
style={
'display': 'block',
'margin-left': 'auto',
'margin-right': 'auto',
Expand All @@ -39,8 +40,9 @@ def init_navbar():
html.P(
"""
Use the map to filter the data by postal area.
You can select a postal area by clicking on it on the map. Double click will select all postal areas.
The data displayed on the map can be filtered too. Click on the legend of the map to show/Hide different layers.
You can select a postal area by clicking on it on the map. Double click will
select all postal areas. The data displayed on the map can be filtered too.
Click on the legend of the map to show/Hide different layers.
"""
)
]
Expand All @@ -64,7 +66,7 @@ def init_navbar():
brand_href="/",
color="#1a1c22",
dark=True,
fluid =True
fluid=True
)

return navbar
return navbar
11 changes: 6 additions & 5 deletions website/dashmap/layouts/tab_census/household.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from ..templates.templates import init_accordion_element, assemble_accordion


def init_census_household_accordion() -> object:
"""
Initialize the accordion for census tab.
Expand All @@ -10,28 +11,28 @@ def init_census_household_accordion() -> object:
"""
accord_household_size = init_accordion_element(
title="Household Size",
id='id_household_size',
graph_id='id_household_size',
tab_n='1-2',
group_n=1
)

accord_household_structure = init_accordion_element(
title="Household Structure",
id='id_household_structure',
graph_id='id_household_structure',
tab_n='1-2',
group_n=2
)

accord_household_income = init_accordion_element(
title="Household Income",
id='id_household_income',
graph_id='id_household_income',
tab_n='1-2',
group_n=3
)

accord_household_dwell = init_accordion_element(
title="Household Dwelling Type",
id='id_household_dwellings',
graph_id='id_household_dwellings',
tab_n='1-2',
group_n=4
)
Expand All @@ -43,4 +44,4 @@ def init_census_household_accordion() -> object:
accord_household_dwell,
]

return assemble_accordion(accordions)
return assemble_accordion(accordions)
13 changes: 7 additions & 6 deletions website/dashmap/layouts/tab_census/individual.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from ..templates.templates import init_accordion_element, assemble_accordion


def init_census_individual_accordion() -> object:
"""
Initialize the accordion for census tab.
Expand All @@ -10,35 +11,35 @@ def init_census_individual_accordion() -> object:
"""
accordion_age = init_accordion_element(
title="Age",
id='id_age_dist_hist',
graph_id='id_age_dist_hist',
tab_n=1,
group_n=1
)

accordion_gender = init_accordion_element(
title="Gender",
id='id_gender_pie_chart',
graph_id='id_gender_pie_chart',
tab_n=1,
group_n=2
)

accordion_education = init_accordion_element(
title="Education",
id='id_education_pie_chart',
graph_id='id_education_pie_chart',
tab_n=1,
group_n=3
)

accordion_income = init_accordion_element(
title="Income",
id='id_income_pie_chart',
graph_id='id_income_pie_chart',
tab_n=1,
group_n=4
)

accordion_employment = init_accordion_element(
title="Employment",
id='id_employment_pie_chart',
graph_id='id_employment_pie_chart',
tab_n=1,
group_n=5
)
Expand All @@ -51,4 +52,4 @@ def init_census_individual_accordion() -> object:
accordion_employment,
]

return assemble_accordion(accordions)
return assemble_accordion(accordions)
9 changes: 5 additions & 4 deletions website/dashmap/layouts/tab_census/main_census.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ def init_tab_census() -> object:
census_tab_content = dbc.Card(
dbc.CardBody(
[
html.H2("Census", style={'marginBottom': 10, 'marginTop':1}),
html.H2("Census", style={'marginBottom': 10, 'marginTop': 1}),
html.P(
"""
A census is a complete enumeration of population and its vital characteristics.
Censuses are created by systematic recording and aggregation of data about the members of a given population.
The purpose populations census is to understand the basic structure of the society and identify emerging patterns and trends.
Censuses are created by systematic recording and aggregation of data about the
members of a given population. The purpose populations census is to understand the
basic structure of the society and identify emerging patterns and trends.
""",
className="card-text"
),
Expand Down Expand Up @@ -57,4 +58,4 @@ def init_tab_census() -> object:
), className="mt-3",
)

return census_tab_content
return census_tab_content
9 changes: 5 additions & 4 deletions website/dashmap/layouts/tab_environment/environment.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from ..templates.templates import init_accordion_element, assemble_accordion


def init_environment_accordion():
"""
Initialize the accordion for environment tab.
Expand All @@ -10,21 +11,21 @@ def init_environment_accordion():
"""
wind_rose = init_accordion_element(
title="Wind Patterns",
id='id_windrose',
graph_id='id_windrose',
tab_n=5,
group_n=1
)

avg_air_temp = init_accordion_element(
title="Air Temperature",
id='id_air_temperature',
graph_id='id_air_temperature',
tab_n=5,
group_n=2
)

air_pollution = init_accordion_element(
title="Air Pollution",
id='id_air_pollution',
graph_id='id_air_pollution',
tab_n=5,
group_n=3
)
Expand All @@ -35,4 +36,4 @@ def init_environment_accordion():
air_pollution,
]

return assemble_accordion(accordions)
return assemble_accordion(accordions)
12 changes: 7 additions & 5 deletions website/dashmap/layouts/tab_environment/main_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from .environment import init_environment_accordion


def init_tab_environment() -> object:
"""
Initialize the environment tab.
Expand All @@ -17,12 +18,13 @@ def init_tab_environment() -> object:
environment_tab_content = dbc.Card(
dbc.CardBody(
[
html.H2("Environment", style={'marginBottom': 10, 'marginTop':1}),
html.H2("Environment", style={'marginBottom': 10, 'marginTop': 1}),
html.P("""
The environment refers to the environmental conditions created as byproduct of manmade and natural processes.
It includes metrics like pollution, noise, wind patterns and radiation levels.
"""
, className="card-text"),
The environment refers to the environmental conditions created as byproduct
of man-made and natural processes. It includes metrics like pollution, noise,
wind patterns and radiation levels.
""",
className="card-text"),
html.Div(environment_accordion),
]
),
Expand Down
4 changes: 2 additions & 2 deletions website/dashmap/layouts/tab_mobility/main_mobility.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def init_tab_mobility() -> object:
mobility_tab_content = dbc.Card(
dbc.CardBody(
[
html.H2("Mobility", style={'marginBottom': 10, 'marginTop':1}),
html.H2("Mobility", style={'marginBottom': 10, 'marginTop': 1}),
html.P(
"""
Geographic mobility is the measure of how populations and goods move over time.
Expand All @@ -33,4 +33,4 @@ def init_tab_mobility() -> object:
className="mt-3",
)

return mobility_tab_content
return mobility_tab_content
16 changes: 8 additions & 8 deletions website/dashmap/layouts/tab_mobility/mobility.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from ..templates.templates import init_accordion_element, assemble_accordion


def init_mobility_accordion():
"""
Initialize the accordion for mobility tab.
Expand All @@ -10,28 +11,28 @@ def init_mobility_accordion():
"""
accord_1 = init_accordion_element(
title="Mobility Index",
id='id_mobility_index',
graph_id='id_mobility_index',
tab_n=4,
group_n=1
)

accord_2 = init_accordion_element(
title="Comming Soon!",
id='id_metro_accordion',
title="Coming Soon!",
graph_id='id_metro_accordion',
tab_n=4,
group_n=2
)

accord_3 = init_accordion_element(
title="Comming Soon!",
id='id_tram_accordion',
title="Coming Soon!",
graph_id='id_tram_accordion',
tab_n=4,
group_n=3
)

accord_4 = init_accordion_element(
title="Comming Soon!",
id='id_bikes_accordion',
title="Coming Soon!",
graph_id='id_bikes_accordion',
tab_n=4,
group_n=4
)
Expand All @@ -44,4 +45,3 @@ def init_mobility_accordion():
]

return assemble_accordion(mobility_accordion)

9 changes: 5 additions & 4 deletions website/dashmap/layouts/tab_real_estate/estate.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from ..templates.templates import init_accordion_element, assemble_accordion


def init_real_estate_accordion():
"""
Initialize the real estate accordion for real estate tab.
Expand All @@ -10,21 +11,21 @@ def init_real_estate_accordion():
"""
accord_re_owning = init_accordion_element(
title="Ownership",
id='id_re_owning',
graph_id='id_re_owning',
tab_n=2,
group_n=2
)

accord_re_renting = init_accordion_element(
title="Rentals",
id='id_re_renting',
graph_id='id_re_renting',
tab_n=2,
group_n=3
)

accord_re_sauna = init_accordion_element(
title="Sauna Index",
id='id_re_sauna',
graph_id='id_re_sauna',
tab_n=2,
group_n=4
)
Expand All @@ -35,4 +36,4 @@ def init_real_estate_accordion():
accord_re_sauna,
]

return assemble_accordion(accordions)
return assemble_accordion(accordions)
Loading

0 comments on commit fdd112e

Please sign in to comment.