We need to do this because when I tride to go to the JSON serializer a
bunch of tests started failing because various parts of our code are
putting things into the session that are not JSON serializable.
We can't keep using the default pickle serializer because it defaluts to
using the highest available protocol and that will cause issues with the
python 2 to 3 upgrade since both will be running in production at the
same time. We need to use a version of the pickle protocol that both
can use interchangably.
We also need to make sure we read with latin1 encoding to make datetimes
work correctly between the two versions of python.
HIGHEST_PROTOCOL will cause it to change when we move from python 2 to 3
and this may cause issues as older machines try to read objects pickeld
with a version of the protocol they don't know.
During deploys, and if we have to roll back are two examples.
Changes to show blank screen instead of logout message for Enterprise SSO flow. It confuses learner when they are already signed in and access their course from B2B site.
ENT-1688
Fixed pep8 quality violation
use testserver as HOST instead of edx.org
assert enterprise app is enabled
added logging
Print different values
Reload django url config
assert all quote operations to see how they work on jenkins
debug url resolved values
login user in setup
added log to debug test on jenkins
Using UrlResetMixin
Using regex instead of resolve
Fixed quality violation
Fixed pylint quality violations
Fixed target interpolation syntax
Added developer's comment
changes made to pass tests with python 2 and other minor changes
Updated the tests to fix the string/bytes input
changes made to pass tests with python 2 and other minor changes
made some changes as suggested
made changes as suggested
changes made as suggested
Python3 json can not work with bytes type input so used simplejson
instead of python json which works with both bytes and unicode
type input.
Previously we mistakenly updated StringIO to six.String io. which
caused the tests failure. Used io.BytesIO to fix the issues as
assci character bytes can not be converted to unicode.
The API documentation decorators do not have to leak which solution we
use to generate the docs. Here, and as discussed in PR #21820, we rename
the `openapi` module to `apidocs`, and we make sure that this module
includes all the right functions to document API Views without referring
to Open API.
The `swagger_auto_schema` view function decorator allows us to
auto-document API endpoints. All swagger arguments are passed as kwargs
to the decorator, but this feels a bit unnatural: we would like to use
the function documentation as the endpoint summary and description. We
introduce this feature here by reading the `__doc_`_attribute of the
view function.
This fixes errors like:
Oct 10 12:46:07 ip-10-2-10-15 [service_variant=lms][django.request][env:prod-edx-edxapp] ERROR [ip-10-2-10-15 31278] [user None] [exception.py:135] - Internal Server Error: /courses/course-v1:HarvardX+1962USRx+3T2019/discussions/settings
Traceback (most recent call last):
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
response = self._get_response(request)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/decorators.py", line 185, in inner
return func(*args, **kwargs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/newrelic/hooks/framework_django.py", line 539, in wrapper
return wrapped(*args, **kwargs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/views/decorators/http.py", line 40, in inner
return func(request, *args, **kwargs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/decorators.py", line 149, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/edx/app/edxapp/edx-platform/common/djangoapps/util/json_request.py", line 55, in parse_json_into_request
return view_function(request, *args, **kwargs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/edx/app/edxapp/edx-platform/lms/djangoapps/discussion/views.py", line 936, in course_discussions_settings_handler
course, discussion_settings
File "/edx/app/edxapp/edx-platform/lms/djangoapps/discussion/views.py", line 957, in get_divided_discussions
all_discussions = utils.get_discussion_categories_ids(course, None, include_all=True)
File "/edx/app/edxapp/edx-platform/lms/djangoapps/discussion/django_comment_client/utils.py", line 485, in get_discussion_categories_ids
xblock.discussion_id for xblock in get_accessible_discussion_xblocks(course, user, include_all=include_all)
File "/edx/app/edxapp/edx-platform/lms/djangoapps/discussion/django_comment_client/utils.py", line 146, in get_accessible_discussion_xblocks
return get_accessible_discussion_xblocks_by_course_id(course.id, user, include_all=include_all)
File "/edx/app/edxapp/edx-platform/openedx/core/lib/cache_utils.py", line 73, in decorator
result = wrapped(*args, **kwargs)
File "/edx/app/edxapp/edx-platform/lms/djangoapps/discussion/django_comment_client/utils.py", line 159, in get_accessible_discussion_xblocks_by_course_id
if has_required_keys(xblock) and (include_all or has_access(user, 'load', xblock, course_id))
File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/access.py", line 158, in has_access
return _has_access_descriptor(user, action, obj, course_key)
File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/access.py", line 572, in _has_access_descriptor
return _dispatch(checkers, action, user, descriptor)
File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/access.py", line 669, in _dispatch
result = table[action]()
File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/access.py", line 543, in can_load
group_access_response = _has_group_access(descriptor, user, course_key)
File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/access.py", line 513, in _has_group_access
user_fragment=partition.access_denied_fragment(descriptor, user, user_group, allowed_groups),
File "/edx/app/edxapp/edx-platform/openedx/features/content_type_gating/partitions.py", line 98, in access_denied_fragment
upgrade_price, _ = format_strikeout_price(user, course)
File "/edx/app/edxapp/edx-platform/openedx/features/discounts/utils.py", line 22, in format_strikeout_price
if can_receive_discount(user, course):
File "/edx/app/edxapp/edx-platform/openedx/features/discounts/applicability.py", line 74, in can_receive_discount
if CourseEnrollment.objects.filter(user=user).exclude(mode__in=CourseMode.UPSELL_TO_VERIFIED_MODES).exists():
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/query.py", line 787, in filter
return self._filter_or_exclude(False, *args, **kwargs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/query.py", line 805, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1250, in add_q
clause, _ = self._add_q(q_object, self.used_aliases)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1276, in _add_q
allow_joins=allow_joins, split_subq=split_subq,
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1206, in build_filter
condition = lookup_class(lhs, value)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/lookups.py", line 24, in __init__
self.rhs = self.get_prep_lookup()
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/fields/related_lookups.py", line 112, in get_prep_lookup
self.rhs = target_field.get_prep_value(self.rhs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 966, in get_prep_value
return int(value)
TypeError: int() argument must be a string or a number, not 'AnonymousUser'
This is tracked in https://openedx.atlassian.net/browse/REV-988
[REV-988]