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. --- AUTHORS | 1 + README.rst | 6 +-- 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 ++++++++++++++++++-------------------- conf/supervisord.conf | 2 +- 16 files changed, 107 insertions(+), 95 deletions(-) create mode 100644 AUTHORS create mode 100644 budget/run.py diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..80e231c --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +The project has been started by Alexis Métaireau and Frédéric Sureau. Friends arehelping since that in the person of Arnaud Bos and Quentin Roy. diff --git a/README.rst b/README.rst index 47d7c36..8b32bb5 100644 --- a/README.rst +++ b/README.rst @@ -1,10 +1,6 @@ Budget-manager ############## -:author: Alexis Métaireau, Frédéric Sureau -:date: 10/03/2010 -:technologies: Python, Flask, SQLAlchemy, WTForm - This is a really tiny app to ease the shared houses budget management. Keep track of who bought what, when, and for who to then compute the balance of each person. @@ -18,7 +14,7 @@ To make it run, you just have to do something like:: $ source venv/bin/activate $ pip install -r requirements.txt $ cd budget - $ python web.py + $ python run.py Deploy it ========= 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 @@