Skip to content
Closed
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
39 changes: 39 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Tests

on:
pull_request:
branches: [master]
push:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
strategy:
max-parallel: 2
matrix:
python: ["3.8", "3.9", "3.10", "3.11"]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Install dependencies
id: install-dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions

- name: Test with tox
id: test-with-tox
run: |
tox
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ __pycache__
.DS_Store

/test_robots.db
venv
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Changelog

## Unreleased

- Add upgrade considerations for Wagtail 5.1

## 1.0.0 (2023-07-25)

- Integrate [wagtail upgrades](https://github.com/unexceptable/wagtail-robots/pull/20)
16 changes: 6 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@ user:
migrate:
@python testmanage.py migrate

tox-215:
tox -e py38-dj32-wt215

tox-216:
tox -e py38-dj32-wt216
tox-41:
tox -e py38-dj41-wt41

tox-3:
tox -e py38-dj40-wt30
tox-42:
tox -e py38-dj42-wt42

tox-4:
tox -e py38-dj40-wt40
tox -e py38-dj41-wt41
tox-50:
tox -e py38-dj42-wt50
11 changes: 10 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,23 @@ Installation
Use your favorite Python installer to install it from PyPI::

pip install wagtail-robots
pip install wagtail_modeladmin # if Wagtail >= 5.1

Or get the source from the application site at::

http://github.com/adrian-turjak/wagtail-robots/

Then follow these steps:

1. Add ``'wagtail.contrib.modeladmin'`` and ``'robots'`` to your INSTALLED_APPS_ setting.
1. Add ``robots`` and ``modeladmin`` to the ``INSTALLED_APPS`` setting in your project settings::

INSTALLED_APPS = [
...
'wagtail_modeladmin', # if Wagtail >=5.1; Don't repeat if it's there already
'wagtail.contrib.modeladmin', # if Wagtail <5.1; Don't repeat if it's there already
'robots',
]

2. Run the ``migrate`` management command

You may want to additionally setup the `Wagtail sitemap generator`_.
Expand Down
Binary file modified docs/source/static/1_in_menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/static/2_index.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/static/3_create_edit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/static/4_create_edit_condensed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/static/5_index_rule.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 4 additions & 14 deletions robots/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import django
from six import u

from django.db import models
from django.utils.text import get_text_list
Expand All @@ -7,20 +7,10 @@
from modelcluster.models import ClusterableModel
from modelcluster.fields import ParentalKey

from robots.panels import WrappedInlinepanel
from wagtail.admin.panels import FieldPanel
from wagtail.models import Site

from wagtail import VERSION as WAGTAIL_VERSION
if WAGTAIL_VERSION >= (3, 0):
from wagtail.models import Site
from wagtail.admin.panels import FieldPanel
else:
from wagtail.core.models import Site
from wagtail.admin.edit_handlers import FieldPanel

if django.VERSION >= (3, 0):
from six import u
else:
from django.utils.six import u
from robots.panels import WrappedInlinepanel


class BaseUrl(models.Model):
Expand Down
19 changes: 5 additions & 14 deletions robots/panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

from django.conf import settings

from wagtail import VERSION as WAGTAIL_VERSION
if WAGTAIL_VERSION >= (3, 0):
from wagtail.admin.panels import InlinePanel
else:
from wagtail.admin.edit_handlers import InlinePanel
from wagtail.admin.panels import InlinePanel


def WrappedInlinepanel(relation_name, heading='', label='',
Expand All @@ -26,15 +22,10 @@ def WrappedInlinepanel(relation_name, heading='', label='',
'new_card_header_text': new_card_header_text,
}
else:
if WAGTAIL_VERSION >= (2, 0):
defaults = {
'heading': heading,
'label': label,
}
else:
defaults = {
'label': label,
}
defaults = {
'heading': heading,
'label': label,
}

defaults.update(kwargs)
return klass(relation_name, **defaults)
8 changes: 4 additions & 4 deletions robots/test/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

import os

from wagtail import VERSION as WAGTAIL_VERSION

# Build paths inside the project like this: os.path.join(PROJECT_DIR, ...)
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.path.dirname(PROJECT_DIR)
Expand Down Expand Up @@ -42,11 +44,11 @@
"wagtail.search",
"wagtail.admin",
"wagtail.api.v2",
"wagtail.contrib.modeladmin",
"wagtail_modeladmin" if WAGTAIL_VERSION >= (5, 1) else "wagtail.contrib.modeladmin",
"wagtail.contrib.routable_page",
"wagtail.contrib.styleguide",
"wagtail.sites",
"wagtail.core",
"wagtail",
"taggit",
"rest_framework",
"django.contrib.admin",
Expand Down Expand Up @@ -125,8 +127,6 @@

USE_I18N = True

USE_L10N = True

USE_TZ = True


Expand Down
2 changes: 1 addition & 1 deletion robots/test/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from wagtail.admin import urls as wagtailadmin_urls
from wagtail.documents import urls as wagtaildocs_urls
from wagtail.core import urls as wagtail_urls
from wagtail import urls as wagtail_urls

urlpatterns = [
path("django-admin/", admin.site.urls),
Expand Down
18 changes: 4 additions & 14 deletions robots/views.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
import django
from django.db.models import Q
from django.views.decorators.cache import cache_page
from django.views.generic import ListView
from django.urls import NoReverseMatch, reverse

from wagtail.contrib.sitemaps.views import sitemap
from wagtail.models import Site

from robots import settings
from robots.models import Rule

if django.VERSION[:2] >= (2, 0):
from django.urls import NoReverseMatch, reverse
else:
from django.core.urlresolvers import NoReverseMatch, reverse

from wagtail import VERSION as WAGTAIL_VERSION # noqa
if WAGTAIL_VERSION >= (3, 0):
from wagtail.models import Site
else:
from wagtail.core.models import Site

from wagtail.contrib.sitemaps.views import sitemap


class RuleList(ListView):
"""
Expand Down
7 changes: 6 additions & 1 deletion robots/wagtail_hooks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@

from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register
from wagtail import VERSION as WAGTAIL_VERSION

if WAGTAIL_VERSION >= (5, 1):
from wagtail_modeladmin.options import ModelAdmin, modeladmin_register
else:
from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register

from robots.models import Rule

Expand Down
14 changes: 9 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@
],
},
install_requires=[
'wagtail>=2.15',
'wagtail>=4.1',
],
extras_require={
'testing': [
'wagtail-modeladmin>=1.0',
],
},
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Web Environment',
Expand All @@ -33,16 +38,15 @@
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development',
'Topic :: Software Development :: Libraries :: Application Frameworks',
'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',
'Framework :: Django',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.0',
'Framework :: Django :: 4.1',
'Framework :: Wagtail :: 2',
'Framework :: Wagtail :: 3',
'Framework :: Django :: 4.2',
'Framework :: Wagtail :: 4',
'Framework :: Wagtail :: 5',
]
)
2 changes: 1 addition & 1 deletion testmanage.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def runtests():
try:
execute_from_command_line(argv)
finally:
from wagtail.tests.settings import STATIC_ROOT, MEDIA_ROOT
from wagtail.test.settings import STATIC_ROOT, MEDIA_ROOT

shutil.rmtree(STATIC_ROOT, ignore_errors=True)
shutil.rmtree(MEDIA_ROOT, ignore_errors=True)
Expand Down
13 changes: 10 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ skipsdist = True
usedevelop = True

envlist =
py{37}-dj{32}-wt{215,216}
py{38,39,310}-dj{32,40}-wt{216,30,40}
py{39,310}-dj{41}-wt{40,41}
py{38,39,310}-dj{32,41}-wt{41,42,50,51}
py311-dj41-wt{41,42,50,51}
py311-dj42-wt{50,51}

[gh-actions]
python =
3.8: py38
3.9: py39
3.10: py310
3.11: py311

[testenv]
deps = -r{toxinidir}/test-requirements.txt
Expand Down