-
Notifications
You must be signed in to change notification settings - Fork 4.2k
[BD-13] Deprecates remaining user-related properties on ModuleSystem #29375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thanks for the pull request, @pomegranited! I've created BLENDED-1020 to keep track of it in Jira. More details are on the BD-13 project page. When this pull request is ready, tag your edX technical lead. |
b95a920 to
185bedc
Compare
50d6ecd to
887d00f
Compare
|
Thanks for your detailed review @Agrendalath ! I've addressed your points, and deployed a new appserver. Could you activate that one and use it for your testing? Also, I'd like to squash my commits before merging, so let me know when you're ready for me to do that? |
Agrendalath
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
- I tested this: verified that the refactored properties are working correctly
- I read through the code
- I checked for accessibility issues: n/a
- Includes documentation
- I made sure any change in configuration variables is reflected in the corresponding client's
configuration-securerepository: n/a
|
@pomegranited, thank you for preparing the sandbox instance and nice testing instructions! Feel free to squash the commits. I've noticed an odd behavior of the LTI provider, though it doesn't seem to be related to this PR. When I"m opening the LTI XBlock in the LMS as a "staff" user - it's working correctly. However, when I'm using the "audit", then I'm getting an error page. There is the following traceback on the Traceback (most recent call last):
File "/edx/app/edxapp/edx-platform/lms/djangoapps/lti_provider/users.py", line 31, in authenticate_lti_user
lti_user = LtiUser.objects.get(
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/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/lib/python3.8/site-packages/django/db/models/query.py", line 435, in get
raise self.model.DoesNotExist(
lms.djangoapps.lti_provider.models.LtiUser.DoesNotExist: LtiUser matching query does not exist.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python3.8/contextlib.py", line 75, in inner
return func(*args, **kwds)
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/newrelic/hooks/framework_django.py", line 562, in wrapper
return wrapped(*args, **kwargs)
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/edx/app/edxapp/edx-platform/common/djangoapps/util/views.py", line 188, in inner
response = view_func(request, *args, **kwargs)
File "/edx/app/edxapp/edx-platform/lms/djangoapps/lti_provider/views.py", line 91, in lti_launch
authenticate_lti_user(request, params['user_id'], lti_consumer)
File "/edx/app/edxapp/edx-platform/lms/djangoapps/lti_provider/users.py", line 37, in authenticate_lti_user
lti_user = create_lti_user(lti_user_id, lti_consumer)
File "/edx/app/edxapp/edx-platform/lms/djangoapps/lti_provider/users.py", line 59, in create_lti_user
edx_user = User.objects.create_user(
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/contrib/auth/models.py", line 152, in create_user
return self._create_user(username, email, password, **extra_fields)
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/contrib/auth/models.py", line 146, in _create_user
user.save(using=self._db)
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/contrib/auth/base_user.py", line 67, in save
super().save(*args, **kwargs)
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 726, in save
self.save_base(using=using, force_insert=force_insert,
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 774, in save_base
post_save.send(
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 180, in send
return [
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 181, in <listcomp>
(receiver, receiver(signal=self, sender=sender, **named))
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/enterprise/decorators.py", line 88, in wrapper
signal_handler(*args, **kwargs)
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/enterprise/signals.py", line 68, in handle_user_post_save
for pending_ecu in pending_ecus:
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/query.py", line 280, in __iter__
self._fetch_all()
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/query.py", line 1324, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/query.py", line 51, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1175, in execute_sql
cursor.execute(sql, params)
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 66, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 78, in _execute
self.db.validate_no_broken_transaction()
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/base/base.py", line 447, in validate_no_broken_transaction
raise TransactionManagementError(
django.db.transaction.TransactionManagementError: An error occurred in the current transaction. You can't execute queries until the end of the 'atomic' block. |
bc7f32b to
75eb0d7
Compare
|
Thanks for your review @Agrendalath ! I've rebased and squashed my commits, so this should be ready to merge once tests pass again.
The sandbox for https://github.com/edx/edx-platform/pull/29260 is the LTI provider for the LTI problem used here. I rebased that PR on latest |
|
@ormsbee Are you ok with @Agrendalath merging this PR (and https://github.com/edx/edx-platform/pull/29312), or would you rather deploy them on your timeline? I don't want to mess up anyone's holiday :) But it would be great to get these in soon. |
Deprecates these ModuleSystem attributes in favor of the user service: * user_location * get_real_user * get_user_role Related changes: * Stores the user location into DjangoXBlockUserService's optional attribute as request_country_code * Uses the student model's user_by_anonymous_it to fetch the (cached) real user * Updates affected tests
from code and tests.
6292791 to
e3ed12d
Compare
|
Your PR has finished running tests. There were no failures. |
|
@jristau1984, I'm merging this, as discussed on Slack. |
|
@pomegranited 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
|
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
|
EdX Release Notice: This PR has been deployed to the production environment. |
Description
Builds on the shim added by https://github.com/edx/edx-platform/pull/29190 to deprecate these remaining user-related
ModuleSystemattributes in favour of the user service:These properties are only used by a few XBlocks: LTI, LTI2.0, Video (CDN/branding), edxnotes
This change is only a refactoring, and should not affect Learners, Course Authors, or anyone else using edx-platform.
Supporting information
Testing instructions
Basic regression testing can be run on the sandbox.
To test the LTI 2.0 (consumer) component:
Note that the LTI URL points to a problem block on a different sandbox server's Demo course.
To test edx-notes:
To test the video CDN/branding:
You need to view the site from one of the CDN-configured countries, currently Australia (
AU), Pakistan (PK), or Poland (PL).Note: I don't really have a valid CDN to use here, but enabling a CDN allows a configured branding logo to be shown under the video, so this at least is visible and can be tested.
Note that the configured branding logo is shown under the video when you view this content from one of the configured countries.
Deadline
None
Author Notes & Concerns
Setup for user location/CDN testing:
EDXAPP_VIDEO_CDN_URLSor/edx/etc/lms.ymlto provide a CDN URL for a given country code (doesn't matter what the URL is), eg.{ "AU": { "url": "https://www.sa.gov.au", "logo_src": "https://www.sa.gov.au/__data/assets/image/0012/251013/sa-logo.png", "logo_tag": "Logo for South Australia" } }