Merge pull request #19225 from edx/fsheets/fix-unicode
WIP: Cleanup from LEARNER-6668
This commit is contained in:
@@ -124,12 +124,11 @@ class StartDateError(AccessError):
|
||||
def __init__(self, start_date):
|
||||
error_code = "course_not_started"
|
||||
if start_date == DEFAULT_START_DATE:
|
||||
developer_message = "Course has not started"
|
||||
user_message = _("Course has not started")
|
||||
developer_message = u"Course has not started"
|
||||
user_message = _(u"Course has not started")
|
||||
else:
|
||||
developer_message = "Course does not start until {}".format(start_date)
|
||||
user_message = _("Course does not start until {}"
|
||||
.format("{:%B %d, %Y}".format(start_date)))
|
||||
developer_message = u"Course does not start until {}".format(start_date)
|
||||
user_message = _(u"Course does not start until {}").format("{:%B %d, %Y}".format(start_date))
|
||||
super(StartDateError, self).__init__(error_code, developer_message, user_message)
|
||||
|
||||
|
||||
@@ -139,8 +138,8 @@ class MilestoneAccessError(AccessError):
|
||||
"""
|
||||
def __init__(self):
|
||||
error_code = "unfulfilled_milestones"
|
||||
developer_message = "User has unfulfilled milestones"
|
||||
user_message = _("You have unfulfilled milestones")
|
||||
developer_message = u"User has unfulfilled milestones"
|
||||
user_message = _(u"You have unfulfilled milestones")
|
||||
super(MilestoneAccessError, self).__init__(error_code, developer_message, user_message)
|
||||
|
||||
|
||||
@@ -151,8 +150,8 @@ class VisibilityError(AccessError):
|
||||
"""
|
||||
def __init__(self):
|
||||
error_code = "not_visible_to_user"
|
||||
developer_message = "Course is not visible to this user"
|
||||
user_message = _("You do not have access to this course")
|
||||
developer_message = u"Course is not visible to this user"
|
||||
user_message = _(u"You do not have access to this course")
|
||||
super(VisibilityError, self).__init__(error_code, developer_message, user_message)
|
||||
|
||||
|
||||
@@ -162,8 +161,8 @@ class MobileAvailabilityError(AccessError):
|
||||
"""
|
||||
def __init__(self):
|
||||
error_code = "mobile_unavailable"
|
||||
developer_message = "Course is not available on mobile for this user"
|
||||
user_message = _("You do not have access to this course on a mobile device")
|
||||
developer_message = u"Course is not available on mobile for this user"
|
||||
user_message = _(u"You do not have access to this course on a mobile device")
|
||||
super(MobileAvailabilityError, self).__init__(error_code, developer_message, user_message)
|
||||
|
||||
|
||||
@@ -192,5 +191,5 @@ class NoAllowedPartitionGroupsError(AccessError):
|
||||
"""
|
||||
def __init__(self, partition, user_message=None, user_fragment=None):
|
||||
error_code = "no_allowed_user_groups"
|
||||
developer_message = "Group access for {} excludes all students".format(partition.name)
|
||||
developer_message = u"Group access for {} excludes all students".format(partition.name)
|
||||
super(NoAllowedPartitionGroupsError, self).__init__(error_code, developer_message, user_message)
|
||||
|
||||
@@ -77,7 +77,7 @@ def get_course_by_id(course_key, depth=0):
|
||||
if course:
|
||||
return course
|
||||
else:
|
||||
raise Http404("Course not found: {}.".format(unicode(course_key)))
|
||||
raise Http404(u"Course not found: {}.".format(unicode(course_key)))
|
||||
|
||||
|
||||
def get_course_with_access(user, action, course_key, depth=0, check_if_enrolled=False, check_survey_complete=True):
|
||||
|
||||
@@ -151,7 +151,7 @@ class CoursewareIndex(View):
|
||||
|
||||
return self.render(request)
|
||||
except Exception as exception: # pylint: disable=broad-except
|
||||
return CourseTabView.handle_exceptions(request, self.course, exception)
|
||||
return CourseTabView.handle_exceptions(request, self.course_key, self.course, exception)
|
||||
|
||||
def _setup_masquerade_for_effective_user(self):
|
||||
"""
|
||||
@@ -315,7 +315,7 @@ class CoursewareIndex(View):
|
||||
if not child:
|
||||
# User may be trying to access a child that isn't live yet
|
||||
if not self._is_masquerading_as_student():
|
||||
raise Http404('No {block_type} found with name {url_name}'.format(
|
||||
raise Http404(u'No {block_type} found with name {url_name}'.format(
|
||||
block_type=block_type,
|
||||
url_name=url_name,
|
||||
))
|
||||
|
||||
@@ -509,7 +509,7 @@ class CourseTabView(EdxFragmentView):
|
||||
set_custom_metrics_for_course_key(course_key)
|
||||
return super(CourseTabView, self).get(request, course=course, page_context=page_context, **kwargs)
|
||||
except Exception as exception: # pylint: disable=broad-except
|
||||
return CourseTabView.handle_exceptions(request, course, exception)
|
||||
return CourseTabView.handle_exceptions(request, course_key, course, exception)
|
||||
|
||||
@staticmethod
|
||||
def url_to_enroll(course_key):
|
||||
@@ -560,14 +560,12 @@ class CourseTabView(EdxFragmentView):
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def handle_exceptions(request, course, exception):
|
||||
"""
|
||||
def handle_exceptions(request, course_key, course, exception):
|
||||
u"""
|
||||
Handle exceptions raised when rendering a view.
|
||||
"""
|
||||
if isinstance(exception, Redirect) or isinstance(exception, Http404):
|
||||
raise
|
||||
if isinstance(exception, UnicodeEncodeError):
|
||||
raise Http404("URL contains Unicode characters")
|
||||
if settings.DEBUG:
|
||||
raise
|
||||
user = request.user
|
||||
@@ -576,7 +574,7 @@ class CourseTabView(EdxFragmentView):
|
||||
request.path,
|
||||
getattr(user, 'real_user', user),
|
||||
user,
|
||||
None if course is None else text_type(course.id),
|
||||
text_type(course_key),
|
||||
)
|
||||
try:
|
||||
return render_to_response(
|
||||
|
||||
8
pylintrc
8
pylintrc
@@ -55,7 +55,7 @@
|
||||
[MASTER]
|
||||
ignore = ,.git,.tox,migrations,node_modules,.pycharm_helpers
|
||||
persistent = yes
|
||||
load-plugins = edx_lint.pylint,pylint_django,pylint_celery
|
||||
load-plugins = edx_lint.pylint,pylint_django,pylint_celery,caniusepython3.pylint_checker
|
||||
init-hook = "import sys; sys.path.extend(['lms/djangoapps', 'cms/djangoapps', 'common/djangoapps'])"
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
@@ -345,7 +345,9 @@ disable =
|
||||
unpacking-in-except,
|
||||
using-cmp-argument,
|
||||
xrange-builtin,
|
||||
zip-builtin-not-iterating,,unicode-format-string
|
||||
zip-builtin-not-iterating,
|
||||
unicode-format-string,
|
||||
native-string,
|
||||
|
||||
[REPORTS]
|
||||
output-format = text
|
||||
@@ -445,4 +447,4 @@ int-import-graph =
|
||||
[EXCEPTIONS]
|
||||
overgeneral-exceptions = Exception
|
||||
|
||||
# c8b8d35a9a123f3c2eb3ce0cb466156bab2beedc
|
||||
# 4285ece9aa125ff8efc6f77ed6d34579e65e2d96
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
[MASTER]
|
||||
ignore+ = ,.git,.tox,migrations,node_modules,.pycharm_helpers
|
||||
init-hook="import sys; sys.path.extend(['lms/djangoapps', 'cms/djangoapps', 'common/djangoapps'])"
|
||||
load-plugins+=,caniusepython3.pylint_checker
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
# Disable unicode-format-string until we can agree to turn it on.
|
||||
disable+ = ,unicode-format-string
|
||||
disable+ =
|
||||
unicode-format-string,
|
||||
native-string,
|
||||
|
||||
[BASIC]
|
||||
attr-rgx = [a-z_][a-z0-9_]{2,40}$
|
||||
|
||||
@@ -64,6 +64,7 @@ bok-choy==0.9.0
|
||||
boto3==1.4.8
|
||||
boto==2.39.0
|
||||
botocore==1.8.17
|
||||
caniusepython3==7.0.0
|
||||
celery==3.1.25
|
||||
certifi==2018.11.29
|
||||
cffi==1.11.5
|
||||
@@ -84,6 +85,7 @@ decorator==4.3.2
|
||||
defusedxml==0.5.0
|
||||
dicttoxml==1.7.4
|
||||
diff-cover==0.9.8
|
||||
distlib==0.2.8
|
||||
django-appconf==1.0.2
|
||||
django-babel-underscore==0.5.2
|
||||
django-babel==0.6.2
|
||||
@@ -224,7 +226,7 @@ oauth2==1.9.0.post1
|
||||
oauthlib==2.1.0
|
||||
openapi-codec==1.3.2
|
||||
pa11ycrawler==1.6.2
|
||||
packaging==19.0 # via sphinx
|
||||
packaging==19.0
|
||||
parsel==1.5.1
|
||||
path.py==8.2.1
|
||||
pathlib2==2.3.3
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
beautifulsoup4 # Library for extracting data from HTML and XML files
|
||||
before_after # Syntactic sugar for mock, only used in one test case, not Python 3 compatible
|
||||
bok-choy # Framework for browser automation tests, based on selenium
|
||||
caniusepython3 # Library for checking the ability to upgrade to python3
|
||||
cssselect # Used to extract HTML fragments via CSS selectors in 2 test cases and pyquery
|
||||
ddt # Run a test case multiple times with different input; used in many, many of our tests
|
||||
edx-i18n-tools>=0.4.6 # Commands for developers and translators to extract, compile and validate translations
|
||||
|
||||
@@ -61,6 +61,7 @@ bok-choy==0.9.0
|
||||
boto3==1.4.8
|
||||
boto==2.39.0
|
||||
botocore==1.8.17
|
||||
caniusepython3==7.0.0
|
||||
celery==3.1.25
|
||||
certifi==2018.11.29
|
||||
cffi==1.11.5
|
||||
@@ -81,6 +82,7 @@ decorator==4.3.2
|
||||
defusedxml==0.5.0
|
||||
dicttoxml==1.7.4 # via moto
|
||||
diff-cover==0.9.8
|
||||
distlib==0.2.8 # via caniusepython3
|
||||
django-appconf==1.0.2
|
||||
django-babel-underscore==0.5.2
|
||||
django-babel==0.6.2
|
||||
@@ -216,6 +218,7 @@ oauth2==1.9.0.post1
|
||||
oauthlib==2.1.0
|
||||
openapi-codec==1.3.2
|
||||
pa11ycrawler==1.6.2
|
||||
packaging==19.0 # via caniusepython3
|
||||
parsel==1.5.1 # via scrapy
|
||||
path.py==8.2.1
|
||||
pathlib2==2.3.3 # via pytest, pytest-django
|
||||
|
||||
Reference in New Issue
Block a user