From ef353d643c274d19e7816e9cfa436e38f1d1edea Mon Sep 17 00:00:00 2001 From: Alexis Metaireau Date: Fri, 9 Sep 2011 21:21:37 +0200 Subject: Refactor the application to use blueprints. This allows to isolate some behavior in the context of the web application so the API and the web application can behave in different ways. --- budget/run.py | 22 +++++++++ budget/templates/add_bill.html | 2 +- budget/templates/add_member.html | 2 +- budget/templates/authenticate.html | 2 +- budget/templates/edit_bill.html | 2 +- budget/templates/forms.html | 2 +- budget/templates/home.html | 6 +-- budget/templates/invitation_mail | 2 +- budget/templates/layout.html | 10 ++-- budget/templates/list_bills.html | 14 +++--- budget/templates/send_invites.html | 4 +- budget/tests.py | 32 ++++++------- budget/web.py | 93 ++++++++++++++++++-------------------- 13 files changed, 104 insertions(+), 89 deletions(-) create mode 100644 budget/run.py (limited to 'budget') diff --git a/budget/run.py b/budget/run.py new file mode 100644 index 0000000..b1fad19 --- /dev/null +++ b/budget/run.py @@ -0,0 +1,22 @@ +from web import main, db, mail +import api + +from flask import * + +app = Flask(__name__) +app.config.from_object("default_settings") +app.register_blueprint(main) + +# db +db.init_app(app) +db.app = app +db.create_all() + +# mail +mail.init_app(app) + +def main(): + app.run(host="0.0.0.0", debug=True) + +if __name__ == '__main__': + main() diff --git a/budget/templates/add_bill.html b/budget/templates/add_bill.html index 0b575d7..3b29896 100644 --- a/budget/templates/add_bill.html +++ b/budget/templates/add_bill.html @@ -1,7 +1,7 @@ {% extends "layout.html" %} {% block top_menu %} -Back to the list +Back to the list {% endblock %} {% block content %} diff --git a/budget/templates/add_member.html b/budget/templates/add_member.html index 5739791..62fcf9e 100644 --- a/budget/templates/add_member.html +++ b/budget/templates/add_member.html @@ -1,6 +1,6 @@ {% extends "layout.html" %} {% block content %} -
+ {{ forms.add_member(form) }}
{% endblock %} diff --git a/budget/templates/authenticate.html b/budget/templates/authenticate.html index 0ad8815..9852d6a 100644 --- a/budget/templates/authenticate.html +++ b/budget/templates/authenticate.html @@ -8,7 +8,7 @@ {% if create_project %}

The project you are trying to access do not exist, do you want -to create it? +to create it?

{% endif %}
diff --git a/budget/templates/edit_bill.html b/budget/templates/edit_bill.html index f069193..9c272ae 100644 --- a/budget/templates/edit_bill.html +++ b/budget/templates/edit_bill.html @@ -1,7 +1,7 @@ {% extends "layout.html" %} {% block top_menu %} -Back to the list +Back to the list {% endblock %} {% block content %} diff --git a/budget/templates/forms.html b/budget/templates/forms.html index 7b512ff..b027763 100644 --- a/budget/templates/forms.html +++ b/budget/templates/forms.html @@ -80,7 +80,7 @@ {{ input(form.emails) }}
- No, thanks + No, thanks
{% endmacro %} diff --git a/budget/templates/home.html b/budget/templates/home.html index 1b77cbd..ceb3b57 100644 --- a/budget/templates/home.html +++ b/budget/templates/home.html @@ -7,7 +7,7 @@