Commit 05dba592 by Muhammad Ammar

Merge pull request #29 from edx/ammar/upgrade-django1.8

upgrade django 1.8
parents 41cb623a 241eff24
......@@ -12,7 +12,6 @@ endif
test: clean
./manage.py test --settings=$(test_settings) --with-coverage --with-ignore-docstrings \
--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-xml --cover-xml-file=build/coverage/coverage.xml \
$(foreach package,$(PACKAGES),--cover-package=$(package)) \
......@@ -48,8 +47,5 @@ requirements:
test.requirements: requirements
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
......@@ -41,7 +41,7 @@ class HasAccessToken(BasePermission):
if data['aud'] != settings.CLIENT_ID:
raise TokenWrongIssuer
user_found = False
for request_field in ('GET', 'POST', 'DATA'):
for request_field in ('GET', 'POST', 'data'):
if 'user' in getattr(request, request_field):
req_user = getattr(request, request_field)['user']
if req_user == auth_user:
......
......@@ -92,10 +92,10 @@ class BaseAnnotationViewTests(APITestCase):
"""
Helper for search method. All keyword parameters are passed in GET
"""
q = QueryDict("user=" + TEST_USER, mutable=True)
q.update(kwargs)
url = reverse('api:v1:annotations_search') + '?{}'.format(q.urlencode())
result = self.client.get(url)
data = {"user": TEST_USER}
data.update(kwargs)
url = reverse('api:v1:annotations_search')
result = self.client.get(url, data=data)
return result.data
......
......@@ -29,7 +29,7 @@ class AnnotationSearchView(APIView):
Search annotations in most appropriate storage
"""
# 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)
else:
results = self.get_from_es(*args, **kwargs)
......@@ -39,7 +39,7 @@ class AnnotationSearchView(APIView):
"""
Search annotations in database
"""
params = self.request.QUERY_PARAMS.dict()
params = self.request.query_params.dict()
query = Note.objects.filter(
**{f: v for (f, v) in params.items() if f in ('course_id', 'usage_id')}
).order_by('-updated')
......@@ -56,7 +56,7 @@ class AnnotationSearchView(APIView):
"""
Search annotations in ElasticSearch
"""
params = self.request.QUERY_PARAMS.dict()
params = self.request.query_params.dict()
query = SearchQuerySet().models(Note).filter(
**{f: v for (f, v) in params.items() if f in ('user', 'course_id', 'usage_id')}
)
......@@ -102,7 +102,7 @@ class AnnotationListView(APIView):
"""
Get a list of all annotations.
"""
params = self.request.QUERY_PARAMS.dict()
params = self.request.query_params.dict()
if 'course_id' not in params:
return Response(status=status.HTTP_400_BAD_REQUEST)
......@@ -117,11 +117,11 @@ class AnnotationListView(APIView):
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)
try:
note = Note.create(self.request.DATA)
note = Note.create(self.request.data)
note.full_clean()
except ValidationError as error:
log.debug(error, exc_info=True)
......
......@@ -44,6 +44,8 @@ MIDDLEWARE_CLASSES = (
)
INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.staticfiles',
'rest_framework',
'rest_framework_swagger',
......
......@@ -3,6 +3,7 @@ from .common import *
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'default.db',
}
}
......
......@@ -7,8 +7,6 @@
# pygtk.require().
#init-hook=
# Profiled execution.
profile=no
# Add files or directories to the blacklist. They should be base names, not
# paths.
......@@ -69,10 +67,6 @@ reports=yes
# (RP0004).
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
# used to format the message information. See doc for all details
#msg-template=
......@@ -80,9 +74,6 @@ comment=no
[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
bad-functions=map,filter,apply,input,file
......@@ -197,10 +188,6 @@ ignored-modules=
# (useful for classes with attributes dynamically set).
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
# system, and so shouldn't trigger E0201 when accessed. Python regular
# expressions are accepted.
......@@ -315,10 +302,6 @@ max-public-methods=20
[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.
defining-attr-methods=__init__,__new__,setUp
......
Django==1.7.3
Django==1.8.7
requests==2.4.3
djangorestframework==3.0.2
djangorestframework==3.2.3
django-rest-swagger==0.2.0
django-haystack==2.3.1
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
MySQL-python==1.2.5 # GPL License
gunicorn==19.1.1 # MIT
......
-r base.txt
django_nose==1.2
django_nose==1.4.1
mock==1.0.1
coverage==3.7.1
nose-exclude==0.2.0
nose-ignore-docstring==0.2
pep8==1.5.7
pylint==1.4.1
pylint==1.5.0
diff-cover==0.7.2
factory_boy==2.5.2
ddt==0.8.0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment