diff --git a/app/admin.py b/app/admin.py index 335e78f..03b6152 100644 --- a/app/admin.py +++ b/app/admin.py @@ -4,7 +4,7 @@ from flask.ext import login from app import app, db -from models import User +from models import User, Location, Food, Order, OrderItem @@ -20,8 +20,18 @@ class ModelBaseView(ModelView): class UserAdminModel(ModelBaseView): column_searchable_list = ('username',) inline_models = None - form_columns = ('username', 'admin') + + +class LocationAdminModel(ModelBaseView): + column_searchable_list = ('name', 'address', 'website') + inline_models = None + form_columns = ('name', 'address', 'website') + admin = Admin(app, name='FoodBot', url='/foodbot/admin', template_mode='bootstrap3') admin.add_view(UserAdminModel(User, db.session)) +admin.add_view(LocationAdminModel(Location, db.session)) +admin.add_view(ModelBaseView(Food, db.session)) +admin.add_view(ModelBaseView(Order, db.session)) +admin.add_view(ModelBaseView(OrderItem, db.session)) diff --git a/app/foodbot.py b/app/foodbot.py index 6d2d11f..0165261 100644 --- a/app/foodbot.py +++ b/app/foodbot.py @@ -1,3 +1,8 @@ +# 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 diff --git a/app/models.py b/app/models.py index 8d37025..1936d88 100644 --- a/app/models.py +++ b/app/models.py @@ -6,7 +6,8 @@ class User(db.Model): username = db.Column(db.String(80), unique=True) admin = db.Column(db.Boolean) bias = db.Column(db.Integer) - orders = db.relationship('Order', backref='courrier', lazy='dynamic') + runs = db.relationship('Order', backref='courrier', lazy='dynamic') + orders = db.relationship('OrderItem', backref='user', lazy='dynamic') def configure(self, username, admin, bias): self.username = username @@ -56,6 +57,8 @@ class Food(db.Model): location_id = db.Column(db.Integer, db.ForeignKey('location.id')) name = db.Column(db.String(120)) price = db.Column(db.Integer) + orders = db.relationship('OrderItem', backref='food', lazy='dynamic') + def configure(self, location, name, price): self.location = location @@ -84,6 +87,7 @@ class Order(db.Model): def __repr__(self): return 'Order' + class OrderItem(db.Model): id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) diff --git a/app/requirements.txt b/app/requirements.txt index 029a996..44bb7c4 100644 --- a/app/requirements.txt +++ b/app/requirements.txt @@ -8,7 +8,6 @@ MarkupSafe==0.23 SQLAlchemy==0.9.8 WTForms==2.0 Werkzeug==0.9.6 -flup==1.0.2 itsdangerous==0.24 requests==2.4.0 Flask-OAuthlib==0.8.0 diff --git a/app/templates/layout.html b/app/templates/layout.html index 61e2bac..03685c6 100644 --- a/app/templates/layout.html +++ b/app/templates/layout.html @@ -15,6 +15,7 @@