Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
fix: fix django 4.0 deprecation warnings (#1498)
Browse files Browse the repository at this point in the history
  • Loading branch information
UsamaSadiq authored Sep 14, 2023
1 parent 991ee06 commit 4a946c9
Show file tree
Hide file tree
Showing 20 changed files with 109 additions and 112 deletions.
1 change: 0 additions & 1 deletion analytics_dashboard/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = 'core.apps.AnalyticsDashboardConfig'
4 changes: 1 addition & 3 deletions analytics_dashboard/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from analytics_dashboard.core.models import User


@admin.register(User)
class AnalyticsDashboardUserAdmin(UserAdmin):
pass


admin.site.register(User, AnalyticsDashboardUserAdmin)
2 changes: 1 addition & 1 deletion analytics_dashboard/core/templatetags/dashboard_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.conf import settings
from django.template.defaultfilters import stringfilter
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from opaque_keys.edx.keys import CourseKey
from slugify import slugify

Expand Down
2 changes: 1 addition & 1 deletion analytics_dashboard/core/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.contrib.auth import get_user_model
from django.test import TestCase
from django.test.utils import override_settings
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from analytics_dashboard.core.utils import (
CourseStructureApiClient,
Expand Down
4 changes: 2 additions & 2 deletions analytics_dashboard/core/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.test import TestCase
from django.test.utils import override_settings
from django.urls import reverse, reverse_lazy
from django.utils.http import urlquote
from urllib.parse import quote
from django_dynamic_fixture import G
from testfixtures import LogCapture

Expand Down Expand Up @@ -55,7 +55,7 @@ def setUp(self):
class RedirectTestCaseMixin:
def assertRedirectsNoFollow(self, response, expected_url, status_code=302, **querystringkwargs):
if querystringkwargs:
expected_url += '?{}'.format('&'.join('{}={}'.format(key, urlquote(value))
expected_url += '?{}'.format('&'.join('{}={}'.format(key, quote(value))
for (key, value) in querystringkwargs.items()))

self.assertEqual(response['Location'], f'{expected_url}')
Expand Down
2 changes: 1 addition & 1 deletion analytics_dashboard/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.conf import settings
from django.contrib.auth import get_user_model
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from soapbox.models import Message

from common import clients
Expand Down
2 changes: 1 addition & 1 deletion analytics_dashboard/courses/presenters/engagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from analyticsclient.client import Client
from analyticsclient.exceptions import NotFoundError
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from waffle import switch_is_active

from analytics_dashboard.core.templatetags.dashboard_extras import metric_percentage
Expand Down
2 changes: 1 addition & 1 deletion analytics_dashboard/courses/presenters/enrollment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from analyticsclient.constants import education_levels as EDUCATION_LEVEL
from analyticsclient.constants import enrollment_modes
from analyticsclient.constants import genders as GENDER
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django_countries import countries

import analytics_dashboard.courses.utils as utils
Expand Down
2 changes: 1 addition & 1 deletion analytics_dashboard/courses/presenters/performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.conf import settings
from django.core.cache import cache
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from requests.exceptions import HTTPError
from slugify import slugify

Expand Down
2 changes: 1 addition & 1 deletion analytics_dashboard/courses/tests/test_serializers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json

from django.test import TestCase
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from analytics_dashboard.courses.serializers import LazyEncoder

Expand Down
2 changes: 1 addition & 1 deletion analytics_dashboard/courses/tests/test_views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from django.contrib.humanize.templatetags.humanize import intcomma
from django.core.cache import cache
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from waffle.testutils import override_switch

from analytics_dashboard.core.tests.test_views import RedirectTestCaseMixin, UserTestCaseMixin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from ddt import ddt, data
from django.test import TestCase
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from waffle.testutils import override_switch

from analytics_dashboard.courses.tests import utils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.conf import settings
from django.test import TestCase
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from slugify import slugify
from waffle.testutils import override_switch

Expand Down
80 changes: 40 additions & 40 deletions analytics_dashboard/courses/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.conf import settings
from django.conf.urls import include, url
from django.urls import include, path, re_path

from analytics_dashboard.courses import views
from analytics_dashboard.courses.views import (
Expand Down Expand Up @@ -34,100 +34,100 @@
SECTION_ID_PATTERN, SUBSECTION_ID_PATTERN, VIDEO_ID_PATTERN)

ENROLLMENT_URLS = ([
url(r'^activity/$', enrollment.EnrollmentActivityView.as_view(), name='activity'),
url(r'^geography/$', enrollment.EnrollmentGeographyView.as_view(), name='geography'),
url(r'^demographics/age/$', enrollment.EnrollmentDemographicsAgeView.as_view(), name='demographics_age'),
url(r'^demographics/education/$', enrollment.EnrollmentDemographicsEducationView.as_view(),
path('activity/', enrollment.EnrollmentActivityView.as_view(), name='activity'),
path('geography/', enrollment.EnrollmentGeographyView.as_view(), name='geography'),
path('demographics/age/', enrollment.EnrollmentDemographicsAgeView.as_view(), name='demographics_age'),
path('demographics/education/', enrollment.EnrollmentDemographicsEducationView.as_view(),
name='demographics_education'),
url(r'^demographics/gender/$', enrollment.EnrollmentDemographicsGenderView.as_view(), name='demographics_gender'),
path('demographics/gender/', enrollment.EnrollmentDemographicsGenderView.as_view(), name='demographics_gender'),
], 'enrollment')

ENGAGEMENT_URLS = ([
url(r'^content/$', engagement.EngagementContentView.as_view(), name='content'),
url(r'^videos/$', engagement.EngagementVideoCourse.as_view(), name='videos'),
path('content/', engagement.EngagementContentView.as_view(), name='content'),
path('videos/', engagement.EngagementVideoCourse.as_view(), name='videos'),
# ordering of the URLS is important for routing the the section, subsection, etc. correctly
url(video_timeline_regex, engagement.EngagementVideoTimeline.as_view(), name='video_timeline'),
url(fr'^videos/sections/{SECTION_ID_PATTERN}/subsections/{SUBSECTION_ID_PATTERN}/$',
re_path(video_timeline_regex, engagement.EngagementVideoTimeline.as_view(), name='video_timeline'),
re_path(fr'^videos/sections/{SECTION_ID_PATTERN}/subsections/{SUBSECTION_ID_PATTERN}/$',
engagement.EngagementVideoSubsection.as_view(),
name='video_subsection'),
url(fr'^videos/sections/{SECTION_ID_PATTERN}/$',
re_path(fr'^videos/sections/{SECTION_ID_PATTERN}/$',
engagement.EngagementVideoSection.as_view(),
name='video_section'),
], 'engagement')

PERFORMANCE_URLS = ([
url(r'^ungraded_content/$', performance.PerformanceUngradedContent.as_view(), name='ungraded_content'),
url(ungraded_answer_distribution_regex, performance.PerformanceUngradedAnswerDistribution.as_view(),
path('ungraded_content/', performance.PerformanceUngradedContent.as_view(), name='ungraded_content'),
re_path(ungraded_answer_distribution_regex, performance.PerformanceUngradedAnswerDistribution.as_view(),
name='ungraded_answer_distribution'),
url(fr'^ungraded_content/sections/{SECTION_ID_PATTERN}/subsections/{SUBSECTION_ID_PATTERN}/$',
re_path(fr'^ungraded_content/sections/{SECTION_ID_PATTERN}/subsections/{SUBSECTION_ID_PATTERN}/$',
performance.PerformanceUngradedSubsection.as_view(),
name='ungraded_subsection'),
url(fr'^ungraded_content/sections/{SECTION_ID_PATTERN}/$',
re_path(fr'^ungraded_content/sections/{SECTION_ID_PATTERN}/$',
performance.PerformanceUngradedSection.as_view(),
name='ungraded_section'),
url(r'^graded_content/$', performance.PerformanceGradedContent.as_view(), name='graded_content'),
url(r'^graded_content/(?P<assignment_type>[\w-]+)/$',
path('graded_content/', performance.PerformanceGradedContent.as_view(), name='graded_content'),
re_path(r'^graded_content/(?P<assignment_type>[\w-]+)/$',
performance.PerformanceGradedContentByType.as_view(),
name='graded_content_by_type'),
url(answer_distribution_regex, performance.PerformanceAnswerDistributionView.as_view(), name='answer_distribution'),
re_path(answer_distribution_regex, performance.PerformanceAnswerDistributionView.as_view(), name='answer_distribution'),

# This MUST come AFTER the answer distribution pattern; otherwise, the answer distribution pattern
# will be interpreted as an assignment pattern.
url(fr'^graded_content/assignments/{ASSIGNMENT_ID_PATTERN}/$',
re_path(fr'^graded_content/assignments/{ASSIGNMENT_ID_PATTERN}/$',
performance.PerformanceAssignment.as_view(),
name='assignment'),
url(r'^learning_outcomes/$',
path('learning_outcomes/',
performance.PerformanceLearningOutcomesContent.as_view(),
name='learning_outcomes'),
url(fr'^learning_outcomes/{TAG_VALUE_ID_PATTERN}/$',
re_path(fr'^learning_outcomes/{TAG_VALUE_ID_PATTERN}/$',
performance.PerformanceLearningOutcomesSection.as_view(),
name='learning_outcomes_section'),
url(fr'^learning_outcomes/{TAG_VALUE_ID_PATTERN}/problems/{PROBLEM_ID_PATTERN}/$',
re_path(fr'^learning_outcomes/{TAG_VALUE_ID_PATTERN}/problems/{PROBLEM_ID_PATTERN}/$',
performance.PerformanceLearningOutcomesAnswersDistribution.as_view(),
name='learning_outcomes_answers_distribution'),
url(r'^learning_outcomes/{}/problems/{}/{}/$'.format(TAG_VALUE_ID_PATTERN, PROBLEM_ID_PATTERN,
re_path(r'^learning_outcomes/{}/problems/{}/{}/$'.format(TAG_VALUE_ID_PATTERN, PROBLEM_ID_PATTERN,
PROBLEM_PART_ID_PATTERN),
performance.PerformanceLearningOutcomesAnswersDistribution.as_view(),
name='learning_outcomes_answers_distribution_with_part'),
], 'performance')

CSV_URLS = ([
url(r'^enrollment/$', csv.CourseEnrollmentCSV.as_view(), name='enrollment'),
url(r'^enrollment/geography/$', csv.CourseEnrollmentByCountryCSV.as_view(), name='enrollment_geography'),
url(r'^enrollment/demographics/age/$',
path('enrollment/', csv.CourseEnrollmentCSV.as_view(), name='enrollment'),
path('enrollment/geography/', csv.CourseEnrollmentByCountryCSV.as_view(), name='enrollment_geography'),
path('enrollment/demographics/age/',
csv.CourseEnrollmentDemographicsAgeCSV.as_view(),
name='enrollment_demographics_age'),
url(r'^enrollment/demographics/education/$',
path('enrollment/demographics/education/',
csv.CourseEnrollmentDemographicsEducationCSV.as_view(),
name='enrollment_demographics_education'),
url(r'^enrollment/demographics/gender/$',
path('enrollment/demographics/gender/',
csv.CourseEnrollmentDemographicsGenderCSV.as_view(),
name='enrollment_demographics_gender'),
url(r'^engagement/activity_trend/$',
path('engagement/activity_trend/',
csv.CourseEngagementActivityTrendCSV.as_view(),
name='engagement_activity_trend'),
url(fr'^engagement/videos/{PIPELINE_VIDEO_ID}/$',
re_path(fr'^engagement/videos/{PIPELINE_VIDEO_ID}/$',
csv.CourseEngagementVideoTimelineCSV.as_view(),
name='engagement_video_timeline'),
url(r'^performance/graded_content/problems/{}/answer_distribution/{}/$'.format(CONTENT_ID_PATTERN,
re_path(r'^performance/graded_content/problems/{}/answer_distribution/{}/$'.format(CONTENT_ID_PATTERN,
PROBLEM_PART_ID_PATTERN),
csv.PerformanceAnswerDistributionCSV.as_view(),
name='performance_answer_distribution'),
url(r'problem_responses/', csv.PerformanceProblemResponseCSV.as_view(), name='performance_problem_responses')
re_path(r'problem_responses/', csv.PerformanceProblemResponseCSV.as_view(), name='performance_problem_responses')
], 'csv')

COURSE_URLS = [
# Course homepage. This should be the entry point for other applications linking to the course.
url(r'^$', views.CourseHome.as_view(), name='home'),
url(r'^enrollment/', include(ENROLLMENT_URLS)),
url(r'^engagement/', include(ENGAGEMENT_URLS)),
url(r'^performance/', include(PERFORMANCE_URLS)),
url(r'^csv/', include(CSV_URLS)),
path('', views.CourseHome.as_view(), name='home'),
path('enrollment/', include(ENROLLMENT_URLS)),
path('engagement/', include(ENGAGEMENT_URLS)),
path('performance/', include(PERFORMANCE_URLS)),
path('csv/', include(CSV_URLS)),
]

app_name = 'courses'
urlpatterns = [
url('^$', course_summaries.CourseIndex.as_view(), name='index'),
url(fr'^{settings.COURSE_ID_PATTERN}/', include(COURSE_URLS)),
url(r'csv/course_list/$', course_summaries.CourseIndexCSV.as_view(), name='index_csv')
path('', course_summaries.CourseIndex.as_view(), name='index'),
re_path(fr'^{settings.COURSE_ID_PATTERN}/', include(COURSE_URLS)),
path('csv/course_list/', course_summaries.CourseIndexCSV.as_view(), name='index_csv')
]
Loading

0 comments on commit 4a946c9

Please sign in to comment.