Remove removed concepts in admin, add choice item
This commit is contained in:
parent
9588116ba7
commit
798e08d74b
1 changed files with 2 additions and 18 deletions
20
app/admin.py
20
app/admin.py
|
@ -6,7 +6,7 @@ from flask_admin import Admin
|
|||
from flask_admin.contrib.sqla import ModelView
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
|
||||
from models import Location, Order, OrderItem, Product, User
|
||||
from models import Order, OrderItem, OrderItemChoice, User
|
||||
|
||||
|
||||
class ModelBaseView(ModelView):
|
||||
|
@ -26,27 +26,11 @@ class UserAdminModel(ModelBaseView):
|
|||
inline_models = None
|
||||
|
||||
|
||||
class ProductAdminModel(ModelBaseView):
|
||||
"Model for product admin"
|
||||
# pylint: disable=R0903
|
||||
column_searchable_list = ("name",)
|
||||
inline_models = None
|
||||
|
||||
|
||||
class LocationAdminModel(ModelBaseView):
|
||||
"Model for location admin"
|
||||
# pylint: disable=R0903
|
||||
column_searchable_list = ("name", "address", "website")
|
||||
inline_models = None
|
||||
form_columns = ("name", "address", "website", "telephone")
|
||||
|
||||
|
||||
def init_admin(app: Flask, database: SQLAlchemy) -> None:
|
||||
"Initialize the admin related things in the app."
|
||||
admin = Admin(app, name="Haldis", url="/admin", template_mode="bootstrap3")
|
||||
|
||||
admin.add_view(UserAdminModel(User, database.session))
|
||||
admin.add_view(LocationAdminModel(Location, database.session))
|
||||
admin.add_view(ProductAdminModel(Product, database.session))
|
||||
admin.add_view(ModelBaseView(Order, database.session))
|
||||
admin.add_view(ModelBaseView(OrderItem, database.session))
|
||||
admin.add_view(ModelBaseView(OrderItemChoice, database.session))
|
||||
|
|
Loading…
Reference in a new issue