From 76f7d4c56d6a0bfadb2196eca1999277f534cb69 Mon Sep 17 00:00:00 2001 From: Tom Naessens Date: Tue, 31 Mar 2015 16:29:28 +0200 Subject: [PATCH 1/4] Some PEP8, remove insecure_lib --- app/app.py | 1 + app/config.example.py | 1 - app/create_database.py | 1 + app/forms.py | 2 ++ app/james.py | 7 ------- app/login.py | 1 + 6 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/app.py b/app/app.py index 813d9c5..a47ea69 100644 --- a/app/app.py +++ b/app/app.py @@ -24,5 +24,6 @@ class PrefixFix(object): environ['PATH_INFO'] = path[len(self.script_name):] return self.app(environ, start_response) + if not app.debug: app.wsgi_app = PrefixFix(app.wsgi_app, '/james') diff --git a/app/config.example.py b/app/config.example.py index 6fe57ee..faa8067 100644 --- a/app/config.example.py +++ b/app/config.example.py @@ -1,6 +1,5 @@ # config - class Configuration(object): SQLALCHEMY_DATABASE_URI = 'sqlite:///james.db' DEBUG = True diff --git a/app/create_database.py b/app/create_database.py index 834e458..6f39415 100644 --- a/app/create_database.py +++ b/app/create_database.py @@ -53,6 +53,7 @@ def chinees_create_entry(zetmeel, vlees="", saus=""): entry.configure(chinees, "{} {} {}".format(zetmeel, vlees, saus).rstrip(), 550) db.session.add(entry) + for zetmeel, vlees, saus in product(zetmelen, vlezen, sauzen): chinees_create_entry(zetmeel, vlees, saus) diff --git a/app/forms.py b/app/forms.py index a78eae6..73ff3ae 100644 --- a/app/forms.py +++ b/app/forms.py @@ -35,6 +35,7 @@ class OrderItemForm(Form): def populate(self, location): self.product_id.choices = [(i.id, (i.name + ": " + euro(i.price))) for i in location.products] + class AnonOrderItemForm(OrderItemForm): name = StringField('Name', validators=[validators.required()]) @@ -43,6 +44,7 @@ class AnonOrderItemForm(OrderItemForm): if self.name.data is None: self.name.data = session.get('anon_name', None) + def validate(self): rv = OrderForm.validate(self) if not rv: diff --git a/app/james.py b/app/james.py index d4fbb1b..ae3f0e8 100644 --- a/app/james.py +++ b/app/james.py @@ -1,8 +1,3 @@ -# TEMPORARY ## SHOULD BE DELETED AFTER KELDER.ZEUS HAS THEIR CERTIFICATE -import os -os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1" - - from views import * from app import app, db @@ -15,7 +10,5 @@ from utils import * from views import * - - if __name__ == '__main__': app.run(host='0.0.0.0', port=80) diff --git a/app/login.py b/app/login.py index 6375128..275766f 100644 --- a/app/login.py +++ b/app/login.py @@ -14,6 +14,7 @@ login_manager.init_app(app) def load_user(userid): return User.query.filter_by(id=userid).first() + @app.route('/login') def login(): return zeus_login() From f276b94a1c98c30702352e733d6455f152f67e16 Mon Sep 17 00:00:00 2001 From: Tom Naessens Date: Tue, 31 Mar 2015 16:29:45 +0200 Subject: [PATCH 2/4] Use HTTPS for everything --- app/zeus.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/zeus.py b/app/zeus.py index fda87b3..2421a1b 100644 --- a/app/zeus.py +++ b/app/zeus.py @@ -15,7 +15,7 @@ zeus = oauth.remote_app( consumer_key=app.config['ZEUS_KEY'], consumer_secret=app.config['ZEUS_SECRET'], request_token_params={}, - base_url='http://kelder.zeus.ugent.be/oauth/api/', + base_url='https://kelder.zeus.ugent.be/oauth/api/', access_token_method='POST', access_token_url='https://kelder.zeus.ugent.be/oauth/oauth2/token/', authorize_url='https://kelder.zeus.ugent.be/oauth/oauth2/authorize/' From e56f1fd0898d49f33dfc83761904c2a1ea706712 Mon Sep 17 00:00:00 2001 From: Tom Naessens Date: Tue, 31 Mar 2015 18:03:36 +0200 Subject: [PATCH 3/4] This --- uwsgi.ini | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/uwsgi.ini b/uwsgi.ini index a004beb..1c4804a 100644 --- a/uwsgi.ini +++ b/uwsgi.ini @@ -1,17 +1,13 @@ # mysite_uwsgi.ini file [uwsgi] -plugins = python - # Django-related settings # the base directory (full path) chdir = /home/james/production # Django's wsgi file -module = app.wsgi +module = app.app # the virtualenv (full path) home = /home/james/production/env -# something about ImportError -no-site = true # process-related settings # master From 9948037fd597b29d165d04218e1bbdbaf3122e90 Mon Sep 17 00:00:00 2001 From: Tom Naessens Date: Tue, 31 Mar 2015 18:04:30 +0200 Subject: [PATCH 4/4] This? --- uwsgi.ini | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/uwsgi.ini b/uwsgi.ini index 1c4804a..8231c39 100644 --- a/uwsgi.ini +++ b/uwsgi.ini @@ -4,10 +4,11 @@ # Django-related settings # the base directory (full path) chdir = /home/james/production -# Django's wsgi file -module = app.app +# Callables +module = app +callable = app # the virtualenv (full path) -home = /home/james/production/env +virtualenv = /home/james/production/env # process-related settings # master