Skip to content

Commit

Permalink
Update needed for Django 4.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan-CTL committed Aug 1, 2023
1 parent 7184b45 commit 9afd358
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 28 deletions.
4 changes: 3 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
2.4.0
2.4.0 (2023-08-01)
====================
* Removed django-jenkins
* Prioritize urllib.parse.quote import over deprecated django.utils.http.urlquote
* Adds compatibility with Django 4.2

2.3.0 (2023-02-17)
====================
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ WHEEL_VERSION ?= 0.37.1
PIP_VERSION ?= 22.3
MAX_COMPLEXITY ?= 12
PY_DIRS ?= $(APP)
DJANGO ?= "Django==3.2.16"
DJANGO ?= "Django==4.2.3"

FLAKE8 ?= $(VE)/bin/flake8
PIP ?= $(VE)/bin/pip
Expand Down
4 changes: 2 additions & 2 deletions courseaffils/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.http import HttpResponseRedirect
from django.conf import settings
from django.utils.encoding import smart_text
from django.utils.encoding import smart_str

from courseaffils.models import Course, CourseAccess
from courseaffils.views import CourseListView
Expand Down Expand Up @@ -79,7 +79,7 @@ def process_response(self, request, response):
if 'ANONYMIZE' in request.COOKIES:
for user, uid in getattr(request, 'scrub_names', {}).items():
if len(user.last_name) > 3:
response.content = smart_text(
response.content = smart_str(
response.content,
errors='ignore').replace(
user.get_full_name(), 'User Name_%d' % uid)
Expand Down
6 changes: 3 additions & 3 deletions courseaffils/tests/test_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ def test_already_selected_course(self):
assert not already_selected_course(StubRequest(False))

def test_cmm_process_response(self):
c = CourseManagerMiddleware()
c = CourseManagerMiddleware(self)
assert c.process_response(StubRequest(True), "foo") == "foo"

def test_cmm_process_response_anon(self):
c = CourseManagerMiddleware()
c = CourseManagerMiddleware(self)
r = StubRequest(self.c)
r.user = self.student
r.COOKIES['ANONYMIZE'] = True
Expand All @@ -82,7 +82,7 @@ def test_cmm_process_response_anon(self):
assert "long enough" not in c.process_response(r, resp).content

def test_cmm_process_request(self):
c = CourseManagerMiddleware()
c = CourseManagerMiddleware(self)
r = StubRequest(self.c)
r.user = self.student
assert c.process_request(r) is None
Expand Down
14 changes: 7 additions & 7 deletions courseaffils/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import unicode_literals

from django.test import TestCase, override_settings
from django.utils.encoding import smart_text
from django.utils.encoding import smart_str
from courseaffils.columbia import CourseStringMapper
from courseaffils.models import Course, CourseSettings
from courseaffils.models import CourseInfo, CourseAccess
Expand Down Expand Up @@ -51,7 +51,7 @@ def tearDown(self):
self.faculty.delete()

def test_str(self):
self.assertEqual(smart_text(self.c), "test course")
self.assertEqual(smart_str(self.c), "test course")

def test_members(self):
self.assertIn(self.student, self.c.members)
Expand Down Expand Up @@ -135,7 +135,7 @@ def test_details(self):
"nonexistant",
default="a default value"), "a default value")

self.assertEqual(smart_text(self.c.details()["foo"]),
self.assertEqual(smart_str(self.c.details()["foo"]),
"(test course) foo: bar")

# update
Expand All @@ -146,22 +146,22 @@ def test_coursesettings(self):
cs = CourseSettings.objects.create(
course=self.c,
custom_headers="some headers")
self.assertEqual(smart_text(cs), "Settings for test course")
self.assertEqual(smart_str(cs), "Settings for test course")

def test_courseinfo(self):
# current behavior is that a CourseInfo object
# is created automatically for each course
# by a hook elsewhere. so verify that.
self.assertNotEqual(CourseInfo.objects.all().count(), 0)

self.assertEqual(smart_text(self.c.info),
self.assertEqual(smart_str(self.c.info),
'test course () None None-None')

self.c.info.year = 2013
self.c.info.term = 1
self.c.info.days = "MWF"
self.c.info.save()
self.assertEqual(smart_text(self.c.info),
self.assertEqual(smart_str(self.c.info),
'test course (Spring 2013) MWF None-None')

self.assertEqual(self.c.info.time(), 'MWF')
Expand Down Expand Up @@ -191,7 +191,7 @@ def test_is_valid_from_factory(self):
self.aa.full_clean()

def test_str(self):
self.assertEqual(smart_text(self.aa), self.aa.name)
self.assertEqual(smart_str(self.aa), self.aa.name)

def test_past_present_future(self):
with freeze_time('2012-01-14'):
Expand Down
1 change: 0 additions & 1 deletion courseaffils/tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
'django.contrib.contenttypes',
'django.contrib.sessions',
'courseaffils',
'django_markwhat',
)

PROJECT_APPS = [
Expand Down
14 changes: 7 additions & 7 deletions courseaffils/tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from __future__ import unicode_literals

from django.conf.urls import url
from django.urls import path
from courseaffils import views


urlpatterns = [
url(r'^select_course/$',
views.CourseListView.as_view(),
name='select_course'),
url(r'^course/create/$',
views.CourseCreateView.as_view(),
name='create_course'),
path('select_course/',
views.CourseListView.as_view(),
name='select_course'),
path('course/create/',
views.CourseCreateView.as_view(),
name='create_course'),
]
10 changes: 7 additions & 3 deletions courseaffils/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
from django.views.generic.edit import CreateView
from django.views.generic.list import ListView
from django.utils import timezone
from django.utils.http import urlquote
from django.http import HttpResponseForbidden, HttpResponse
from django.contrib.auth.models import User

try:
from urllib.parse import quote
except ImportError:
from django.utils.http import urlquote as quote


SESSION_KEY = 'ccnmtl.courseaffils.course'

Expand Down Expand Up @@ -130,7 +134,7 @@ def get_context_data(self, **kwargs):
if 'QUERY_STRING' in self.request.META \
and 'unset_course' not in self.request.GET:
# just GET (until someone complains)
escaped_path = urlquote(self.request.get_full_path())
escaped_path = quote(self.request.get_full_path())
next_redirect = '&next=' + escaped_path

context.update({
Expand Down Expand Up @@ -173,7 +177,7 @@ def select_course(request):
and 'unset_course' not in request.GET:
# just GET (until someone complains)
response_dict['next_redirect'] = '&next=%s' % (
urlquote(request.get_full_path()))
quote(request.get_full_path()))

return render(request, 'courseaffils/select_course.html',
response_dict)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from setuptools import setup, find_packages

version = '2.3.0'
version = '2.4.0'


setup(
name='django-courseaffils',
version=version,
description="course affiliations",
long_description="a django app which manages course information",
long_description="A django app which manages course information.",
classifiers=[],
keywords='',
author='Columbia University\'s Center for Teaching and Learning',
Expand Down
1 change: 0 additions & 1 deletion test_reqs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ zipp==3.16.2 # for flake8
flake8==6.1.0
pep8==1.7.1
pyflakes==3.1.0
django-markwhat==1.6.2
Faker==19.2.0
factory_boy==3.3.0
freezegun==1.2.2
Expand Down

0 comments on commit 9afd358

Please sign in to comment.