Skip to content

Commit

Permalink
Add django 4.2 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolas committed Mar 7, 2024
1 parent 5b8dde5 commit f00c911
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 88 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ VE ?= ./ve
REQUIREMENTS ?= test_reqs.txt
SYS_PYTHON ?= python3
PY_SENTINAL ?= $(VE)/sentinal
WHEEL_VERSION ?= 0.33.6
PIP_VERSION ?= 20.0.2
WHEEL_VERSION ?= 0.42.0
PIP_VERSION ?= 24.0
MAX_COMPLEXITY ?= 8
PY_DIRS ?= $(APP)
DJANGO ?= "Django==3.2.13"
DJANGO ?= "Django==4.2.11"

FLAKE8 ?= $(VE)/bin/flake8
PIP ?= $(VE)/bin/pip
Expand Down
4 changes: 2 additions & 2 deletions pagetree/templates/pagetree/testblock.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{% load markup %}
{{pageblock.body|markdown}}
{% load markdownify %}
{{ pageblock.body|markdownify }}
12 changes: 6 additions & 6 deletions pagetree/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,11 @@ def test_import_from_dict(self):
'css_extra': 'new css_extra',
'body': 'new body'}
b.import_from_dict(d)
self.assertEquals(b.label, 'new label')
self.assertEquals(b.css_extra, 'new css_extra')
self.assertEqual(b.label, 'new label')
self.assertEqual(b.css_extra, 'new css_extra')

sub = b.block()
self.assertEquals(sub.body, 'new body')
self.assertEqual(sub.body, 'new body')

def test_import_custom_block_dict(self):
b = self.section1.pageblock_set.first()
Expand All @@ -477,8 +477,8 @@ def test_import_custom_block_dict(self):
b.import_from_dict(d)

sub = b.block()
self.assertEquals(sub.display_name, 'Test Block')
self.assertEquals(sub.body, 'abc')
self.assertEqual(sub.display_name, 'Test Block')
self.assertEqual(sub.body, 'abc')


class UserTrackingTest(TestCase):
Expand Down Expand Up @@ -784,7 +784,7 @@ def test_clone_hierarchy(self):
descendants = duplicate.get_root().get_descendants()
self.assertTrue(descendants[0].label, 'Section 1')
self.assertTrue(descendants[0].depth, 1)
self.assertEquals(descendants[0].pageblock_set.count(), 1)
self.assertEqual(descendants[0].pageblock_set.count(), 1)

self.assertTrue(descendants[1].label, 'Section 2')
self.assertTrue(descendants[1].depth, 1)
Expand Down
22 changes: 11 additions & 11 deletions pagetree/tests/test_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ def setUp(self):
lambda x: x.username)

def test_identifier(self):
self.assertEquals(self.column.identifier(), 'username')
self.assertEqual(self.column.identifier(), 'username')

def test_metadata(self):
key_row = ['', 'username', 'profile', 'string', 'Username']
self.assertEquals(self.column.metadata(), key_row)
self.assertEqual(self.column.metadata(), key_row)

def test_user_value(self):
user = UserFactory()
self.assertEquals(self.column.user_value(user), user.username)
self.assertEqual(self.column.user_value(user), user.username)


class PagetreeReportTest(PagetreeTestCase):
Expand All @@ -34,34 +34,34 @@ def setUp(self):
self.user = UserFactory()

def test_users(self):
self.assertEquals(len(self.report.users()), 1)
self.assertEqual(len(self.report.users()), 1)

def test_standalone_columns(self):
self.assertEquals(len(self.report.standalone_columns()), 0)
self.assertEqual(len(self.report.standalone_columns()), 0)

def test_metadata_columns(self):
hierarchies = Hierarchy.objects.all()
self.assertEquals(len(hierarchies), 2)
self.assertEqual(len(hierarchies), 2)
columns = self.report.metadata_columns(hierarchies)
self.assertEquals(len(columns), 2)
self.assertEqual(len(columns), 2)

def test_metadata(self):
hierarchies = Hierarchy.objects.all()
rows = []
for row in self.report.metadata(hierarchies):
rows.append(row)
self.assertEquals(len(rows), 4)
self.assertEqual(len(rows), 4)

def test_value_columns(self):
hierarchies = Hierarchy.objects.all()
columns = self.report.value_columns(hierarchies)
self.assertEquals(len(columns), 2)
self.assertEqual(len(columns), 2)

def test_values(self):
hierarchies = Hierarchy.objects.all()
rows = []
for row in self.report.values(hierarchies):
rows.append(row)
self.assertEquals(len(rows), 2)
self.assertEqual(len(rows), 2)

self.assertEquals(rows[1][0], self.user.username)
self.assertEqual(rows[1][0], self.user.username)
6 changes: 3 additions & 3 deletions pagetree/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ def test_pageblock_json_export(self):
the_json = loads(smart_str(response.content))
self.assertEqual(the_json["body"],
"You should now use the edit link to add content")
self.assertEquals(the_json["css_extra"], "the-css-class")
self.assertEquals(the_json["block_type"], "Test Block")
self.assertEquals(the_json["label"], "Welcome to your new Forest Site")
self.assertEqual(the_json["css_extra"], "the-css-class")
self.assertEqual(the_json["block_type"], "Test Block")
self.assertEqual(the_json["label"], "Welcome to your new Forest Site")

def test_edit_pageblock(self):
p = PageBlock.objects.all()[0]
Expand Down
50 changes: 25 additions & 25 deletions pagetree/tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
from __future__ import unicode_literals

from django.conf.urls import include, url
from django.urls import include, re_path
from pagetree.generic.views import EditView, InstructorView, PageView

urlpatterns = [
url(r'^pagetree/', include('pagetree.urls')),
re_path(r'^pagetree/', include('pagetree.urls')),

# instantiate generic views using a template that doesn't
# extend/depend on base.html
url(r'^pages/edit/(?P<path>.*)$',
EditView.as_view(template_name="pagetree/test_page.html"),
{}, 'edit-page'),
url(r'^pages/instructor/(?P<path>.*)$',
InstructorView.as_view(template_name="pagetree/test_page.html")),
url(r'^pages/(?P<path>.*)$',
PageView.as_view(template_name="pagetree/test_page.html")),
re_path(r'^pages/edit/(?P<path>.*)$',
EditView.as_view(template_name="pagetree/test_page.html"),
{}, 'edit-page'),
re_path(r'^pages/instructor/(?P<path>.*)$',
InstructorView.as_view(template_name="pagetree/test_page.html")),
re_path(r'^pages/(?P<path>.*)$',
PageView.as_view(template_name="pagetree/test_page.html")),

# a second set to make sure non-default hierarchies
# get handled as well
url(r'^pages2/edit/(?P<path>.*)$',
EditView.as_view(
hierarchy_name="two",
hierarchy_base="/pages2",
template_name="pagetree/test_page.html"),
{}, 'edit-page'),
url(r'^pages2/instructor/(?P<path>.*)$',
InstructorView.as_view(
hierarchy_name="two",
hierarchy_base="/pages2",
template_name="pagetree/test_page.html")),
url(r'^pages2/(?P<path>.*)$',
PageView.as_view(
hierarchy_name="two",
hierarchy_base="/pages2",
template_name="pagetree/test_page.html")),
re_path(r'^pages2/edit/(?P<path>.*)$',
EditView.as_view(
hierarchy_name="two",
hierarchy_base="/pages2",
template_name="pagetree/test_page.html"),
{}, 'edit-page'),
re_path(r'^pages2/instructor/(?P<path>.*)$',
InstructorView.as_view(
hierarchy_name="two",
hierarchy_base="/pages2",
template_name="pagetree/test_page.html")),
re_path(r'^pages2/(?P<path>.*)$',
PageView.as_view(
hierarchy_name="two",
hierarchy_base="/pages2",
template_name="pagetree/test_page.html")),
]
62 changes: 31 additions & 31 deletions pagetree/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import os.path

from django.conf.urls import url
from django.urls import re_path
import django.views.static

from pagetree.generic.views import CloneHierarchyView
Expand All @@ -17,37 +17,37 @@
media_root = os.path.join(os.path.dirname(__file__), "media")

urlpatterns = [
url(r'^media/(?P<path>.*)$', django.views.static.serve,
{'document_root': media_root}),
re_path(r'^media/(?P<path>.*)$', django.views.static.serve,
{'document_root': media_root}),
]

urlpatterns += [
url(r'^reorder_pageblocks/(?P<section_id>\d+)/$', reorder_pageblocks, {},
"reorder-pageblocks"),
url(r'^reorder_section_children/(?P<section_id>\d+)/$',
reorder_section_children, {}, "reorder-section-children"),
url(r'^section/add/(?P<section_id>\d+)/$', add_child_section, {},
"add-child-section"),
url(r'^section/move/(?P<section_id>\d+)/$', move_section, {},
"move-section"),
url(r'^pageblock/add/(?P<section_id>\d+)/$', add_pageblock, {},
"add-pageblock"),
url(r'^pageblock/edit/(?P<pageblock_id>\d+)/$', edit_pageblock, {},
"edit-pageblock"),
url(r'^pageblock/jsonexport/(?P<pageblock_id>\d+)/$',
export_pageblock_json, {}, "export-pageblock-json"),
url(r'^pageblock/jsonimport/(?P<pageblock_id>\d+)/$',
import_pageblock_json, {}, "import-pageblock-json"),
url(r'^delete_section/(?P<section_id>\d+)/$', delete_section, {},
"delete-section"),
url(r'^edit_section/(?P<section_id>\d+)/$', edit_section, {},
"edit-section"),
url(r'^delete_pageblock/(?P<pageblock_id>\d+)/$', delete_pageblock, {},
"delete-pageblock"),
url(r'^create_tree_root$', create_tree_root, {}, "create_tree_root"),
url(r'^export/$', exporter, {}, 'export-hierarchy'),
url(r'^version/(?P<version_id>\d+)/revert/$', revert_to_version, {},
"revert-to-version"),
url(r'^clone_hierarchy/(?P<hierarchy_id>\d+)/$',
CloneHierarchyView.as_view(), name="clone-hierarchy"),
re_path(r'^reorder_pageblocks/(?P<section_id>\d+)/$', reorder_pageblocks,
{}, "reorder-pageblocks"),
re_path(r'^reorder_section_children/(?P<section_id>\d+)/$',
reorder_section_children, {}, "reorder-section-children"),
re_path(r'^section/add/(?P<section_id>\d+)/$', add_child_section, {},
"add-child-section"),
re_path(r'^section/move/(?P<section_id>\d+)/$', move_section, {},
"move-section"),
re_path(r'^pageblock/add/(?P<section_id>\d+)/$', add_pageblock, {},
"add-pageblock"),
re_path(r'^pageblock/edit/(?P<pageblock_id>\d+)/$', edit_pageblock, {},
"edit-pageblock"),
re_path(r'^pageblock/jsonexport/(?P<pageblock_id>\d+)/$',
export_pageblock_json, {}, "export-pageblock-json"),
re_path(r'^pageblock/jsonimport/(?P<pageblock_id>\d+)/$',
import_pageblock_json, {}, "import-pageblock-json"),
re_path(r'^delete_section/(?P<section_id>\d+)/$', delete_section, {},
"delete-section"),
re_path(r'^edit_section/(?P<section_id>\d+)/$', edit_section, {},
"edit-section"),
re_path(r'^delete_pageblock/(?P<pageblock_id>\d+)/$', delete_pageblock, {},
"delete-pageblock"),
re_path(r'^create_tree_root$', create_tree_root, {}, "create_tree_root"),
re_path(r'^export/$', exporter, {}, 'export-hierarchy'),
re_path(r'^version/(?P<version_id>\d+)/revert/$', revert_to_version, {},
"revert-to-version"),
re_path(r'^clone_hierarchy/(?P<hierarchy_id>\d+)/$',
CloneHierarchyView.as_view(), name="clone-hierarchy"),
]
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Used by readthedocs.org to build the documentation
Django>=3.2.14,<4
Django>=4.2.11,<5
2 changes: 1 addition & 1 deletion runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def main():
'django.contrib.contenttypes',
'django.contrib.sessions',
'pagetree',
'django_markwhat',
'django_jenkins',
'markdownify.apps.MarkdownifyConfig',
),
TEST_RUNNER='django.test.runner.DiscoverRunner',
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField',
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
install_requires=[
"Django",
"django-treebeard",
"Markdown",
"coverage",
"django-markwhat",
"django-bootstrap3",
"six",
"Markdown",
"django-markdownify",
],
scripts=[],
license="BSD",
Expand Down
10 changes: 7 additions & 3 deletions test_reqs.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
django-treebeard==4.7.1
Markdown>=2.6.11,<3
coverage==7.4.3
importlib-metadata<7.1 # for flake8
importlib-metadata==7.0.2 # for flake8
typing_extensions==4.10.0
zipp==3.17.0 # for flake8
flake8==7.0.0
django-jenkins==0.110.0
pep8==1.7.1
pyflakes==3.2.0
django-markwhat==1.6.2
Faker==24.0.0
factory_boy==3.3.0
six==1.16.0
pycodestyle==2.11.1
mccabe==0.7.0
python-dateutil==2.9.0.post0
text-unidecode==1.3

Markdown==3.5.2
django-markdownify==0.9.3
bleach==6.1.0
webencodings==0.5.1
tinycss2==1.2.1 # django-markdownify

0 comments on commit f00c911

Please sign in to comment.