Skip to content

Commit

Permalink
Update python-Flask-Admin to version 1.6.1 / rev 16 via SR 1120478
Browse files Browse the repository at this point in the history
https://build.opensuse.org/request/show/1120478
by user mcalabkova + anag+factory
- Add few patches to fix tests (from gh#pallets-eco/flask-admin#2328):
  * model-from-model.patch
  * reverse-relation-for-model.patch
  * bytes-not-str.patch
  • Loading branch information
mcalabkova authored and bmwiedemann committed Oct 26, 2023
1 parent 161710c commit f44afe5
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 2 deletions.
Binary file modified packages/p/python-Flask-Admin/.files
Binary file not shown.
12 changes: 12 additions & 0 deletions packages/p/python-Flask-Admin/.rev
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,16 @@
- Skip a recalcitrant test.</comment>
<requestid>1097852</requestid>
</revision>
<revision rev="16" vrev="3">
<srcmd5>7b8d73f455d7e9f7bdb0b9bd50aa315c</srcmd5>
<version>1.6.1</version>
<time>1698333289</time>
<user>anag+factory</user>
<comment>- 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
</comment>
<requestid>1120478</requestid>
</revision>
</revisionlist>
28 changes: 28 additions & 0 deletions packages/p/python-Flask-Admin/bytes-not-str.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From 11b657cd886f18ad186eb8cf5401b00bcba0f842 Mon Sep 17 00:00:00 2001
From: Chris Mayo <[email protected]>
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/')
27 changes: 27 additions & 0 deletions packages/p/python-Flask-Admin/model-from-model.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
From d18b41fa9ff98cc2ebf0c282c8ad096299924d89 Mon Sep 17 00:00:00 2001
From: David Gilman <[email protected]>
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


8 changes: 8 additions & 0 deletions packages/p/python-Flask-Admin/python-Flask-Admin.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Tue Oct 24 12:14:40 UTC 2023 - Markéta Machová <[email protected]>

- 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 <[email protected]>

Expand Down
8 changes: 6 additions & 2 deletions packages/p/python-Flask-Admin/python-Flask-Admin.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
Expand Down
44 changes: 44 additions & 0 deletions packages/p/python-Flask-Admin/reverse-relation-for-model.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
From 84139973c90aa43e00267d294fd9dcd7d3aa4d2d Mon Sep 17 00:00:00 2001
From: Chris Mayo <[email protected]>
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):

0 comments on commit f44afe5

Please sign in to comment.