98 Commits

Author SHA1 Message Date
Kyle McCormick
834cb9482d refactor: rename ModuleStore runtimes now that XModules are gone (#35523)
* Consolidates and renames the runtime used as a base for all the others:
  * Before: `xmodule.x_module:DescriptorSystem` and
            `xmodule.mako_block:MakoDescriptorSystem`.
  * After:  `xmodule.x_module:ModuleStoreRuntime`.

* Co-locates and renames the runtimes for importing course OLX:
  * Before: `xmodule.x_module:XMLParsingSystem` and
            `xmodule.modulestore.xml:ImportSystem`.
  * After:  `xmodule.modulestore.xml:XMLParsingModuleStoreRuntime` and
            `xmodule.modulestore.xml:XMLImportingModuleStoreRuntime`.
  * Note: I would have liked to consolidate these, but it would have
          involved nontrivial test refactoring.

* Renames the stub Old Mongo runtime:
  * Before: `xmodule.modulestore.mongo.base:CachingDescriptorSystem`.
  * After: `xmodule.modulestore.mongo.base:OldModuleStoreRuntime`.

* Renames the Split Mongo runtime, the which is what runs courses in LMS and CMS:
  * Before: `xmodule.modulestore.split_mongo.caching_descriptor_system:CachingDescriptorSystem`.
  * After: `xmodule.modulestore.split_mongo.runtime:SplitModuleStoreRuntime`.

* Renames some of the dummy runtimes used only in unit tests.
2025-10-29 15:46:07 -04:00
Daniel Valenzuela
eadf5e2d79 fix: render library assets named xblock-
The previous pattern for matching was too broad and would break
the rendering of assets that were prefixed with "xblock".
2024-12-09 10:05:01 -05:00
Agrendalath
71fee4a4a0 feat!: remove block handling from runtime initialization of ReplaceURLService
BREAKING CHANGE: This removes the following deprecated shims from the runtime:
`replace_urls`, `replace_course_urls`, `replace_jump_to_id_urls`. XBlocks need
to use the `replace_urls` service instead.
2023-06-21 20:28:24 +02:00
0x29a
83396ffb07 refactor: convert course_module term to course_block 2022-12-19 17:48:49 +01:00
Sagirov Eugeniy
8f88422c4a test: prepare tests for removing support for children in Old Mongo 2022-10-28 11:43:20 -04:00
Kaustav Banerjee
c48c655998 refactor: deprecates replace url related properties from ModuleSystem
Deprecates the following attributes from ModuleSystem:
 * replace_urls
 * replace_course_urls
 * replace_jump_to_id_urls

A new ReplaceURLService is created as replacement with a unified replace_urls method
2022-03-14 09:35:41 -04:00
Jawayria
ce26c8476d chore: Applied lint-amnesty on common/djangoapps 2021-12-13 20:53:36 +05:00
M. Zulqarnain
ba75bb6569 feat: django codemods changes for common folder (#28775) 2021-10-21 13:52:19 +05:00
Awais Qureshi
8a4c0b74e6 chore: Django3 has removed python_2_unicode_compatible.
Execute the codemodes.
2021-07-26 23:56:45 +05:00
Kyle McCormick
9aefd6f986 style: django-not-configured is not a sensible lint-amnesty value (#26862)
django-not-configured is an error raised by pylint (with
the pylint-django plugin) when it's not correctly configured.

We should not be applying lint amnesty for such a violation.
2021-03-05 08:11:58 -05:00
Usman Khalid
dd96a2aa72 Convert Course, Section and Sequence XModules to XBlocks. (#25965) 2021-03-02 10:29:33 -05:00
Awais Qureshi
4db9cdfc66 BOM-2375
Run Pyupgrade on static replace folder.
2021-02-22 21:55:26 +05:00
Awais Qureshi
4f6a6b5776 BOM-2375
Run Pyupgrade on static replace folder.
2021-02-22 21:41:54 +05:00
Aarif
7dfd6edd23 replaced unittest assertions pytest assertions (#26524) 2021-02-18 18:08:23 +05:00
Jawayria
edfced071d Resolved quality errors 2021-02-02 19:19:33 +05:00
Jawayria
4dad2ab406 Applied pylint-amnesty to static_replace 2021-02-02 19:19:33 +05:00
Ned Batchelder
9a72148310 Squash a regex warning
warnings.py:109 - /edx/app/edxapp/edx-platform/common/djangoapps/static_replace/__init__.py:76: DeprecationWarning: Flags not at the start of the expression '\n        (?x)       ' (truncated)
2020-11-16 10:21:49 -05:00
Kyle McCormick
151bd13666 Use full names for common.djangoapps imports; warn when using old style (#25477)
* Generate common/djangoapps import shims for LMS
* Generate common/djangoapps import shims for Studio
* Stop appending project root to sys.path
* Stop appending common/djangoapps to sys.path
* Import from common.djangoapps.course_action_state instead of course_action_state
* Import from common.djangoapps.course_modes instead of course_modes
* Import from common.djangoapps.database_fixups instead of database_fixups
* Import from common.djangoapps.edxmako instead of edxmako
* Import from common.djangoapps.entitlements instead of entitlements
* Import from common.djangoapps.pipline_mako instead of pipeline_mako
* Import from common.djangoapps.static_replace instead of static_replace
* Import from common.djangoapps.student instead of student
* Import from common.djangoapps.terrain instead of terrain
* Import from common.djangoapps.third_party_auth instead of third_party_auth
* Import from common.djangoapps.track instead of track
* Import from common.djangoapps.util instead of util
* Import from common.djangoapps.xblock_django instead of xblock_django
* Add empty common/djangoapps/__init__.py to fix pytest collection
* Fix pylint formatting violations
* Exclude import_shims/ directory tree from linting
2020-11-10 07:02:01 -05:00
Aarif
98af9ce418 remove useless-supression warnings 2020-05-01 19:42:15 +05:00
Aarif
6ee2089077 fixed warnings for wrong-import-order 2020-04-08 23:43:06 +05:00
Feanil Patel
6e3fe00fff Fix all E303 pep8 errors. 2019-12-30 12:25:38 -05:00
Feanil Patel
9cf2f9f298 Run 2to3 -f future . -w
This will remove imports from __future__ that are no longer needed.

https://docs.python.org/3.5/library/2to3.html#2to3fixer-future
2019-12-30 10:35:30 -05:00
Manjinder Singh
7f3045cf75 BOM-933: Fix type mismatches in various migrations 4 (#22146)
* fix type mismatch in course_goals  migrations

* fix type mismatch in experiments  migrations

* fix type mismatch in xblock_django  migrations

* fix type mismatch in catalog  migrations

* fix type mismatch in static_replace  migrations

* fix type mismatch in bulk_email  migrations

* fix type mismatch in course_overviews migrations
2019-10-24 13:47:51 -04:00
Ayub khan
5c47a3b425 BOM Project
Updated __unicode__ to __str__
2019-09-25 18:31:54 +05:00
Feanil Patel
220759ee1d Remove unnecessary print statements. 2019-09-18 11:52:15 -04:00
Feanil Patel
ea49975a73 BOM-617 Fix test_static_replace test failures.
Update the tests around static_file code to use byte streams instead of
string streams for generating static content.  This is a fix to get
these tests passing on python 3.
2019-09-18 11:51:49 -04:00
aarif
61800c619f replaced StringIO imports with import from six
replaced cStringIO and StringIO imports with import from six

fixed StringIO imports

fixed StringIO imports

fixed XSS python-wrap warning
2019-08-08 00:09:16 +05:00
Amit
9e2397a60a INCR-137: Run python-modernize at common/djangoapps/static_replace (#20481) 2019-05-09 09:36:45 -04:00
cclauss
9a0c995885 ur'strings' are syntax errors in Python 3 2019-03-17 13:56:02 +01:00
Julia Eskew
368f221f0a Initial start on annotations. 2019-02-19 11:24:21 -05:00
Usman Khalid
ca910b6f27 Collect static asset URLs from static_replace.replace_static_urls
Allows users to keep track of which static asset URLs were found in given text,
and what they were replaced from/to.
2018-09-11 11:16:33 +09:30
Jeremy Bowman
bcaec3c5bb TE-2525 nose.tools removal part 1/2 2018-08-07 08:30:12 -04:00
Jeremy Bowman
d3d6272d8f PLAT-1873 to_deprecated_string() cleanup part 1 2018-01-08 13:51:42 -05:00
bmedx
29514cc2d2 Update clear_collectstatic_cache management command to Django 1.11 spec 2017-12-04 13:05:33 -05:00
John Eskew
02f26f55ce Remove unused imports. Push model imports down into relevant methods.
Mock out the static_replace modules in the proper location.
2017-10-05 11:12:52 -04:00
Jeremy Bowman
97f5fe035b Fixes for pytest database usage 2017-09-06 13:15:34 -04:00
cahrens
6f71706b17 Remove SlashSeparatedCourseKey from tests. 2017-08-07 14:49:30 -04:00
Andy Armstrong
93235d118d Reorder imports using isort (except lms and cms) 2017-05-30 16:04:54 -04:00
Ned Batchelder
4a568476fd Remove a number of unneeded super()-delegation methods 2017-04-27 14:12:56 -04:00
Toby Lawrence
8ab62b5b99 [PERF-351] Account for settings.STATIC_URL in XBlock resource URLs when
rewriting them.

In PERF-341, we adjusted the static_replace middleware to try and
exclude static XBlock resource URLs from being interpreted as the marker
URLs used to signify course assets in course content.  Since they both
started with /static, this could, and did, cause issues where linking
directly to the assets of an XBlock within, say, one of its templates,
would lead to that link being rewritten and ultimately being incorrect.
The fix attempted to see if the link started with the prefix that all
static XBlock resource URLs start, and if so, it returned them
unmodified.

We incorrectly assumed that our testing captured all cases, and since
we're here, we know that this was wrong.  We weren't accounting for cases
when the URLs being generated had the STATIC_URL configuration value
prefixed -- https://example.com/static/xblock/.... -- and so our direct
check of seeing if such a URL started with "/static/xblock" would always
fail, leading to the erroneous rewriting and nonsensical output.

This fix checks if the link either starts with the prefix OR if it
starts with the STATIC_URL value and contains the prefix overall.  There
is a small overlap between the STATIC_URL and the prefix we check for,
so an inconsistency could arise down the line if we changed our
STATIC_URL to use a difference base directory, but our tests will at
least catch the issue now.
2016-07-12 22:33:11 -04:00
Toby Lawrence
f15533dc8f [PERF-346] Add a second version component to versioned course asset URLs
This version component reflects the "version" of the StaticContent
objects which we cache server-side.  If the layout of those objects
changes between releases, errors occur when loading them from cache.

By using a separate version value, which can be incremented on its own
after a change has been made to the StaticContent class, we can avoid
loading older cached content and in turn take advantage of these changes
faster, without needing to intervene operationally.
2016-07-10 19:20:20 -04:00
Toby Lawrence
faaa30c02d [PERF-341] Fix up to not rewrite XBlock resource URLs.
For XBlocks that used their static.public resources in the rendered
output -- for example, a link to a bundled image -- those URLs would be
treated as course assets using the '/static/' prefix trick, and thus,
rewritten.  These rewritten URLs don't work because they aren't course
assets.

When course content authors are creating their courses, we provide them
a special shorthand way of writing URLs that reference assets they have
uploaded to the course. If they uploaded a file called my-lil-pony.mp4,
and they wanted to provide a link to it when users view the course, they
would use /static/my-lil-pony.mp4. This special prefix -- /static/ --
signals to the static_replace middleware that it's a course asset and we
should write /static/my-lil-pony.mp4 to a URL that properly references
the asset based on the course ID, and things like the configured asset
CDN, etc.

Thus, the URL /static/my-lil-pony.mp4 gets turned into something like:

/assets/courseware/<md5hash>/asset-v1:edX+Demo+2016T1+type@asset+block/my-lil-pony.mp4

when viewed in the courseware.

Now, we also serve actual static assets from a prefix of /static/. This
is stuff like our JavaScript and CSS, and the JS/CSS/etc of
XBlocks/XModules. These paths look like:

/static/js/lms-main_vendor.46d6a8c02600.js

or

/static/xblock/resources/xmodule.vertical_block/public/js/vertical_student_view.43727a907769.js

Normally, these paths are caught by nginx, before they reach the LMS,
and are served straight from the filesystem. However, if you were to
have one of these paths in your course content, the static_replace
middleware would see the /static/ at the front and immediately think
it's a course asset, and would dutifully rewrite the URL to something
like:

/assets/courseware/<md5hash>/asset-v1:edX+Demo+2016T1+type@asset+block/static_xblock_resources_xmodule.vertical_block_public_js_vertical_student_view.43727a907769.js

which is not a course asset, and so it will always fail to load.

Long story short, I changed the static_replace middleware to
specifically check to see if the path being matched starts with
/static/xblock/, and if so, it keeps the original instead of rewriting
it.
2016-06-23 14:47:02 -04:00
Toby Lawrence
849ebc5f22 [PERF-325] Add versioned course asset URLs when canonicalizing asset paths. 2016-06-15 08:04:52 -04:00
John Eskew
84da6e4c1f Address DaveO's comments. 2016-04-21 11:56:23 -04:00
John Eskew
8a9845c26e Remove ModuleStoreEnum.Type.xml 2016-04-12 11:53:51 -04:00
Toby Lawrence
b03ee49a82 Fix up the excluded extensions bit.
This adds the missing admin class, and registration of it, required to
actually change the value of the excluded extensions configuration.
2016-02-05 12:14:15 -05:00
Toby Lawrence
e57d1a2006 Add leading period so we don't get partial matches on extensions. 2016-02-02 10:07:13 -05:00
Toby Lawrence
1183f6cec9 Add the ability to exclude files from URL canonicalization.
To be able to more easily deal with same-origin issues, due to some course assets being loaded in an iframe, we're adding the ability to specify file extensions that should be excluded from URL canonicalization.  The default value is simply 'html', which means we won't rewrite asset links that point to files ending in .html.  Thus, they'll be loaded from the same origin as the parent page, and voila, no SOP issues.
2016-02-01 21:44:35 -05:00
Toby Lawrence
fb984206cf Add the migrations necessary for asset base URL support. 2016-01-08 13:16:50 -05:00
Toby Lawrence
77343df0d9 [PERF-224] Support to serve static assets from a CDN.
A base URL can now be configured which is, potentially, prepended to an
asset URL.  This allows a CDN, or caching server, to front static asset
requests, taking load off of the contentstore and speeding up page load
times.

Asset URL generation respects locked vs unlocked assets, and will not
generate links to locked assets that would traverse a CDN (even though
the authorization component of the contentserver middleware wouldn't
allow those links to work anyways).
2016-01-05 10:24:44 -05:00