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

Commit

Permalink
fix: Added support for django42
Browse files Browse the repository at this point in the history
  • Loading branch information
zubairshakoorarbisoft authored and Muhammad Soban Javed committed Sep 27, 2023
1 parent c129b11 commit 0c8b3d8
Show file tree
Hide file tree
Showing 15 changed files with 70 additions and 75 deletions.
6 changes: 3 additions & 3 deletions analytics_data_api/urls.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from django.conf.urls import include, url
from django.urls import include, re_path
from rest_framework.urlpatterns import format_suffix_patterns

app_name = 'analytics_data_api'

urlpatterns = [
url(r'^v0/', include('analytics_data_api.v0.urls')),
url(r'^v1/', include('analytics_data_api.v1.urls')),
re_path(r'^v0/', include('analytics_data_api.v0.urls')),
re_path(r'^v1/', include('analytics_data_api.v1.urls')),
]

urlpatterns = format_suffix_patterns(urlpatterns)
1 change: 0 additions & 1 deletion analytics_data_api/v0/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = 'analytics_data_api.v0.apps.ApiAppConfig'
2 changes: 1 addition & 1 deletion analytics_data_api/v0/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class Meta(BaseCourseModel.Meta):

module_id = models.CharField(db_index=True, max_length=255)
part_id = models.CharField(db_index=True, max_length=255)
correct = models.NullBooleanField()
correct = models.BooleanField(default=None, null=True)
value_id = models.CharField(db_index=True, max_length=255, null=True)
answer_value = models.TextField(null=True, db_column='answer_value_text')
variant = models.IntegerField(null=True)
Expand Down
21 changes: 10 additions & 11 deletions analytics_data_api/v0/urls/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
from django.conf.urls import include, url
from django.urls import reverse_lazy
from django.urls import include, path, reverse_lazy
from django.views.generic import RedirectView

app_name = 'analytics_data_api.v0'

COURSE_ID_PATTERN = r'(?P<course_id>[^/+]+[/+][^/+]+[/+][^/]+)'

urlpatterns = [
url(r'^courses/', include('analytics_data_api.v0.urls.courses')),
url(r'^problems/', include('analytics_data_api.v0.urls.problems')),
url(r'^videos/', include('analytics_data_api.v0.urls.videos')),
url('^', include('analytics_data_api.v0.urls.learners')),
url('^', include('analytics_data_api.v0.urls.course_summaries')),
url('^', include('analytics_data_api.v0.urls.programs')),
path('courses/', include('analytics_data_api.v0.urls.courses')),
path('problems/', include('analytics_data_api.v0.urls.problems')),
path('videos/', include('analytics_data_api.v0.urls.videos')),
path('', include('analytics_data_api.v0.urls.learners')),
path('', include('analytics_data_api.v0.urls.course_summaries')),
path('', include('analytics_data_api.v0.urls.programs')),

# pylint: disable=no-value-for-parameter
url(r'^authenticated/$', RedirectView.as_view(url=reverse_lazy('authenticated')), name='authenticated'),
url(r'^health/$', RedirectView.as_view(url=reverse_lazy('health')), name='health'),
url(r'^status/$', RedirectView.as_view(url=reverse_lazy('status')), name='status'),
path('authenticated/', RedirectView.as_view(url=reverse_lazy('authenticated')), name='authenticated'),
path('health/', RedirectView.as_view(url=reverse_lazy('health')), name='health'),
path('status/', RedirectView.as_view(url=reverse_lazy('status')), name='status'),
]
4 changes: 2 additions & 2 deletions analytics_data_api/v0/urls/course_summaries.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from django.conf.urls import url
from django.urls import re_path

from analytics_data_api.v0.views import course_summaries as views

app_name = 'course_summaries'

urlpatterns = [
url(r'^course_summaries/$', views.CourseSummariesView.as_view(), name='course_summaries'),
re_path(r'^course_summaries/$', views.CourseSummariesView.as_view(), name='course_summaries'),
]
4 changes: 2 additions & 2 deletions analytics_data_api/v0/urls/courses.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.conf.urls import url
from django.urls import re_path

from analytics_data_api.v0.urls import COURSE_ID_PATTERN
from analytics_data_api.v0.views import courses as views
Expand All @@ -25,4 +25,4 @@

for path, view, name in COURSE_URLS:
regex = fr'^{COURSE_ID_PATTERN}/{path}/$'
urlpatterns.append(url(regex, view.as_view(), name=name))
urlpatterns.append(re_path(regex, view.as_view(), name=name))
6 changes: 3 additions & 3 deletions analytics_data_api/v0/urls/learners.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.conf.urls import url
from django.urls import re_path

