Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Added support for Django42 #346

Merged
merged 2 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ jobs:
max-parallel: 4
matrix:
python-version: ['py38']
django-version: ['django32']
django-version: ['django32', 'django42']
db-version: ['mysql57', 'mysql80']
# excluding mysql5.7 with Django 4.2 since Django 4.2 has
# dropped support for MySQL<8
exclude:
- django-version: 'django42'
db-version: 'mysql57'

steps:
- uses: actions/checkout@v2
Expand Down
1 change: 0 additions & 1 deletion .travis/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ export DJANGO_SETTINGS_MODULE=notesserver.settings.test
cd /edx/app/edx_notes_api/edx_notes_api

make validate

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ static: # provide the static target for devstack's tooling.
requirements:
pip install -q -r requirements/base.txt --exists-action=w

test.requirements: requirements
test.requirements:
pip install -q -r requirements/test.txt --exists-action=w

develop: test.requirements
develop: requirements test.requirements

piptools: ## install pinned version of pip-compile and pip-sync
pip install -r requirements/pip-tools.txt
Expand Down
4 changes: 2 additions & 2 deletions notesapi/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.conf.urls import include, url
from django.urls import include, path

app_name = "notesapi.v1"

urlpatterns = [
url(r'^v1/', include('notesapi.v1.urls', namespace='v1')),
path('v1/', include('notesapi.v1.urls', namespace='v1')),
]
2 changes: 1 addition & 1 deletion notesapi/v1/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class HasAccessToken(BasePermission):
def has_permission(self, request, view):
if getattr(settings, 'DISABLE_TOKEN_CHECK', False):
return True
token = request.META.get('HTTP_X_ANNOTATOR_AUTH_TOKEN', '')
token = request.headers.get('x-annotator-auth-token', '')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if not token:
logger.debug("No token found in headers")
return False
Expand Down
10 changes: 5 additions & 5 deletions notesapi/v1/urls.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from django.conf.urls import url
from django.urls import path, re_path

from notesapi.v1.views import (AnnotationDetailView, AnnotationListView,
AnnotationRetireView, AnnotationSearchView)
app_name = "notesapi.v1"
urlpatterns = [
url(r'^annotations/$', AnnotationListView.as_view(), name='annotations'),
url(r'^retire_annotations/$', AnnotationRetireView.as_view(), name='annotations_retire'),
url(
path('annotations/', AnnotationListView.as_view(), name='annotations'),
path('retire_annotations/', AnnotationRetireView.as_view(), name='annotations_retire'),
re_path(
r'^annotations/(?P<annotation_id>[a-zA-Z0-9_-]+)/?$',
AnnotationDetailView.as_view(),
name='annotations_detail'
),
url(r'^search/$', AnnotationSearchView.as_view(), name='annotations_search'),
path('search/', AnnotationSearchView.as_view(), name='annotations_search'),
]
2 changes: 1 addition & 1 deletion notesapi/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.core.exceptions import ValidationError
from django.db.models import Q
from django.urls import reverse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from rest_framework import status
from rest_framework.generics import GenericAPIView, ListAPIView
from rest_framework.response import Response
Expand Down
7 changes: 7 additions & 0 deletions notesserver/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,10 @@
'JWT_AUTH_REFRESH_COOKIE': 'edx-jwt-refresh-cookie',
'JWT_ALGORITHM': 'HS256',
}

CSRF_TRUSTED_ORIGINS = []

# Django 4.0+ uses zoneinfo if this is not set. We can remove this and
# migrate to zoneinfo after Django 4.2 upgrade. See more on following url
# https://docs.djangoproject.com/en/4.2/releases/4.0/#zoneinfo-default-timezone-implementation
USE_DEPRECATED_PYTZ = True
14 changes: 7 additions & 7 deletions notesserver/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.conf.urls import include, url
from django.urls import include, path, re_path
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
from rest_framework import permissions
Expand All @@ -16,10 +16,10 @@
)

urlpatterns = [
url(r'^heartbeat/$', notesserver.views.heartbeat, name='heartbeat'),
url(r'^selftest/$', notesserver.views.selftest, name='selftest'),
url(r'^robots.txt$', notesserver.views.robots, name='robots'),
url(r'^$', notesserver.views.root, name='root'),
url(r'^api/', include('notesapi.urls', namespace='api')),
url(r'^swagger/$', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
path('heartbeat/', notesserver.views.heartbeat, name='heartbeat'),
path('selftest/', notesserver.views.selftest, name='selftest'),
re_path(r'^robots.txt$', notesserver.views.robots, name='robots'),
path('', notesserver.views.root, name='root'),
path('api/', include('notesapi.urls', namespace='api')),
path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
]
13 changes: 7 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[tox]
envlist = py38-django{32}
envlist = py38-django{32, 42}
skipsdist = true

[testenv]
deps =
django32: -r requirements/django.txt
deps =
django32: Django>=3.2,<4.0
django42: Django>=4.2,<4.3
-r {toxinidir}/requirements/test.txt
passenv =
passenv =
CONN_MAX_AGE
DB_ENGINE
DB_HOST
Expand All @@ -16,7 +17,7 @@ passenv =
DB_USER
ENABLE_DJANGO_TOOLBAR
ELASTICSEARCH_URL
whitelist_externals =
whitelist_externals =
make
commands =
commands =
make validate
Loading