Commit 35a99ac76a73e40a8dace666de7463b7e924f756
1 parent
fef4a9fd
Exists in
master
Move more text content to the YAML file.
Showing
3 changed files
with
41 additions
and
30 deletions
Show diff stats
flaskr/__init__.py
... | ... | @@ -5,7 +5,7 @@ from webassets.loaders import PythonLoader as PythonAssetsLoader |
5 | 5 | |
6 | 6 | from flaskr import assets |
7 | 7 | from flaskr.models import db |
8 | -from flaskr.controllers.main import main | |
8 | +from flaskr.controllers.main_controller import main | |
9 | 9 | |
10 | 10 | from flaskr.extensions import ( |
11 | 11 | cache, |
... | ... | @@ -14,7 +14,7 @@ from flaskr.extensions import ( |
14 | 14 | login_manager |
15 | 15 | ) |
16 | 16 | |
17 | -from yaml import safe_load as yaml_safe_load | |
17 | +from flaskr.content import content | |
18 | 18 | |
19 | 19 | from markdown import markdown |
20 | 20 | |
... | ... | @@ -57,12 +57,7 @@ def create_app(object_name): |
57 | 57 | # register our blueprints |
58 | 58 | app.register_blueprint(main) |
59 | 59 | |
60 | - # Load content data from the YAML file | |
61 | - content = {} | |
62 | - with open('content.yml', 'r') as content_file: | |
63 | - content = yaml_safe_load(content_file.read()) | |
64 | - | |
65 | - # VERSION | |
60 | + # VERSION (move to version.py is necessary) | |
66 | 61 | version = "0.0.0" |
67 | 62 | with open('VERSION', 'r') as version_file: |
68 | 63 | version = version_file.read().strip() | ... | ... |
flaskr/forms.py
... | ... | @@ -7,73 +7,85 @@ from wtforms import \ |
7 | 7 | from wtforms import validators |
8 | 8 | |
9 | 9 | from .models import User |
10 | +from .content import content | |
11 | + | |
12 | +form_content = content['estimate']['form'] | |
10 | 13 | |
11 | 14 | |
12 | 15 | # ESTIMATION FORM ############################################################# |
13 | 16 | |
14 | 17 | class EstimateForm(Form): |
15 | 18 | email = StringField( |
16 | - label=u"Email Address", | |
17 | - description=u"Make sure you provide a valid address " | |
18 | - u"or you won't receive the results.", | |
19 | + label=form_content['email']['label'], | |
20 | + description=form_content['email']['description'], | |
19 | 21 | validators=[ |
20 | 22 | validators.DataRequired(), |
21 | 23 | validators.Email(), |
22 | 24 | ], |
23 | 25 | ) |
24 | 26 | first_name = StringField( |
25 | - label=u"First Name", | |
26 | - description=u"Also known as given name, eg. `Didier`.", | |
27 | + label=form_content['first_name']['label'], | |
28 | + description=form_content['first_name']['description'], | |
27 | 29 | validators=[ |
28 | 30 | validators.Optional(), |
29 | 31 | validators.Length(max=1024), |
30 | 32 | ], |
31 | 33 | ) |
32 | 34 | last_name = StringField( |
33 | - label=u"Last Name", | |
34 | - description=u"Also known as family name, eg. `Barret`.", | |
35 | + label=form_content['last_name']['label'], | |
36 | + description=form_content['last_name']['description'], | |
35 | 37 | validators=[ |
36 | 38 | validators.Optional(), |
37 | 39 | validators.Length(max=1024), |
38 | 40 | ], |
39 | 41 | ) |
40 | 42 | institution = StringField( |
41 | - label=u"Institution / Enterprise", | |
42 | - description=u"If any.", | |
43 | + label=form_content['institution']['label'], | |
44 | + description=form_content['institution']['description'], | |
43 | 45 | validators=[ |
44 | 46 | validators.Optional(), |
45 | 47 | validators.Length(max=1024), |
46 | 48 | ], |
47 | 49 | ) |
48 | 50 | comment = TextAreaField( |
49 | - label=u"Leave a comment", | |
50 | - description=u"Any input is appreciated. Everyone's a critic.", | |
51 | + label=form_content['comment']['label'], | |
52 | + description=form_content['comment']['description'], | |
51 | 53 | validators=[ |
52 | 54 | validators.Optional(), |
53 | 55 | validators.Length(max=2048), |
54 | 56 | ], |
55 | 57 | ) |
56 | 58 | origin_addresses = TextAreaField( |
57 | - label=u"Origin Cities", | |
58 | - description=u"One address per line, in the form `City, Country`. " | |
59 | - u"Make sure your addresses are correctly spelled.", | |
59 | + label=form_content['origin_addresses']['label'], | |
60 | + description=form_content['origin_addresses']['description'], | |
60 | 61 | validators=[ |
61 | 62 | validators.DataRequired(), |
62 | 63 | ], |
64 | + render_kw={ | |
65 | + "placeholder": form_content['origin_addresses']['placeholder'] | |
66 | + }, | |
63 | 67 | ) |
64 | 68 | destination_addresses = TextAreaField( |
65 | - label=u"Destination Cities", | |
66 | - description=u"One address per line, in the form `City, Country`. " | |
67 | - u"Make sure your addresses are correctly spelled.", | |
69 | + label=form_content['destination_addresses']['label'], | |
70 | + description=form_content['destination_addresses']['description'], | |
68 | 71 | validators=[ |
69 | 72 | validators.DataRequired(), |
70 | 73 | ], |
74 | + render_kw={ | |
75 | + "placeholder": form_content['destination_addresses']['placeholder'] | |
76 | + }, | |
77 | + ) | |
78 | + compute_optimal_destination = BooleanField( | |
79 | + label=form_content['compute_optimal_destination']['label'], | |
80 | + description=form_content['compute_optimal_destination']['description'], | |
81 | + default=False, | |
82 | + validators=[ | |
83 | + validators.Optional(), | |
84 | + ], | |
71 | 85 | ) |
72 | - should_compute_optimal_destination = BooleanField( | |
73 | - label=u"Compute the destination city " | |
74 | - u"that will minimize emissions? <br>" | |
75 | - u"(useful when setting up a meeting/conference)", | |
76 | - description=u"", | |
86 | + use_atmosfair_rfi = BooleanField( | |
87 | + label=form_content['use_atmosfair_rfi']['label'], | |
88 | + description=form_content['use_atmosfair_rfi']['description'], | |
77 | 89 | default=False, |
78 | 90 | validators=[ |
79 | 91 | validators.Optional(), | ... | ... |