from analytics_data_api.constants.learner import UUID_REGEX_PATTERN
from analytics_data_api.v0.views import learners as views
Expand All @@ -8,6 +8,6 @@
USERNAME_PATTERN = r'(?P<username>[\w.+-]+)'

urlpatterns = [
url(fr'^enterprise/(?P<enterprise_customer>{UUID_REGEX_PATTERN})/engagements/$',
views.EnterpriseLearnerEngagementView.as_view(), name='engagements'),
re_path(fr'^enterprise/(?P<enterprise_customer>{UUID_REGEX_PATTERN})/engagements/$',
views.EnterpriseLearnerEngagementView.as_view(), name='engagements'),
]
9 changes: 5 additions & 4 deletions analytics_data_api/v0/urls/problems.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re

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

from analytics_data_api.v0.views import problems as views

Expand All @@ -12,9 +12,10 @@
]

urlpatterns = [
url(r'^(?P<module_id>.+)/sequential_open_distribution/$',
views.SequentialOpenDistributionView.as_view(), name='sequential_open_distribution'),
re_path(r'^(?P<module_id>.+)/sequential_open_distribution/$',
views.SequentialOpenDistributionView.as_view(),
name='sequential_open_distribution'),
]

for path, view, name in PROBLEM_URLS:
urlpatterns.append(url(r'^(?P<problem_id>.+)/' + re.escape(path) + r'/$', view.as_view(), name=name))
urlpatterns.append(re_path(r'^(?P<problem_id>.+)/' + re.escape(path) + r'/$', view.as_view(), name=name))
4 changes: 2 additions & 2 deletions analytics_data_api/v0/urls/programs.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from django.conf.urls import url
from django.urls import path

from analytics_data_api.v0.views import programs as views

app_name = 'programs'

urlpatterns = [
url(r'^programs/$', views.ProgramsView.as_view(), name='programs'),
path('programs/', views.ProgramsView.as_view(), name='programs'),
]
4 changes: 2 additions & 2 deletions analytics_data_api/v0/urls/videos.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re

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

from analytics_data_api.v0.views import videos as views

Expand All @@ -13,4 +13,4 @@
urlpatterns = []

for path, view, name in VIDEO_URLS:
urlpatterns.append(url(r'^(?P<video_id>.+)/' + re.escape(path) + r'/$', view.as_view(), name=name))
urlpatterns.append(re_path(r'^(?P<video_id>.+)/' + re.escape(path) + r'/$', view.as_view(), name=name))
4 changes: 2 additions & 2 deletions analytics_data_api/v0/views/courses.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.db import connections, router
from django.db.models import Max
from django.http import Http404
from django.utils.timezone import make_aware, utc
from django.utils.timezone import make_aware
from opaque_keys.edx.keys import CourseKey
from rest_framework import generics
from rest_framework.response import Response
Expand All @@ -32,7 +32,7 @@ def get(self, request, *args, **kwargs):
self.course_id = self.kwargs.get('course_id')
start_date = request.query_params.get('start_date')
end_date = request.query_params.get('end_date')
timezone = utc
timezone = datetime.timezone.utc

self.start_date = self.parse_date(start_date, timezone)
self.end_date = self.parse_date(end_date, timezone)
Expand Down
19 changes: 9 additions & 10 deletions analytics_data_api/v1/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.conf.urls import include, url
from django.urls import reverse_lazy
from django.urls import include, re_path, reverse_lazy
from django.views.generic import RedirectView

from analytics_data_api.v0.urls import COURSE_ID_PATTERN
Expand All @@ -26,16 +25,16 @@

for path, view, name in COURSE_URLS:
regex = fr'^courses/{COURSE_ID_PATTERN}/{path}/$'
course_urlpatterns.append(url(regex, view.as_view(), name=name))
course_urlpatterns.append(re_path(regex, view.as_view(), name=name))

urlpatterns = course_urlpatterns + [
url(r'^problems/', include('analytics_data_api.v0.urls.problems')),
url(r'^videos/', include('analytics_data_api.v0.urls.videos')),
url('^', include('analytics_data_api.v0.urls.course_summaries')),
url('^', include('analytics_data_api.v0.urls.programs')),
re_path(r'^problems/', include('analytics_data_api.v0.urls.problems')),
re_path(r'^videos/', include('analytics_data_api.v0.urls.videos')),
re_path('^', include('analytics_data_api.v0.urls.course_summaries')),
re_path('^', include('analytics_data_api.v0.urls.programs')),

# pylint: disable=no-value-for-parameter
url(r'^authenticated/$', RedirectView.as_view(url=reverse_lazy('authenticated')), name='authenticated'),
url(r'^health/$', RedirectView.as_view(url=reverse_lazy('health')), name='health'),
url(r'^status/$', RedirectView.as_view(url=reverse_lazy('status')), name='status'),
re_path(r'^authenticated/$', RedirectView.as_view(url=reverse_lazy('authenticated')), name='authenticated'),
re_path(r'^health/$', RedirectView.as_view(url=reverse_lazy('health')), name='health'),
re_path(r'^status/$', RedirectView.as_view(url=reverse_lazy('status')), name='status'),
]
20 changes: 10 additions & 10 deletions analyticsdataserver/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.conf.urls import include, url
from django.contrib import admin
from django.urls import include, re_path
from django.views.generic import RedirectView
from edx_api_doc_tools import make_api_info, make_docs_ui_view
from rest_framework.authtoken.views import obtain_auth_token
Expand All @@ -10,16 +10,16 @@
admin.site.site_title = admin.site.site_header

urlpatterns = [
url(r'^api-auth/', include('rest_framework.urls', 'rest_framework')),
url(r'^api-token-auth/', obtain_auth_token),
re_path(r'^api-auth/', include('rest_framework.urls', 'rest_framework')),
re_path(r'^api-token-auth/', obtain_auth_token),

url(r'^api/', include('analytics_data_api.urls')),
url(r'^status/$', views.StatusView.as_view(), name='status'),
url(r'^authenticated/$', views.AuthenticationTestView.as_view(), name='authenticated'),
url(r'^health/$', views.HealthView.as_view(), name='health'),
re_path(r'^api/', include('analytics_data_api.urls')),
re_path(r'^status/$', views.StatusView.as_view(), name='status'),
re_path(r'^authenticated/$', views.AuthenticationTestView.as_view(), name='authenticated'),
re_path(r'^health/$', views.HealthView.as_view(), name='health'),
]

urlpatterns.append(url(r'', include('enterprise_data.urls')))
urlpatterns.append(re_path(r'', include('enterprise_data.urls')))

api_ui_view = make_docs_ui_view(
api_info=make_api_info(
Expand All @@ -31,8 +31,8 @@
)

urlpatterns += [
url(r'^docs/$', api_ui_view, name='api-docs'),
url(r'^$', RedirectView.as_view(url='/docs')), # pylint: disable=no-value-for-parameter
re_path(r'^docs/$', api_ui_view, name='api-docs'),
re_path(r'^$', RedirectView.as_view(url='/docs')), # pylint: disable=no-value-for-parameter
]

handler500 = 'analyticsdataserver.views.handle_internal_server_error' # pylint: disable=invalid-name
Expand Down
3 changes: 1 addition & 2 deletions docs/api/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import os
import sys
import django

import django
from path import Path


# Add any paths that contain templates here, relative to this directory.
# templates_path.append('source/_templates')

Expand Down
38 changes: 18 additions & 20 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
[tox]
skipsdist = True
envlist = py38-django{32}
envlist = py38-django{32, 42}

[testenv]
passenv =
ELASTICSEARCH_LEARNERS_HOST
COVERAGE_DIR
setenv =
tests: DJANGO_SETTINGS_MODULE = analyticsdataserver.settings.test
NODE_BIN = ./node_modules/.bin
PATH = $PATH:$NODE_BIN
deps =
django32: Django>=3.2,<3.3
-r requirements/test.txt
commands =
{posargs:pytest}
passenv =
ELASTICSEARCH_LEARNERS_HOST
COVERAGE_DIR
setenv =
tests: DJANGO_SETTINGS_MODULE = analyticsdataserver.settings.test
NODE_BIN = ./node_modules/.bin
PATH = $PATH:$NODE_BIN
deps =
django32: Django>=3.2,<3.3
django42: Django>=4.2,<4.3
-r requirements/test.txt
commands =
{posargs:pytest}

[testenv:docs]
deps =
deps =
-r{toxinidir}/requirements/doc.txt
allowlist_externals =
allowlist_externals =
make
env
setenv =
# -W will treat warnings as errors.
setenv =
SPHINXOPTS = -W
commands =
# -e allows for overriding setting from the environment.
# -C changes the directory to `docs` before running the command.
commands =
make -e -C docs/api clean
make -e -C docs/api html

0 comments on commit 0c8b3d8

Please sign in to comment.