Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-analytics-data-api
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-analytics-data-api
Commits
662acec2
Commit
662acec2
authored
May 16, 2017
by
Dennis Jen
Committed by
GitHub
May 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upgrading to django 1.11 (#168)
* upgraded django and other packages
parent
7a3e0972
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
70 additions
and
98 deletions
+70
-98
analytics_data_api/v0/tests/views/test_courses.py
+8
-6
analytics_data_api/v0/tests/views/test_videos.py
+5
-5
analyticsdataserver/urls.py
+1
-1
analyticsdataserver/views.py
+18
-1
requirements/base.txt
+8
-8
requirements/test.txt
+5
-5
templates/rest_framework_swagger/index.html
+25
-72
No files found.
analytics_data_api/v0/tests/views/test_courses.py
View file @
662acec2
...
@@ -9,6 +9,7 @@ import urllib
...
@@ -9,6 +9,7 @@ import urllib
import
ddt
import
ddt
from
django.conf
import
settings
from
django.conf
import
settings
from
django.utils
import
timezone
from
django_dynamic_fixture
import
G
from
django_dynamic_fixture
import
G
import
pytz
import
pytz
from
opaque_keys.edx.keys
import
CourseKey
from
opaque_keys.edx.keys
import
CourseKey
...
@@ -592,10 +593,12 @@ class CourseProblemsListViewTests(TestCaseWithAuthentication):
...
@@ -592,10 +593,12 @@ class CourseProblemsListViewTests(TestCaseWithAuthentication):
# natural order and ensure the view properly sorts the objects before grouping.
# natural order and ensure the view properly sorts the objects before grouping.
module_id
=
u'i4x://test/problem/1'
module_id
=
u'i4x://test/problem/1'
alt_module_id
=
u'i4x://test/problem/2'
alt_module_id
=
u'i4x://test/problem/2'
created
=
datetime
.
datetime
.
utc
now
()
created
=
timezone
.
now
()
alt_created
=
created
+
datetime
.
timedelta
(
seconds
=
2
)
alt_created
=
created
+
datetime
.
timedelta
(
seconds
=
2
)
date_time_format
=
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
date_time_format
=
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
# using string representations of dates will cause "DateTimeField time zone support" RuntimeWarning
# however, using the date with timezone causes conversion errors
o1
=
G
(
models
.
ProblemFirstLastResponseAnswerDistribution
,
course_id
=
course_id
,
module_id
=
module_id
,
o1
=
G
(
models
.
ProblemFirstLastResponseAnswerDistribution
,
course_id
=
course_id
,
module_id
=
module_id
,
correct
=
True
,
last_response_count
=
100
,
created
=
created
.
strftime
(
date_time_format
))
correct
=
True
,
last_response_count
=
100
,
created
=
created
.
strftime
(
date_time_format
))
o2
=
G
(
models
.
ProblemFirstLastResponseAnswerDistribution
,
course_id
=
course_id
,
module_id
=
alt_module_id
,
o2
=
G
(
models
.
ProblemFirstLastResponseAnswerDistribution
,
course_id
=
course_id
,
module_id
=
alt_module_id
,
...
@@ -661,7 +664,7 @@ class CourseProblemsAndTagsListViewTests(TestCaseWithAuthentication):
...
@@ -661,7 +664,7 @@ class CourseProblemsAndTagsListViewTests(TestCaseWithAuthentication):
'learning_outcome'
:
[
'Learned nothing'
,
'Learned a few things'
,
'Learned everything'
]
'learning_outcome'
:
[
'Learned nothing'
,
'Learned a few things'
,
'Learned everything'
]
}
}
created
=
datetime
.
datetime
.
utc
now
()
created
=
timezone
.
now
()
alt_created
=
created
+
datetime
.
timedelta
(
seconds
=
2
)
alt_created
=
created
+
datetime
.
timedelta
(
seconds
=
2
)
G
(
models
.
ProblemsAndTags
,
course_id
=
course_id
,
module_id
=
module_id
,
G
(
models
.
ProblemsAndTags
,
course_id
=
course_id
,
module_id
=
module_id
,
...
@@ -728,18 +731,17 @@ class CourseVideosListViewTests(TestCaseWithAuthentication):
...
@@ -728,18 +731,17 @@ class CourseVideosListViewTests(TestCaseWithAuthentication):
module_id
=
'i4x-test-video-1'
module_id
=
'i4x-test-video-1'
video_id
=
'v1d30'
video_id
=
'v1d30'
created
=
datetime
.
datetime
.
utcnow
()
created
=
timezone
.
now
()
date_time_format
=
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
G
(
models
.
Video
,
course_id
=
course_id
,
encoded_module_id
=
module_id
,
G
(
models
.
Video
,
course_id
=
course_id
,
encoded_module_id
=
module_id
,
pipeline_video_id
=
video_id
,
duration
=
100
,
segment_length
=
1
,
users_at_start
=
50
,
users_at_end
=
10
,
pipeline_video_id
=
video_id
,
duration
=
100
,
segment_length
=
1
,
users_at_start
=
50
,
users_at_end
=
10
,
created
=
created
.
strftime
(
date_time_format
)
)
created
=
created
)
alt_module_id
=
'i4x-test-video-2'
alt_module_id
=
'i4x-test-video-2'
alt_video_id
=
'a1d30'
alt_video_id
=
'a1d30'
alt_created
=
created
+
datetime
.
timedelta
(
seconds
=
10
)
alt_created
=
created
+
datetime
.
timedelta
(
seconds
=
10
)
G
(
models
.
Video
,
course_id
=
course_id
,
encoded_module_id
=
alt_module_id
,
G
(
models
.
Video
,
course_id
=
course_id
,
encoded_module_id
=
alt_module_id
,
pipeline_video_id
=
alt_video_id
,
duration
=
200
,
segment_length
=
5
,
users_at_start
=
1050
,
users_at_end
=
50
,
pipeline_video_id
=
alt_video_id
,
duration
=
200
,
segment_length
=
5
,
users_at_start
=
1050
,
users_at_end
=
50
,
created
=
alt_created
.
strftime
(
date_time_format
)
)
created
=
alt_created
)
expected
=
[
expected
=
[
{
{
...
...
analytics_data_api/v0/tests/views/test_videos.py
View file @
662acec2
import
datetime
import
datetime
from
django.conf
import
settings
from
django.conf
import
settings
from
django.utils
import
timezone
from
django_dynamic_fixture
import
G
from
django_dynamic_fixture
import
G
from
analytics_data_api.v0
import
models
from
analytics_data_api.v0
import
models
...
@@ -17,17 +18,16 @@ class VideoTimelineTests(TestCaseWithAuthentication):
...
@@ -17,17 +18,16 @@ class VideoTimelineTests(TestCaseWithAuthentication):
G
(
models
.
VideoTimeline
)
G
(
models
.
VideoTimeline
)
video_id
=
'v1d30'
video_id
=
'v1d30'
created
=
datetime
.
datetime
.
utcnow
()
created
=
timezone
.
now
()
date_time_format
=
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
G
(
models
.
VideoTimeline
,
pipeline_video_id
=
video_id
,
segment
=
0
,
num_users
=
10
,
G
(
models
.
VideoTimeline
,
pipeline_video_id
=
video_id
,
segment
=
0
,
num_users
=
10
,
num_views
=
50
,
created
=
created
.
strftime
(
date_time_format
)
)
num_views
=
50
,
created
=
created
)
G
(
models
.
VideoTimeline
,
pipeline_video_id
=
video_id
,
segment
=
1
,
num_users
=
1
,
G
(
models
.
VideoTimeline
,
pipeline_video_id
=
video_id
,
segment
=
1
,
num_users
=
1
,
num_views
=
1234
,
created
=
created
.
strftime
(
date_time_format
)
)
num_views
=
1234
,
created
=
created
)
alt_video_id
=
'altv1d30'
alt_video_id
=
'altv1d30'
alt_created
=
created
+
datetime
.
timedelta
(
seconds
=
17
)
alt_created
=
created
+
datetime
.
timedelta
(
seconds
=
17
)
G
(
models
.
VideoTimeline
,
pipeline_video_id
=
alt_video_id
,
segment
=
0
,
num_users
=
10231
,
G
(
models
.
VideoTimeline
,
pipeline_video_id
=
alt_video_id
,
segment
=
0
,
num_users
=
10231
,
num_views
=
834828
,
created
=
alt_created
.
strftime
(
date_time_format
)
)
num_views
=
834828
,
created
=
alt_created
)
expected
=
[
expected
=
[
{
{
...
...
analyticsdataserver/urls.py
View file @
662acec2
...
@@ -13,7 +13,7 @@ urlpatterns = [
...
@@ -13,7 +13,7 @@ urlpatterns = [
url
(
r'^api-token-auth/'
,
obtain_auth_token
),
url
(
r'^api-token-auth/'
,
obtain_auth_token
),
url
(
r'^api/'
,
include
(
'analytics_data_api.urls'
,
'api'
)),
url
(
r'^api/'
,
include
(
'analytics_data_api.urls'
,
'api'
)),
url
(
r'^docs/'
,
include
(
'rest_framework_swagger.urls'
)),
url
(
r'^docs/'
,
views
.
SwaggerSchemaView
.
as_view
(
)),
url
(
r'^status/$'
,
views
.
StatusView
.
as_view
(),
name
=
'status'
),
url
(
r'^status/$'
,
views
.
StatusView
.
as_view
(),
name
=
'status'
),
url
(
r'^authenticated/$'
,
views
.
AuthenticationTestView
.
as_view
(),
name
=
'authenticated'
),
url
(
r'^authenticated/$'
,
views
.
AuthenticationTestView
.
as_view
(),
name
=
'authenticated'
),
...
...
analyticsdataserver/views.py
View file @
662acec2
from
django.conf
import
settings
from
django.conf
import
settings
from
django.db
import
connections
from
django.db
import
connections
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
rest_framework
import
permissions
from
rest_framework
import
permissions
,
schemas
from
rest_framework.permissions
import
AllowAny
from
rest_framework.renderers
import
JSONRenderer
from
rest_framework.renderers
import
JSONRenderer
from
rest_framework.response
import
Response
from
rest_framework.response
import
Response
from
rest_framework.views
import
APIView
from
rest_framework.views
import
APIView
from
rest_framework_swagger.renderers
import
OpenAPIRenderer
,
SwaggerUIRenderer
def
handle_internal_server_error
(
_request
):
def
handle_internal_server_error
(
_request
):
...
@@ -27,6 +29,21 @@ def _handle_error(status_code):
...
@@ -27,6 +29,21 @@ def _handle_error(status_code):
return
HttpResponse
(
renderer
.
render
(
info
),
content_type
=
content_type
,
status
=
status_code
)
return
HttpResponse
(
renderer
.
render
(
info
),
content_type
=
content_type
,
status
=
status_code
)
class
SwaggerSchemaView
(
APIView
):
"""
Renders the swagger schema for the documentation regardless of permissions.
"""
permission_classes
=
[
AllowAny
]
renderer_classes
=
[
OpenAPIRenderer
,
SwaggerUIRenderer
]
def
get
(
self
,
_request
):
generator
=
schemas
.
SchemaGenerator
(
title
=
'Analytics API'
)
return
Response
(
generator
.
get_schema
())
class
StatusView
(
APIView
):
class
StatusView
(
APIView
):
"""
"""
Simple check to determine if the server is alive
Simple check to determine if the server is alive
...
...
requirements/base.txt
View file @
662acec2
boto==2.42.0 # MIT
boto==2.42.0 # MIT
Django==1.1
0.7
# BSD License
Django==1.1
1
# BSD License
django-countries==4.
0
# MIT
django-countries==4.
5
# MIT
djangorestframework==3.
5.3
# BSD
djangorestframework==3.
6.2
# BSD
django-rest-swagger==
0.3.8
# BSD
django-rest-swagger==
2.1.2
# BSD
djangorestframework-csv==
1.4.1
# BSD
djangorestframework-csv==
2.0.0
# BSD
django-storages==1.5.
1
# BSD
django-storages==1.5.
2
# BSD
elasticsearch-dsl==0.0.11 # Apache 2.0
elasticsearch-dsl==0.0.11 # Apache 2.0
ordered-set==2.0.
1
# MIT
ordered-set==2.0.
2
# MIT
tqdm==4.1
0.0
# MIT
tqdm==4.1
1.2
# MIT
# markdown is used by swagger for rendering the api docs
# markdown is used by swagger for rendering the api docs
Markdown==2.6.6 # BSD
Markdown==2.6.6 # BSD
...
...
requirements/test.txt
View file @
662acec2
# Test dependencies go here.
# Test dependencies go here.
-r base.txt
-r base.txt
coverage==4.
2
coverage==4.
4.1
ddt==1.1.1
ddt==1.1.1
diff-cover >= 0.9.9
diff-cover >= 0.9.9
django-dynamic-fixture==1.9.
0
django-dynamic-fixture==1.9.
5
django-nose==1.4.4
django-nose==1.4.4
mock==2.0.0
mock==2.0.0
nose-exclude==0.
4.1
nose-exclude==0.
5.0
nose-ignore-docstring==0.2
nose-ignore-docstring==0.2
nose==1.3.7
nose==1.3.7
pep257==0.7.0
pep257==0.7.0
pep8==1.7.0
pep8==1.7.0
pylint==1.6.
4
pylint==1.6.
5
pytz==201
6.6.1
pytz==201
7.2
responses==0.5.1
responses==0.5.1
templates/rest_framework_swagger/index.html
View file @
662acec2
{% extends "rest_framework_swagger/index.html" %}
{% load staticfiles %}
{% load staticfiles %}
<!DOCTYPE html>
<html>
<head>
<title>
edX Analytics API
</title>
<link
href=
'//fonts.googleapis.com/css?family=Droid+Sans:400,700'
rel=
'stylesheet'
type=
'text/css'
/>
<link
href=
'{% static "rest_framework_swagger/css/highlight.default.css" %}'
media=
'screen'
rel=
'stylesheet'
type=
'text/css'
/>
<link
href=
'{% static "rest_framework_swagger/css/rest_framework_swagger.css" %}'
media=
'screen'
rel=
'stylesheet'
type=
'text/css'
/>
<link
href=
'{% static "rest_framework_swagger/css/screen.css" %}'
media=
'screen'
rel=
'stylesheet'
type=
'text/css'
/>
<link
href=
'{% static "css/edx-swagger.css" %}'
media=
'screen'
rel=
'stylesheet'
type=
'text/css'
/>
<script
type=
"text/javascript"
src=
"{% static 'rest_framework_swagger/lib/shred.bundle.js' %}"
></script>
<script
src=
'{% static "rest_framework_swagger/lib/jquery-1.8.0.min.js" %}'
type=
'text/javascript'
></script>
<script
src=
'{% static "rest_framework_swagger/lib/jquery.slideto.min.js" %}'
type=
'text/javascript'
></script>
<script
src=
'{% static "rest_framework_swagger/lib/jquery.wiggle.min.js" %}'
type=
'text/javascript'
></script>
<script
src=
'{% static "rest_framework_swagger/lib/jquery.ba-bbq.min.js" %}'
type=
'text/javascript'
></script>
<script
src=
'{% static "rest_framework_swagger/lib/jquery.cookie.js" %}'
type=
'text/javascript'
></script>
<script
src=
'{% static "rest_framework_swagger/lib/handlebars-1.0.0.js" %}'
type=
'text/javascript'
></script>
<script
src=
'{% static "rest_framework_swagger/lib/underscore-min.js" %}'
type=
'text/javascript'
></script>
<script
src=
'{% static "rest_framework_swagger/lib/backbone-min.js" %}'
type=
'text/javascript'
></script>
<script
src=
'{% static "rest_framework_swagger/lib/swagger.js" %}'
type=
'text/javascript'
></script>
<script
src=
'{% static "rest_framework_swagger/swagger-ui.min.js" %}'
type=
'text/javascript'
></script>
<script
src=
'{% static "rest_framework_swagger/lib/highlight.7.3.pack.js" %}'
type=
'text/javascript'
></script>
<link
rel=
"icon"
type=
"image/x-icon"
href=
'{% static "images/favicon.ico" %}'
/>
{% block header %}
<div
id=
"header"
>
<div
class=
"swagger-ui-wrap"
>
<form
id=
'api_selector'
>
<div
class=
'input'
><input
placeholder=
"http://example.com/api"
id=
"input_baseUrl"
name=
"baseUrl"
type=
"text"
/></div>
<div
class=
'input'
><input
placeholder=
"API Key"
id=
"input_apiKey"
name=
"apiKey"
type=
"text"
/></div>
</form>
</div>
</div>
{% endblock %}
{% block extra_scripts %}
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
$
(
function
()
{
$
(
function
()
{
window
.
swaggerUi
=
new
SwaggerUi
({
window
.
swaggerUi
=
new
SwaggerUi
({
url
:
"{{ swagger_settings.discovery_url }}"
,
url
:
''
,
apiKey
:
"{{ swagger_settings.api_key }}"
,
dom_id
:
'swagger-ui-container'
dom_id
:
"swagger-ui-container"
,
supportedSubmitMethods
:
{{
swagger_settings
.
enabled_methods
}},
onComplete
:
function
(
swaggerApi
,
swaggerUi
){
if
(
console
)
{
console
.
log
(
"Loaded SwaggerUI"
)
}
$
(
'pre code'
).
each
(
function
(
i
,
e
)
{
hljs
.
highlightBlock
(
e
)});
},
onFailure
:
function
(
data
)
{
if
(
console
)
{
console
.
log
(
"Unable to Load SwaggerUI"
);
console
.
log
(
data
);
}
},
docExpansion
:
"none"
});
});
// this sets the authorization token so calls to the API can made via swagger
$
(
'#input_apiKey'
).
change
(
function
()
{
$
(
'#input_apiKey'
).
change
(
function
()
{
var
key
=
$
(
'#input_apiKey'
)[
0
].
value
;
var
key
=
$
(
'#input_apiKey'
)[
0
].
value
;
console
.
log
(
"key: "
+
key
);
console
.
log
(
'key: '
+
key
);
if
(
key
&&
key
.
trim
()
!=
""
)
{
if
(
key
&&
key
.
trim
()
!==
''
)
{
console
.
log
(
"added key "
+
key
);
console
.
log
(
'added key '
+
key
);
window
.
authorizations
.
add
(
"key"
,
new
ApiKeyAuthorization
(
"Authorization"
,
"Token "
+
key
,
"header"
));
window
.
swaggerUi
.
api
.
clientAuthorizations
.
add
(
'key'
,
new
SwaggerClient
.
ApiKeyAuthorization
(
'Authorization'
,
'Token '
+
key
,
'header'
)
);
}
}
})
});
{
%
if
swagger_settings
.
api_key
%
}
window
.
authorizations
.
add
(
"key"
,
new
ApiKeyAuthorization
(
"Authorization"
,
"Token "
+
"{{ swagger_settings.api_key }}"
,
"header"
));
{
%
endif
%
}
window
.
swaggerUi
.
load
();
window
.
swaggerUi
.
load
();
});
});
</script>
</script>
</head>
<body>
<div
id=
'header'
>
<div
class=
"swagger-ui-wrap"
>
<a
id=
"logo"
class=
"edx-logo"
href=
"http://code.edx.org/"
></a>
<form
id=
'api_selector'
>
<div
class=
'input'
><input
placeholder=
"http://example.com/api"
id=
"input_baseUrl"
name=
"baseUrl"
type=
"text"
/></div>
<div
class=
'input'
><input
placeholder=
"API Key"
id=
"input_apiKey"
name=
"apiKey"
type=
"text"
/></div>
<div
class=
'input'
><a
id=
"explore"
href=
"#"
>
Explore
</a></div>
</form>
</div>
</div>
<div
id=
"message-bar"
class=
"swagger-ui-wrap"
>
</div>
<div
id=
"swagger-ui-container"
class=
"swagger-ui-wrap"
>
</div>
</body>
</html>
<script
src=
'{% static "rest_framework_swagger/init.js" %}'
type=
'text/javascript'
></script>
{% endblock %}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment