Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 22 additions & 55 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,74 +14,41 @@ jobs:
fail-fast: false
matrix:
include:
# Django 2.2
- tox-env: "py36-dj22"
python-version: "3.6"
- tox-env: "py37-dj22"
python-version: "3.7"
- tox-env: "py38-dj22"
python-version: "3.8"
- tox-env: "py39-dj22"
python-version: "3.9"
# Django 3.0
- tox-env: "py36-dj30"
python-version: "3.6"
- tox-env: "py37-dj30"
python-version: "3.7"
- tox-env: "py38-dj30"
python-version: "3.8"
- tox-env: "py39-dj30"
python-version: "3.9"
# Django 3.1
- tox-env: "py36-dj31"
python-version: "3.6"
- tox-env: "py37-dj31"
python-version: "3.7"
- tox-env: "py38-dj31"
python-version: "3.8"
- tox-env: "py39-dj31"
python-version: "3.9"
# Django 3.2
- tox-env: "py36-dj32"
python-version: "3.6"
- tox-env: "py37-dj32"
python-version: "3.7"
- tox-env: "py38-dj32"
python-version: "3.8"
- tox-env: "py39-dj32"
python-version: "3.9"
- tox-env: "py310-dj32"
python-version: "3.10"
# Django 4.0
- tox-env: "py38-dj40"
python-version: "3.8"
- tox-env: "py39-dj40"
python-version: "3.9"
- tox-env: "py310-dj40"
# Django 5.2
- tox-env: "py310-dj52"
python-version: "3.10"
# Django 5.2
- tox-env: "py311-dj52"
python-version: "3.11"
# Django 5.2
- tox-env: "py312-dj52"
python-version: "3.12"
# Django 5.2
- tox-env: "py313-dj52"
python-version: "3.13"

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip install -U pip tox
- name: Run tests
run: tox -e ${{ matrix.tox-env }}
- name: Publish Test Report
uses: mikepenz/action-junit-report@v2
uses: mikepenz/action-junit-report@v6
with:
report_paths: '**/junit/TEST-*.xml'

# Lint
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: 3.9
python-version: "3.10"
- name: Install dependencies
run: pip install tox -U pip
- name: Lint
Expand All @@ -94,14 +61,14 @@ jobs:
needs: [test, lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: 3.9
- uses: actions/setup-node@v2
python-version: "3.10"
- uses: actions/setup-node@v6
with:
node-version: '14' # https://github.com/cycjimmy/semantic-release-action/issues/79#issuecomment-955463633
- uses: cycjimmy/semantic-release-action@v2
- uses: cycjimmy/semantic-release-action@v6
with:
semantic_version: 18
extra_plugins: |
Expand Down
6 changes: 2 additions & 4 deletions filebrowser_safe/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@
# For now we just want to be able tu run the test suite without having mezzanine
# installed, and this will do. Remove once filebrowser-safe is completely decoupled
# from mezzanine.
warnings.warn(
"""
warnings.warn("""
You are using a placeholder implementation of the current_site_id function
intended for test purposes only. If you're seeing this you might have a problem
with your Mezzanine installation.
"""
)
""")

def current_site_id():
return dj_settings.SITE_ID
Expand Down
6 changes: 2 additions & 4 deletions filebrowser_safe/templatetags/fb_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
# For now we just want to be able tu run the test suite without having mezzanine
# installed, and this will do. Remove once filebrowser-safe is completely decoupled
# from mezzanine.
warnings.warn(
"""
warnings.warn("""
You are using a placeholder implementation of the thumbnail tag intended for
test purposes only. If you're seeing this you might have a problem with your
Mezzanine installation.
"""
)
""")

def thumbnail(image_url, *args, **kwargs):
return image_url
Expand Down
20 changes: 13 additions & 7 deletions filebrowser_safe/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re
from json import dumps

from django import forms
from django import forms, get_version
from django.conf import settings as django_settings
from django.contrib import messages
from django.contrib.admin.views.decorators import staff_member_required
Expand Down Expand Up @@ -39,20 +39,26 @@
try:
from mezzanine.utils.html import escape
except ImportError:
escape = lambda s: s # noqa

def escape(s):
return s # noqa


if get_version() > "4":
DEFAULT_FILE_STORAGE = django_settings.STORAGES["default"]["BACKEND"]
else:
DEFAULT_FILE_STORAGE = django_settings.DEFAULT_FILE_STORAGE
# Add some required methods to FileSystemStorage
storage_class_name = django_settings.DEFAULT_FILE_STORAGE.split(".")[-1]
storage_class_name = DEFAULT_FILE_STORAGE.split(".")[-1]
mixin_class_name = "filebrowser_safe.storage.%sMixin" % storage_class_name

# Workaround for django-s3-folder-storage
if django_settings.DEFAULT_FILE_STORAGE == "s3_folder_storage.s3.DefaultStorage":
if DEFAULT_FILE_STORAGE == "s3_folder_storage.s3.DefaultStorage":
mixin_class_name = "filebrowser_safe.storage.S3BotoStorageMixin"

try:
mixin_class = import_string(mixin_class_name)
storage_class = import_string(django_settings.DEFAULT_FILE_STORAGE)
storage_class = import_string(DEFAULT_FILE_STORAGE)
except ImportError:
pass
else:
Expand Down Expand Up @@ -275,7 +281,7 @@ def mkdir(request):
)
return HttpResponseRedirect(redirect_url)
except OSError as xxx_todo_changeme:
(errno, strerror) = xxx_todo_changeme.args
errno, strerror = xxx_todo_changeme.args
if errno == 13:
form.errors["dir_name"] = forms.utils.ErrorList(
[_("Permission denied.")]
Expand Down Expand Up @@ -555,7 +561,7 @@ def rename(request):
)
return HttpResponseRedirect(redirect_url)
except OSError as xxx_todo_changeme1:
(errno, strerror) = xxx_todo_changeme1.args
errno, strerror = xxx_todo_changeme1.args
form.errors["name"] = forms.util.ErrorList([_("Error.")])
else:
file_basename = os.path.splitext(filename)[0]
Expand Down
17 changes: 8 additions & 9 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ license_file = LICENSE
classifiers =
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3.13

[options]
python_requires = >=3.6
python_requires = >=3.10
packages = find:
include_package_data = true

Expand All @@ -29,10 +28,10 @@ testing =
pytest-django >= 4, <5
pytest-cov >= 2, < 3
codestyle =
flake8 >= 3, <4
black==20.8b1
isort >= 5, <6
pyupgrade >= 2, <3
flake8 >= 7, <8
black==26.3.1
isort >= 8, <9
pyupgrade >= 3, <4

# Building

Expand Down
8 changes: 2 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
envlist =
py{36,37,38,39,310}-dj{22,30,31,32,40}
py{310,311,312,313}-dj{52}
package
lint

Expand All @@ -9,11 +9,7 @@ envlist =
usedevelop = true
deps =
.[testing]
dj22: Django>=2.2, <3
dj30: Django>=3.0, <3.1
dj31: Django>=3.1, <3.2
dj32: Django>=3.2, <3.3
dj40: Django>=4.0, <4.1
dj52: Django>=5.2, <5.3
commands =
pytest --basetemp="{envtmpdir}" --junitxml="junit/TEST-{envname}.xml" {posargs}

Expand Down