diff --git a/packages/p/python-Flask-Admin/.files b/packages/p/python-Flask-Admin/.files index 41d4d01a4ac..0bf1a6296d0 100644 Binary files a/packages/p/python-Flask-Admin/.files and b/packages/p/python-Flask-Admin/.files differ diff --git a/packages/p/python-Flask-Admin/.rev b/packages/p/python-Flask-Admin/.rev index acb8daa14ba..507c79d44a1 100644 --- a/packages/p/python-Flask-Admin/.rev +++ b/packages/p/python-Flask-Admin/.rev @@ -138,4 +138,16 @@ - Skip a recalcitrant test. 1097852 + + 7b8d73f455d7e9f7bdb0b9bd50aa315c + 1.6.1 + + anag+factory + - Add few patches to fix tests (from gh#flask-admin/flask-admin#2328): + * model-from-model.patch + * reverse-relation-for-model.patch + * bytes-not-str.patch + + 1120478 + diff --git a/packages/p/python-Flask-Admin/bytes-not-str.patch b/packages/p/python-Flask-Admin/bytes-not-str.patch new file mode 100644 index 00000000000..d0b9c1788f0 --- /dev/null +++ b/packages/p/python-Flask-Admin/bytes-not-str.patch @@ -0,0 +1,28 @@ +From 11b657cd886f18ad186eb8cf5401b00bcba0f842 Mon Sep 17 00:00:00 2001 +From: Chris Mayo +Date: Mon, 23 Oct 2023 19:22:07 +0100 +Subject: [PATCH] Fix test_file_admin: "a bytes-like object is required, not + 'str'" + +--- + flask_admin/tests/fileadmin/test_fileadmin.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +Index: Flask-Admin-1.6.1/flask_admin/tests/fileadmin/test_fileadmin.py +=================================================================== +--- Flask-Admin-1.6.1.orig/flask_admin/tests/fileadmin/test_fileadmin.py ++++ Flask-Admin-1.6.1/flask_admin/tests/fileadmin/test_fileadmin.py +@@ -1,3 +1,4 @@ ++from io import BytesIO + import os + import os.path as op + import unittest +@@ -80,7 +81,7 @@ class Base: + assert rv.status_code == 200 + + rv = client.post('/admin/myfileadmin/upload/', +- data=dict(upload=(StringIO(""), 'dummy.txt'))) ++ data=dict(upload=(BytesIO("".encode("utf8")), 'dummy.txt'))) + assert rv.status_code == 302 + + rv = client.get('/admin/myfileadmin/') diff --git a/packages/p/python-Flask-Admin/model-from-model.patch b/packages/p/python-Flask-Admin/model-from-model.patch new file mode 100644 index 00000000000..13cd1c32332 --- /dev/null +++ b/packages/p/python-Flask-Admin/model-from-model.patch @@ -0,0 +1,27 @@ +From d18b41fa9ff98cc2ebf0c282c8ad096299924d89 Mon Sep 17 00:00:00 2001 +From: David Gilman +Date: Mon, 23 Oct 2023 19:22:07 +0100 +Subject: [PATCH] Resolve test_multi_pk.py Flask-SQLAlchemy Model + DeprecationWarning + +--- + flask_admin/tests/sqla/test_multi_pk.py | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/flask_admin/tests/sqla/test_multi_pk.py b/flask_admin/tests/sqla/test_multi_pk.py +index dd122baee..d73625cc7 100644 +--- a/flask_admin/tests/sqla/test_multi_pk.py ++++ b/flask_admin/tests/sqla/test_multi_pk.py +@@ -1,7 +1,11 @@ + from . import setup + from .test_basic import CustomModelView + +-from flask_sqlalchemy import Model ++try: ++ # Flask-SQLAlchemy 3 ++ from flask_sqlalchemy.model import Model ++except ImportError: ++ from flask_sqlalchemy import Model + from sqlalchemy.ext.declarative import declarative_base + + diff --git a/packages/p/python-Flask-Admin/python-Flask-Admin.changes b/packages/p/python-Flask-Admin/python-Flask-Admin.changes index e80ddf76012..af3fa887c4c 100644 --- a/packages/p/python-Flask-Admin/python-Flask-Admin.changes +++ b/packages/p/python-Flask-Admin/python-Flask-Admin.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Tue Oct 24 12:14:40 UTC 2023 - Markéta Machová + +- Add few patches to fix tests (from gh#flask-admin/flask-admin#2328): + * model-from-model.patch + * reverse-relation-for-model.patch + * bytes-not-str.patch + ------------------------------------------------------------------- Mon Jul 10 02:12:28 UTC 2023 - Steve Kowalik diff --git a/packages/p/python-Flask-Admin/python-Flask-Admin.spec b/packages/p/python-Flask-Admin/python-Flask-Admin.spec index 4e708db7dd7..71f25b1ed89 100644 --- a/packages/p/python-Flask-Admin/python-Flask-Admin.spec +++ b/packages/p/python-Flask-Admin/python-Flask-Admin.spec @@ -26,13 +26,17 @@ Source: https://files.pythonhosted.org/packages/source/F/Flask-Admin/Fla # PATCH-FIX-OPENSUSE Flask-BabelEx has been firmly deprecated, switch to Babel # directly. Patch0: switch-to-babel.patch +# cherry-picks from https://github.com/flask-admin/flask-admin/pull/2328 Support latest flask, sqlalchemy, flask-sqlalchemy and wtforms +Patch1: model-from-model.patch +Patch2: reverse-relation-for-model.patch +Patch3: bytes-not-str.patch BuildRequires: %{python_module Flask >= 0.7} BuildRequires: %{python_module Flask-Babel} BuildRequires: %{python_module Flask-SQLAlchemy} BuildRequires: %{python_module Pillow >= 3.3.2} BuildRequires: %{python_module PyYAML} -BuildRequires: %{python_module SQLAlchemy < 2.0} BuildRequires: %{python_module SQLAlchemy-Utils} +BuildRequires: %{python_module SQLAlchemy} BuildRequires: %{python_module WTForms} BuildRequires: %{python_module arrow} BuildRequires: %{python_module colour} @@ -45,7 +49,7 @@ BuildRequires: %{python_module wheel} BuildRequires: fdupes BuildRequires: python-rpm-macros Requires: python-Flask >= 0.7 -Requires: python-SQLAlchemy < 2.0 +Requires: python-SQLAlchemy Requires: python-WTForms BuildArch: noarch %python_subpackages diff --git a/packages/p/python-Flask-Admin/reverse-relation-for-model.patch b/packages/p/python-Flask-Admin/reverse-relation-for-model.patch new file mode 100644 index 00000000000..2af822fb357 --- /dev/null +++ b/packages/p/python-Flask-Admin/reverse-relation-for-model.patch @@ -0,0 +1,44 @@ +From 84139973c90aa43e00267d294fd9dcd7d3aa4d2d Mon Sep 17 00:00:00 2001 +From: Chris Mayo +Date: Mon, 23 Oct 2023 19:22:07 +0100 +Subject: [PATCH] Fix Exception: Cannot find reverse relation for model + +SQLAlchemy 2.0.2 removed the invocation of registry.configure() from +Mapper.iterate_properties causing this problem. + +sqlalchemy.orm.registry.configure() was added in 1.4.0b2. + +Observed as test failures in: + +flask_admin/tests/sqla/test_basic.py +flask_admin/tests/sqla/test_form_rules.py +flask_admin/tests/sqla/test_inlineform.py +--- + flask_admin/contrib/sqla/form.py | 1 + + flask_admin/contrib/sqla/view.py | 1 + + 2 files changed, 2 insertions(+) + +Index: Flask-Admin-1.6.1/flask_admin/contrib/sqla/form.py +=================================================================== +--- Flask-Admin-1.6.1.orig/flask_admin/contrib/sqla/form.py ++++ Flask-Admin-1.6.1/flask_admin/contrib/sqla/form.py +@@ -668,6 +668,7 @@ class InlineModelConverter(InlineModelCo + target_mapper = info.model._sa_class_manager.mapper.base_mapper + + reverse_prop = None ++ model.registry.configure() + + for prop in target_mapper.iterate_properties: + if hasattr(prop, 'direction') and prop.direction.name in ('MANYTOONE', 'MANYTOMANY'): +Index: Flask-Admin-1.6.1/flask_admin/contrib/sqla/view.py +=================================================================== +--- Flask-Admin-1.6.1.orig/flask_admin/contrib/sqla/view.py ++++ Flask-Admin-1.6.1/flask_admin/contrib/sqla/view.py +@@ -366,6 +366,7 @@ class ModelView(BaseModelView): + if model is None: + model = self.model + ++ model.registry.configure() + return model._sa_class_manager.mapper.iterate_properties + + def _apply_path_joins(self, query, joins, path, inner_join=True):