fix merge conflict with _variables.scss
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import json
|
||||
import logging
|
||||
import re
|
||||
import sys
|
||||
from functools import partial
|
||||
|
||||
@@ -13,7 +12,6 @@ from django.http import Http404
|
||||
from django.http import HttpResponse
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
||||
import pyparsing
|
||||
from requests.auth import HTTPBasicAuth
|
||||
from statsd import statsd
|
||||
|
||||
@@ -599,14 +597,14 @@ def _check_files_limits(files):
|
||||
|
||||
# Check number of files submitted
|
||||
if len(inputfiles) > settings.MAX_FILEUPLOADS_PER_INPUT:
|
||||
msg = 'Submission aborted! Maximum %d files may be submitted at once' %\
|
||||
msg = 'Submission aborted! Maximum %d files may be submitted at once' % \
|
||||
settings.MAX_FILEUPLOADS_PER_INPUT
|
||||
return msg
|
||||
|
||||
# Check file sizes
|
||||
for inputfile in inputfiles:
|
||||
if inputfile.size > settings.STUDENT_FILEUPLOAD_MAX_SIZE: # Bytes
|
||||
msg = 'Submission aborted! Your file "%s" is too large (max size: %d MB)' %\
|
||||
if inputfile.size > settings.STUDENT_FILEUPLOAD_MAX_SIZE: # Bytes
|
||||
msg = 'Submission aborted! Your file "%s" is too large (max size: %d MB)' % \
|
||||
(inputfile.name, settings.STUDENT_FILEUPLOAD_MAX_SIZE / (1000 ** 2))
|
||||
return msg
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ class TestTOC(TestCase):
|
||||
'format': '', 'due': None, 'active': False},
|
||||
{'url_name': 'video_123456789012', 'display_name': 'Test Video', 'graded': True,
|
||||
'format': '', 'due': None, 'active': False},
|
||||
{'url_name': 'video_4f66f493ac8f', 'display_name': 'Video Title', 'graded': True,
|
||||
{'url_name': 'video_4f66f493ac8f', 'display_name': 'Video', 'graded': True,
|
||||
'format': '', 'due': None, 'active': False}],
|
||||
'url_name': 'Overview', 'display_name': u'Overview'},
|
||||
{'active': False, 'sections':
|
||||
@@ -230,7 +230,6 @@ class TestTOC(TestCase):
|
||||
'url_name': 'secret:magic', 'display_name': 'secret:magic'}])
|
||||
|
||||
actual = render.toc_for_course(self.portal_user, request, self.toy_course, chapter, None, model_data_cache)
|
||||
print actual
|
||||
assert reduce(lambda x, y: x and (y in actual), expected, True)
|
||||
|
||||
def test_toc_toy_from_section(self):
|
||||
@@ -249,7 +248,7 @@ class TestTOC(TestCase):
|
||||
'format': '', 'due': None, 'active': True},
|
||||
{'url_name': 'video_123456789012', 'display_name': 'Test Video', 'graded': True,
|
||||
'format': '', 'due': None, 'active': False},
|
||||
{'url_name': 'video_4f66f493ac8f', 'display_name': 'Video Title', 'graded': True,
|
||||
{'url_name': 'video_4f66f493ac8f', 'display_name': 'Video', 'graded': True,
|
||||
'format': '', 'due': None, 'active': False}],
|
||||
'url_name': 'Overview', 'display_name': u'Overview'},
|
||||
{'active': False, 'sections':
|
||||
|
||||
@@ -122,6 +122,11 @@ class UserViewSetTest(UserApiTestCase):
|
||||
def test_list_unauthorized(self):
|
||||
self.assertHttpForbidden(self.client.get(self.LIST_URI))
|
||||
|
||||
@override_settings(DEBUG=True)
|
||||
@override_settings(EDX_API_KEY=None)
|
||||
def test_debug_auth(self):
|
||||
self.assertHttpOK(self.client.get(self.LIST_URI))
|
||||
|
||||
def test_get_list_empty(self):
|
||||
User.objects.all().delete()
|
||||
result = self.get_json(self.LIST_URI)
|
||||
@@ -220,6 +225,11 @@ class UserPreferenceViewSetTest(UserApiTestCase):
|
||||
def test_list_unauthorized(self):
|
||||
self.assertHttpForbidden(self.client.get(self.LIST_URI))
|
||||
|
||||
@override_settings(DEBUG=True)
|
||||
@override_settings(EDX_API_KEY=None)
|
||||
def test_debug_auth(self):
|
||||
self.assertHttpOK(self.client.get(self.LIST_URI))
|
||||
|
||||
def test_get_list_empty(self):
|
||||
UserPreference.objects.all().delete()
|
||||
result = self.get_json(self.LIST_URI)
|
||||
@@ -252,6 +262,26 @@ class UserPreferenceViewSetTest(UserApiTestCase):
|
||||
self.assertPrefIsValid(pref)
|
||||
self.assertEqual(pref["key"], "key0")
|
||||
|
||||
def test_get_list_filter_user_empty(self):
|
||||
def test_id(user_id):
|
||||
result = self.get_json(self.LIST_URI, data={"user": user_id})
|
||||
self.assertEqual(result["count"], 0)
|
||||
self.assertEqual(result["results"], [])
|
||||
test_id(self.users[2].id)
|
||||
# TODO: If the given id does not match a user, then the filter is a no-op
|
||||
# test_id(42)
|
||||
# test_id("asdf")
|
||||
|
||||
def test_get_list_filter_user_nonempty(self):
|
||||
user_id = self.users[0].id
|
||||
result = self.get_json(self.LIST_URI, data={"user": user_id})
|
||||
self.assertEqual(result["count"], 2)
|
||||
prefs = result["results"]
|
||||
self.assertEqual(len(prefs), 2)
|
||||
for pref in prefs:
|
||||
self.assertPrefIsValid(pref)
|
||||
self.assertEqual(pref["user"]["id"], user_id)
|
||||
|
||||
def test_get_list_pagination(self):
|
||||
first_page = self.get_json(self.LIST_URI, data={"page_size": 2})
|
||||
self.assertEqual(first_page["count"], 3)
|
||||
|
||||
@@ -12,11 +12,16 @@ class ApiKeyHeaderPermission(permissions.BasePermission):
|
||||
"""
|
||||
Check for permissions by matching the configured API key and header
|
||||
|
||||
settings.EDX_API_KEY must be set, and the X-Edx-Api-Key HTTP header must
|
||||
be present in the request and match the setting.
|
||||
If settings.DEBUG is True and settings.EDX_API_KEY is not set or None,
|
||||
then allow the request. Otherwise, allow the request if and only if
|
||||
settings.EDX_API_KEY is set and the X-Edx-Api-Key HTTP header is
|
||||
present in the request and matches the setting.
|
||||
"""
|
||||
api_key = getattr(settings, "EDX_API_KEY", None)
|
||||
return api_key is not None and request.META.get("HTTP_X_EDX_API_KEY") == api_key
|
||||
return (
|
||||
(settings.DEBUG and api_key is None) or
|
||||
(api_key is not None and request.META.get("HTTP_X_EDX_API_KEY") == api_key)
|
||||
)
|
||||
|
||||
|
||||
class UserViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
@@ -31,7 +36,7 @@ class UserPreferenceViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
permission_classes = (ApiKeyHeaderPermission,)
|
||||
queryset = UserPreference.objects.all()
|
||||
filter_backends = (filters.DjangoFilterBackend,)
|
||||
filter_fields = ("key",)
|
||||
filter_fields = ("key", "user")
|
||||
serializer_class = UserPreferenceSerializer
|
||||
paginate_by = 10
|
||||
paginate_by_param = "page_size"
|
||||
|
||||
Reference in New Issue
Block a user