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 8, 2024
1 parent 5b8dde5 commit 47ebed5
Show file tree
Hide file tree
Showing 16 changed files with 133 additions and 105 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.5.0
=================
* Added Django 4.2 compatibility

1.4.3 (2021-02-23)
=================
* Dependency updates
Expand Down
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
10 changes: 5 additions & 5 deletions pagetree/templates/pagetree/edit_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

<ul class="nav navbar-nav">
{% for section in modules %}
<li{% ifequal section.id module.id %} class="active"{% endifequal %}><a href="{{section.get_edit_url}}">{{section.label}}</a></li>
<li{% if section.id == module.id %} class="active"{% endif %}><a href="{{section.get_edit_url}}">{{section.label}}</a></li>
{% endfor %}
</ul>

Expand Down Expand Up @@ -134,10 +134,10 @@ <h3 style="margin-top: 0;"><a href="{{root.get_edit_url}}">{{section.hierarchy.n
<ul>
{% for s in root.get_descendants %}
<li class="menu" style="list-style: none; line-height: 150%">
{% ifequal s section %}
{% if s == section %}
<span class="glyphicon glyphicon-hand-right"></span>
<strong>
{% endifequal %}
{% endif %}
<span title="The number of pageblocks in this section"
class="pagetree-pageblock-section-count">
{{s.pageblock_set.count}}
Expand All @@ -147,10 +147,10 @@ <h3 style="margin-top: 0;"><a href="{{root.get_edit_url}}">{{section.hierarchy.n
>{{s.label|default:"Empty Label"}}
{% if s.label|length < 1 %} ({{s.slug}}) {% endif %}
</a>
{% ifequal s section %}
{% if s == section %}
</strong>
<span class="glyphicon glyphicon-hand-left"></span>
{% endifequal %}
{% endif %}
{% if s.get_children %}
<ul>
{% else %}{% if s.is_last_child %}
Expand Down
2 changes: 1 addition & 1 deletion pagetree/templates/pagetree/instructor_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h3>Sections</h3>

<ul class="nav navbar-nav">
{% for section in modules %}
<li{% ifequal section.id module.id %} class="active"{% endifequal %}><a href="{{section.get_instructor_url}}">{{section.label}}</a></li>
<li{% if section.id == module.id %} class="active"{% endif %}><a href="{{section.get_instructor_url}}">{{section.label}}</a></li>
{% endfor %}
</ul>

Expand Down
20 changes: 10 additions & 10 deletions pagetree/templates/pagetree/menu.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
<ul>
{% for s in module.get_descendants %}
{% ifequal s.id module.id %}
{% if s.id == module.id %}
{% else %}
<li class="menu-{{s.depth}}">
{% ifnotequal s.id section.id %}
{% ifequal menu_base "/edit" %}
{% if s.id != section.id %}
{% if menu_base == "/edit" %}
<a href="{{s.get_edit_url}}">
{% else %}
{% ifequal menu_base "/instructor" %}
{% if menu_base == "/instructor" %}
<a href="{{s.get_instructor_url}}">
{% else %}
<a href="{{menu_base}}{{s.get_absolute_url}}">
{% endifequal %}
{% endifequal %}
{% endif %}
{% endif %}
{% else %}
<b>
{% endifnotequal %}
{% endif %}
{{s.label}}
{% ifnotequal s.id section.id %}
{% if s.id != section.id %}
</a>
{% else %}
</b>
{% endifnotequal %}
{% endif %}
{% if s.get_children %}
<ul id="section-ul-{{s.id}}">
{% else %}
Expand All @@ -35,6 +35,6 @@
{% else %}
</li>
{% endif%}
{% endifequal %}
{% endif %}
{% endfor %}
</ul>
2 changes: 1 addition & 1 deletion pagetree/templates/pagetree/test_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<ul class="nav navbar-nav">
{% for section in modules %}
<li{% ifequal section.id module.id %} class="active"{% endifequal %}><a href="{{section.get_absolute_url}}">{{section.label}}</a></li>
<li{% if section.id == module.id %} class="active"{% endif %}><a href="{{section.get_absolute_url}}">{{section.label}}</a></li>
{% endfor %}
</ul>

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
Loading

0 comments on commit 47ebed5

Please sign in to comment.