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

Commit 291eb9e

Browse files
authored
Merge pull request #456 from edx/schen/upgrade_django32
[Feat]: Upgrade django from 2.2 to 3.2
2 parents a9f15be + 9daea67 commit 291eb9e

17 files changed

Lines changed: 1331 additions & 428 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ matrix:
2020
- python: '3.8'
2121
env: TESTNAME=test-python-3.8 TARGETS="PYTHON_ENV=py38 main.test"
2222
- python: '3.8'
23-
env: TESTNAME=test-python-3.8-django-3.0 TARGETS="PYTHON_ENV=py38 DJANGO_VERSION=django30 main.test"
23+
env: TESTNAME=test-python-3.8-django-3.0 TARGETS="PYTHON_ENV=py38 DJANGO_VERSION=django32 main.test"
2424
after_success:
2525
- docker exec analytics_api_testing /edx/app/analytics_api/analytics_api/.travis/run_coverage.sh
2626
- codecov --disable pycov

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ COVERAGE_DIR = $(ROOT)/build/coverage
33
PACKAGES = analyticsdataserver analytics_data_api
44
DATABASES = default analytics
55
PYTHON_ENV=py38
6-
DJANGO_VERSION=django22
6+
DJANGO_VERSION=django32
77
.DEFAULT_GOAL := help
88

99
help: ## display this help message

analyticsdataserver/settings/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,9 @@
244244
'rest_framework',
245245
'rest_framework.authtoken',
246246
'rest_framework_jwt',
247-
'rest_framework_swagger',
248247
'django_countries',
248+
'drf_yasg',
249+
'edx_api_doc_tools',
249250
'storages',
250251
'enterprise_data',
251252
'rules.apps.AutodiscoverRulesConfig',

analyticsdataserver/urls.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
from django.conf.urls import include, url
22
from django.contrib import admin
33
from django.views.generic import RedirectView
4+
from edx_api_doc_tools import make_api_info, make_docs_ui_view
45
from rest_framework.authtoken.views import obtain_auth_token
56

67
from analyticsdataserver import views
78

89
admin.site.site_header = 'Analytics Data API Service Administration'
910
admin.site.site_title = admin.site.site_header
1011

12+
api_ui_view = make_docs_ui_view(
13+
make_api_info(
14+
title="edX Analytics Data API",
15+
version="v1",
16+
email="program-cosmonauts@edx.org"
17+
)
18+
)
19+
1120
urlpatterns = [
1221
url(r'^$', RedirectView.as_view(url='/docs')), # pylint: disable=no-value-for-parameter
1322

1423
url(r'^api-auth/', include('rest_framework.urls', 'rest_framework')),
1524
url(r'^api-token-auth/', obtain_auth_token),
1625

1726
url(r'^api/', include('analytics_data_api.urls')),
18-
url(r'^docs/', views.SwaggerSchemaView.as_view()),
19-
27+
url(r'^docs/$', api_ui_view, name='api-docs'),
2028
url(r'^status/$', views.StatusView.as_view(), name='status'),
2129
url(r'^authenticated/$', views.AuthenticationTestView.as_view(), name='authenticated'),
2230
url(r'^health/$', views.HealthView.as_view(), name='health'),

analyticsdataserver/views.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
from django.conf import settings
44
from django.db import connections
55
from django.http import HttpResponse
6-
from rest_framework import permissions, schemas
7-
from rest_framework.permissions import AllowAny
6+
from rest_framework import permissions
87
from rest_framework.renderers import JSONRenderer
98
from rest_framework.response import Response
109
from rest_framework.views import APIView
11-
from rest_framework_swagger.renderers import OpenAPIRenderer, SwaggerUIRenderer
1210

1311
logger = logging.getLogger(__name__)
1412

@@ -33,21 +31,6 @@ def _handle_error(status_code):
3331
return HttpResponse(renderer.render(info), content_type=content_type, status=status_code)
3432

3533

36-
class SwaggerSchemaView(APIView):
37-
"""
38-
Renders the swagger schema for the documentation regardless of permissions.
39-
"""
40-
permission_classes = [AllowAny]
41-
renderer_classes = [
42-
OpenAPIRenderer,
43-
SwaggerUIRenderer
44-
]
45-
46-
def get(self, _request):
47-
generator = schemas.SchemaGenerator(title='Analytics API')
48-
return Response(generator.get_schema())
49-
50-
5134
class StatusView(APIView):
5235
"""
5336
Simple check to determine if the server is alive

requirements/base.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22

33
-c constraints.txt
44

5+
edx-api-doc-tools
56
boto==2.42.0 # MIT
67
boto3
8+
coreapi
79
Django # BSD License
810
django-countries # MIT
911
python-memcached # Python Software Foundation License v2
1012
djangorestframework # BSD
11-
django-rest-swagger # BSD
1213
djangorestframework-csv # BSD
1314
django-storages # BSD
1415
elasticsearch-dsl # Apache 2.0
1516
ordered-set # MIT
1617
tqdm # MIT
1718
urllib3 # MIT
18-
Markdown==2.6.6 # BSD:markdown is used by swagger for rendering the api docs
19+
Markdown # BSD:markdown is used by swagger for rendering the api docs
1920
edx-ccx-keys
2021
edx-django-release-util
2122
edx-opaque-keys

0 commit comments

Comments
 (0)