From 127d585f796fdc4bdd34a177a19ff6072b9bcabc Mon Sep 17 00:00:00 2001 From: SvyatoslavArtymovych Date: Mon, 12 Jun 2023 11:21:07 +0300 Subject: [PATCH] ignore flask admin warnings --- app/__init__.py | 51 +++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 83f2966..43c1fec 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -110,28 +110,33 @@ def create_app(environment="development"): index_view=CustomAdminIndexView(), ) - for view in [ - UsersView(m.User, db.session, name="User", endpoint="/user_"), - BooksView(m.Book, db.session, name="Book", endpoint="/book_"), - CollectionsView( - m.Collection, db.session, name="Collection", endpoint="/collection_" - ), - SectionsView(m.Section, db.session, name="Section", endpoint="/section_"), - InterpretationView( - m.Interpretation, - db.session, - name="Interpretation", - endpoint="/interpretation_", - ), - CommentView(m.Comment, db.session, name="Comment", endpoint="/comment_"), - TagView(m.Tag, db.session, name="Tag", endpoint="/tag_"), - BookContributorView( - m.BookContributor, - db.session, - name="BookContributor", - endpoint="/book_contributor_", - ), - ]: - admin.add_view(view) + import warnings + + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", "Fields missing from ruleset", UserWarning) + + for view in [ + UsersView(m.User, db.session, name="User", endpoint="/user_"), + BooksView(m.Book, db.session, name="Book", endpoint="/book_"), + CollectionsView( + m.Collection, db.session, name="Collection", endpoint="/collection_" + ), + SectionsView(m.Section, db.session, name="Section", endpoint="/section_"), + InterpretationView( + m.Interpretation, + db.session, + name="Interpretation", + endpoint="/interpretation_", + ), + CommentView(m.Comment, db.session, name="Comment", endpoint="/comment_"), + TagView(m.Tag, db.session, name="Tag", endpoint="/tag_"), + BookContributorView( + m.BookContributor, + db.session, + name="BookContributor", + endpoint="/book_contributor_", + ), + ]: + admin.add_view(view) return app