From 1a279db9bf7cc1e0fe2ccd1bb428ae88052204be Mon Sep 17 00:00:00 2001 From: Kiran Jonnalagadda Date: Tue, 5 Mar 2024 15:54:27 +0530 Subject: [PATCH] Remove obsolete Flask-Admin UI --- boxoffice/__init__.py | 19 ----------------- boxoffice/siteadmin.py | 47 ------------------------------------------ requirements.txt | 1 - 3 files changed, 67 deletions(-) delete mode 100644 boxoffice/siteadmin.py diff --git a/boxoffice/__init__.py b/boxoffice/__init__.py index 2e9b0eed..84db94bf 100644 --- a/boxoffice/__init__.py +++ b/boxoffice/__init__.py @@ -4,7 +4,6 @@ from typing import Any from flask import Flask -from flask_admin import Admin from flask_mail import Mail from flask_migrate import Migrate from flask_rq2 import RQ @@ -46,11 +45,6 @@ User, db, ) -from .siteadmin import ( # isort:skip - DiscountCouponModelView, - InvoiceModelView, - OrganizationModelView, -) # --- Handle JSON quirk for Boxoffice -------------------------------------------------- @@ -91,16 +85,3 @@ def default(o: Any) -> Any: app.jinja_env.policies['json.dumps_function'] = app.json.dumps mail.init_app(app) - - -# This is a temporary solution for an admin interface, only -# to be used until the native admin interface is ready. -try: - admin = Admin( - app, name="Boxoffice Admin", template_mode='bootstrap3', url='/siteadmin' - ) - admin.add_view(OrganizationModelView(Organization, db.session)) - admin.add_view(DiscountCouponModelView(DiscountCoupon, db.session)) - admin.add_view(InvoiceModelView(Invoice, db.session)) -except AssertionError: - pass diff --git a/boxoffice/siteadmin.py b/boxoffice/siteadmin.py deleted file mode 100644 index 1ff385b5..00000000 --- a/boxoffice/siteadmin.py +++ /dev/null @@ -1,47 +0,0 @@ -from flask_admin.contrib.sqla import ModelView -from flask_admin.form.fields import JSONField - -from . import lastuser - - -class SiteAdminModelView(ModelView): - def is_accessible(self): - return lastuser.has_permission('siteadmin') - - -class OrganizationModelView(SiteAdminModelView): - can_delete = False - column_display_pk = True - column_list = ('id', 'title', 'organization_id') - form_list = ('id', 'userid', 'title') - form_excluded_columns = [ - 'userid', - 'menus', - 'discount_policies', - 'invoices', - 'orders', - 'created_at', - 'updated_at', - ] - form_overrides = {'details': JSONField} - - -class DiscountCouponModelView(SiteAdminModelView): - can_delete = False - column_filters = ['discount_policy'] - column_searchable_list = ['code'] - column_list = ('code', 'discount_policy') - form_excluded_columns = ['line_items', 'created_at', 'updated_at'] - - -class InvoiceModelView(SiteAdminModelView): - can_delete = False - column_filters = ['invoice_no'] - column_searchable_list = ['invoicee_email'] - column_list = ('customer_order_id', 'invoice_no', 'invoicee_name', 'invoicee_email') - form_excluded_columns = [ - 'customer_order_id', - 'organization_id', - 'created_at', - 'updated_at', - ] diff --git a/requirements.txt b/requirements.txt index 406e889b..e7fd3202 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,6 @@ git+https://github.com/hasgeek/baseframe#egg=baseframe click git+https://github.com/hasgeek/coaster#egg=coaster Flask -Flask-Admin Flask-Assets git+https://github.com/hasgeek/flask-lastuser#egg=Flask-Lastuser Flask-Mail