Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-notes-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-notes-api
Commits
05dba592
Commit
05dba592
authored
Dec 01, 2015
by
Muhammad Ammar
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #29 from edx/ammar/upgrade-django1.8
upgrade django 1.8
parents
41cb623a
241eff24
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
19 additions
and
37 deletions
+19
-37
Makefile
+0
-4
notesapi/v1/permissions.py
+1
-1
notesapi/v1/tests/test_views.py
+4
-4
notesapi/v1/views.py
+6
-6
notesserver/settings/common.py
+2
-0
notesserver/settings/test.py
+1
-0
pylintrc
+0
-17
requirements/base.txt
+3
-3
requirements/test.txt
+2
-2
No files found.
Makefile
View file @
05dba592
...
@@ -12,7 +12,6 @@ endif
...
@@ -12,7 +12,6 @@ endif
test
:
clean
test
:
clean
./manage.py
test
--settings
=
$(test_settings)
--with-coverage
--with-ignore-docstrings
\
./manage.py
test
--settings
=
$(test_settings)
--with-coverage
--with-ignore-docstrings
\
--exclude-dir
=
notesserver/settings
--cover-inclusive
--cover-branches
\
--exclude-dir
=
notesserver/settings
--cover-inclusive
--cover-branches
\
--ignore-files
=
search_indexes.py
--ignore-files
=
highlight.py
\
--cover-html
--cover-html-dir
=
build/coverage/html/
\
--cover-html
--cover-html-dir
=
build/coverage/html/
\
--cover-xml
--cover-xml-file
=
build/coverage/coverage.xml
\
--cover-xml
--cover-xml-file
=
build/coverage/coverage.xml
\
$
(
foreach package,
$(PACKAGES)
,--cover-package
=
$(package)
)
\
$
(
foreach package,
$(PACKAGES)
,--cover-package
=
$(package)
)
\
...
@@ -48,8 +47,5 @@ requirements:
...
@@ -48,8 +47,5 @@ requirements:
test.requirements
:
requirements
test.requirements
:
requirements
pip install
-q
-r
requirements/test.txt
--exists-action
=
w
pip install
-q
-r
requirements/test.txt
--exists-action
=
w
@
# unicode QUERY_PARAMS are being improperly decoded in test client
@
# remove after https://github.com/tomchristie/django-rest-framework/issues/1891 is fixed
pip install
-q
-e
git+https://github.com/tymofij/django-rest-framework.git@bugfix/test-unicode-query-params#egg
=
djangorestframework
develop
:
test.requirements
develop
:
test.requirements
notesapi/v1/permissions.py
View file @
05dba592
...
@@ -41,7 +41,7 @@ class HasAccessToken(BasePermission):
...
@@ -41,7 +41,7 @@ class HasAccessToken(BasePermission):
if
data
[
'aud'
]
!=
settings
.
CLIENT_ID
:
if
data
[
'aud'
]
!=
settings
.
CLIENT_ID
:
raise
TokenWrongIssuer
raise
TokenWrongIssuer
user_found
=
False
user_found
=
False
for
request_field
in
(
'GET'
,
'POST'
,
'
DATA
'
):
for
request_field
in
(
'GET'
,
'POST'
,
'
data
'
):
if
'user'
in
getattr
(
request
,
request_field
):
if
'user'
in
getattr
(
request
,
request_field
):
req_user
=
getattr
(
request
,
request_field
)[
'user'
]
req_user
=
getattr
(
request
,
request_field
)[
'user'
]
if
req_user
==
auth_user
:
if
req_user
==
auth_user
:
...
...
notesapi/v1/tests/test_views.py
View file @
05dba592
...
@@ -92,10 +92,10 @@ class BaseAnnotationViewTests(APITestCase):
...
@@ -92,10 +92,10 @@ class BaseAnnotationViewTests(APITestCase):
"""
"""
Helper for search method. All keyword parameters are passed in GET
Helper for search method. All keyword parameters are passed in GET
"""
"""
q
=
QueryDict
(
"user="
+
TEST_USER
,
mutable
=
True
)
data
=
{
"user"
:
TEST_USER
}
q
.
update
(
kwargs
)
data
.
update
(
kwargs
)
url
=
reverse
(
'api:v1:annotations_search'
)
+
'?{}'
.
format
(
q
.
urlencode
())
url
=
reverse
(
'api:v1:annotations_search'
)
result
=
self
.
client
.
get
(
url
)
result
=
self
.
client
.
get
(
url
,
data
=
data
)
return
result
.
data
return
result
.
data
...
...
notesapi/v1/views.py
View file @
05dba592
...
@@ -29,7 +29,7 @@ class AnnotationSearchView(APIView):
...
@@ -29,7 +29,7 @@ class AnnotationSearchView(APIView):
Search annotations in most appropriate storage
Search annotations in most appropriate storage
"""
"""
# search in DB when ES is not available or there is no need to bother it
# search in DB when ES is not available or there is no need to bother it
if
settings
.
ES_DISABLED
or
'text'
not
in
self
.
request
.
QUERY_PARAMS
.
dict
():
if
settings
.
ES_DISABLED
or
'text'
not
in
self
.
request
.
query_params
.
dict
():
results
=
self
.
get_from_db
(
*
args
,
**
kwargs
)
results
=
self
.
get_from_db
(
*
args
,
**
kwargs
)
else
:
else
:
results
=
self
.
get_from_es
(
*
args
,
**
kwargs
)
results
=
self
.
get_from_es
(
*
args
,
**
kwargs
)
...
@@ -39,7 +39,7 @@ class AnnotationSearchView(APIView):
...
@@ -39,7 +39,7 @@ class AnnotationSearchView(APIView):
"""
"""
Search annotations in database
Search annotations in database
"""
"""
params
=
self
.
request
.
QUERY_PARAMS
.
dict
()
params
=
self
.
request
.
query_params
.
dict
()
query
=
Note
.
objects
.
filter
(
query
=
Note
.
objects
.
filter
(
**
{
f
:
v
for
(
f
,
v
)
in
params
.
items
()
if
f
in
(
'course_id'
,
'usage_id'
)}
**
{
f
:
v
for
(
f
,
v
)
in
params
.
items
()
if
f
in
(
'course_id'
,
'usage_id'
)}
)
.
order_by
(
'-updated'
)
)
.
order_by
(
'-updated'
)
...
@@ -56,7 +56,7 @@ class AnnotationSearchView(APIView):
...
@@ -56,7 +56,7 @@ class AnnotationSearchView(APIView):
"""
"""
Search annotations in ElasticSearch
Search annotations in ElasticSearch
"""
"""
params
=
self
.
request
.
QUERY_PARAMS
.
dict
()
params
=
self
.
request
.
query_params
.
dict
()
query
=
SearchQuerySet
()
.
models
(
Note
)
.
filter
(
query
=
SearchQuerySet
()
.
models
(
Note
)
.
filter
(
**
{
f
:
v
for
(
f
,
v
)
in
params
.
items
()
if
f
in
(
'user'
,
'course_id'
,
'usage_id'
)}
**
{
f
:
v
for
(
f
,
v
)
in
params
.
items
()
if
f
in
(
'user'
,
'course_id'
,
'usage_id'
)}
)
)
...
@@ -102,7 +102,7 @@ class AnnotationListView(APIView):
...
@@ -102,7 +102,7 @@ class AnnotationListView(APIView):
"""
"""
Get a list of all annotations.
Get a list of all annotations.
"""
"""
params
=
self
.
request
.
QUERY_PARAMS
.
dict
()
params
=
self
.
request
.
query_params
.
dict
()
if
'course_id'
not
in
params
:
if
'course_id'
not
in
params
:
return
Response
(
status
=
status
.
HTTP_400_BAD_REQUEST
)
return
Response
(
status
=
status
.
HTTP_400_BAD_REQUEST
)
...
@@ -117,11 +117,11 @@ class AnnotationListView(APIView):
...
@@ -117,11 +117,11 @@ class AnnotationListView(APIView):
Returns 400 request if bad payload is sent or it was empty object.
Returns 400 request if bad payload is sent or it was empty object.
"""
"""
if
'id'
in
self
.
request
.
DATA
:
if
'id'
in
self
.
request
.
data
:
return
Response
(
status
=
status
.
HTTP_400_BAD_REQUEST
)
return
Response
(
status
=
status
.
HTTP_400_BAD_REQUEST
)
try
:
try
:
note
=
Note
.
create
(
self
.
request
.
DATA
)
note
=
Note
.
create
(
self
.
request
.
data
)
note
.
full_clean
()
note
.
full_clean
()
except
ValidationError
as
error
:
except
ValidationError
as
error
:
log
.
debug
(
error
,
exc_info
=
True
)
log
.
debug
(
error
,
exc_info
=
True
)
...
...
notesserver/settings/common.py
View file @
05dba592
...
@@ -44,6 +44,8 @@ MIDDLEWARE_CLASSES = (
...
@@ -44,6 +44,8 @@ MIDDLEWARE_CLASSES = (
)
)
INSTALLED_APPS
=
[
INSTALLED_APPS
=
[
'django.contrib.auth'
,
'django.contrib.contenttypes'
,
'django.contrib.staticfiles'
,
'django.contrib.staticfiles'
,
'rest_framework'
,
'rest_framework'
,
'rest_framework_swagger'
,
'rest_framework_swagger'
,
...
...
notesserver/settings/test.py
View file @
05dba592
...
@@ -3,6 +3,7 @@ from .common import *
...
@@ -3,6 +3,7 @@ from .common import *
DATABASES
=
{
DATABASES
=
{
'default'
:
{
'default'
:
{
'ENGINE'
:
'django.db.backends.sqlite3'
,
'ENGINE'
:
'django.db.backends.sqlite3'
,
'NAME'
:
'default.db'
,
}
}
}
}
...
...
pylintrc
View file @
05dba592
...
@@ -7,8 +7,6 @@
...
@@ -7,8 +7,6 @@
# pygtk.require().
# pygtk.require().
#init-hook=
#init-hook=
# Profiled execution.
profile=no
# Add files or directories to the blacklist. They should be base names, not
# Add files or directories to the blacklist. They should be base names, not
# paths.
# paths.
...
@@ -69,10 +67,6 @@ reports=yes
...
@@ -69,10 +67,6 @@ reports=yes
# (RP0004).
# (RP0004).
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
# Add a comment according to your evaluation note. This is used by the global
# evaluation report (RP0004).
comment=no
# Template used to display messages. This is a python new-style format string
# Template used to display messages. This is a python new-style format string
# used to format the message information. See doc for all details
# used to format the message information. See doc for all details
#msg-template=
#msg-template=
...
@@ -80,9 +74,6 @@ comment=no
...
@@ -80,9 +74,6 @@ comment=no
[BASIC]
[BASIC]
# Required attributes for module, separated by a comma
required-attributes=
# List of builtins function names that should not be used, separated by a comma
# List of builtins function names that should not be used, separated by a comma
bad-functions=map,filter,apply,input,file
bad-functions=map,filter,apply,input,file
...
@@ -197,10 +188,6 @@ ignored-modules=
...
@@ -197,10 +188,6 @@ ignored-modules=
# (useful for classes with attributes dynamically set).
# (useful for classes with attributes dynamically set).
ignored-classes=SQLObject
ignored-classes=SQLObject
# When zope mode is activated, add a predefined set of Zope acquired attributes
# to generated-members.
zope=no
# List of members which are set dynamically and missed by pylint inference
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E0201 when accessed. Python regular
# system, and so shouldn't trigger E0201 when accessed. Python regular
# expressions are accepted.
# expressions are accepted.
...
@@ -315,10 +302,6 @@ max-public-methods=20
...
@@ -315,10 +302,6 @@ max-public-methods=20
[CLASSES]
[CLASSES]
# List of interface methods to ignore, separated by a comma. This is used for
# instance to not check methods defines in Zope's Interface base class.
ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by
# List of method names used to declare (i.e. assign) instance attributes.
# List of method names used to declare (i.e. assign) instance attributes.
defining-attr-methods=__init__,__new__,setUp
defining-attr-methods=__init__,__new__,setUp
...
...
requirements/base.txt
View file @
05dba592
Django==1.
7.3
Django==1.
8.7
requests==2.4.3
requests==2.4.3
djangorestframework==3.
0.2
djangorestframework==3.
2.3
django-rest-swagger==0.2.0
django-rest-swagger==0.2.0
django-haystack==2.3.1
django-haystack==2.3.1
elasticsearch==0.4.5 # only 0.4 works for ES 0.90
elasticsearch==0.4.5 # only 0.4 works for ES 0.90
django-cors-headers==
0.13
django-cors-headers==
1.1.0
PyJWT==0.3.0
PyJWT==0.3.0
MySQL-python==1.2.5 # GPL License
MySQL-python==1.2.5 # GPL License
gunicorn==19.1.1 # MIT
gunicorn==19.1.1 # MIT
...
...
requirements/test.txt
View file @
05dba592
-r base.txt
-r base.txt
django_nose==1.
2
django_nose==1.
4.1
mock==1.0.1
mock==1.0.1
coverage==3.7.1
coverage==3.7.1
nose-exclude==0.2.0
nose-exclude==0.2.0
nose-ignore-docstring==0.2
nose-ignore-docstring==0.2
pep8==1.5.7
pep8==1.5.7
pylint==1.
4.1
pylint==1.
5.0
diff-cover==0.7.2
diff-cover==0.7.2
factory_boy==2.5.2
factory_boy==2.5.2
ddt==0.8.0
ddt==0.8.0
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