Commit Graph

90 Commits

Author SHA1 Message Date
Tim McCormack
83f6e560b7 fix: Add code_owner decorator to remaining Celery tasks (#31762)
This will ensure that errors raised by these tasks will alert the right
team. `send_course_enrollment_email` is the one I set out to fix, but I
discovered a few others.

I located tasks that were missing decorators by running the following
search and visually inspecting the results, although semgrep might be able
to do better:

```
ack '^@.*task|^@set_code_owner_attribute' cms lms common openedx xmodule --ignore-dir=tests --python
```

Also, add more detailed explanation of why a couple of tasks can't use the
decorator. This should only be an issue on tasks inheriting from
UserTaskMixin, which in practice is just CourseExportTask and
CourseImportTask (and the apparently unused EnrollmentReadTask and
EnrollmentWriteTask), via UserTask.
2023-02-15 18:20:50 +00:00
Kyle McCormick
b5fd4cc55f fix: allow content libraries to be created through Django admin (#31719)
Previously, CMS Django admin would demand that at least one
LTIConfig be associated with the new library. This is not
necessary, but Django thought it was, because the `blank`
flag was not enabled on the ContentLibrary model's
`authored_lti_config` many-to-many field.

This should not affect the experimental blockstore-based
library authoring frontend, which already allows libraries
to be created without any authorized_lti_configs.

This will not affect the existing modulestore-based
library authoring frontend, since it doesn't even use
any of the models in question.

A migration is included with this commit, but it should NOT
change MySQL schema, since `blank` is a Django-level validation
flag.
2023-02-07 08:17:01 -05:00
Jillian
9f5c78e81e revert: temp: let XBlock API users optionally use LabXchange block types (#31315)
when fetching block metadata and rendering blocks while maintaining the
original usage IDs/OLX.

Reverts ef8f841ac2
2023-01-11 11:19:58 -08:00
Usama Sadiq
4734f9f16e fix: bump pylint version (#31084) 2022-10-27 12:19:09 +05:00
Sarina Canelake
4a2f231302 fix: fix github url strings (org edx -> openedx) 2022-09-15 14:52:28 -04:00
Jillian Vogel
5688ad0ba7 fix: call blockstore APIs in atomic transactions. [BD-14] (#30456)
* fix: call blockstore APIs in atomic transactions.

To ensure database integry when using the blockstore APIs, the Content
Library views which invoke blockstore API methods are wrapped in
database transactions.

* fix: assert create_library is called inside an atomic transaction block
2022-06-14 09:10:08 -07:00
Jillian Vogel
d0935d467c fix: fixes bug with HTML blocks in studio_view
Rendering asset URLs requires HTML blocks to be associated with a course key.
This change allows HTML blocks to be associated with libraries and still
render without error.
2022-04-21 09:39:59 +01:00
Jillian Vogel
732d8cb337 fix: use mako prefix lms. when XBlock runtime renders in Studio/authoring MFE
When the XBlock runtime is used in Studio/authoring mode, it needs to
use the template path prefix "lms." in order to locate the block
templates. (In LMS view, no prefix is required.)

Fixes bug introduced by https://github.com/openedx/edx-platform/pull/29354
and removes template workaround added by
https://github.com/openedx/edx-platform/pull/29517 (see Author Notes & Concerns)
2022-04-21 09:39:59 +01:00
Jillian Vogel
8b77638bf0 test: refactors blockstore integration tests to run as unit tests.
Tests which @requires_blockstore (i.e. the Blockstore service) have
been made to run as a unit test using the installed Blockstore app, and
will be run by the platform CI.

The Blockstore service tests can still be run manually by setting
EDXAPP_RUN_BLOCKSTORE_TESTS=1

Related fixes:

* adds blockstore bundle storage settings
* let the studio devstack and test servers serve static files from
  the /media URL This allows the blockstore/content libraries API to
  serve blockstore assets in dev.
* Wrap ContentLibrary creation in an atomic transaction, so that if it
 fails, the related bundle can be deleted directly from the database
  during the exception handler. (Previously, we called a REST API which
  deleted it as part of a separate service.)
2022-04-21 09:39:59 +01:00
Jillian Vogel
7d81c3e671 test: minor fixes to requires_blockstore tests
These tests aren't run as part of the CI, and so have been failing for
an unknown time.
2022-04-21 09:39:59 +01:00
Jillian Vogel
cfd53aff70 refactor: installs blockstore into edx-platform
* adds blockstore as a requirement and an installed app, with
  configurable bundle storage settings.
* adds waffle switch and setting to allow use of blockstore's python API
  instead of REST API in live testservers and in production.
* adds database router which, when a `blockstore` DATABASE connection is
  configured, allows the platform to use the blockstore service's
  database instead of the default edxapp database.
* replaces blockstore_api exceptions and models with blockstore.app.api classes
* minor fixes to the blockstore_api to make the Blockstore REST API
  return data packaged the same as the Blockstore Python API.
2022-04-21 09:39:54 +01:00
Mohammad Ahtasham ul Hassan
4260bd2af5 fix: fixed django40 warnings (#29655)
* fix: fixed django40 warnings
* fix: fix quality failures

Co-authored-by: UsamaSadiq <usama.sadiq@arbisoft.com>
2022-03-02 16:08:04 +05:00
XnpioChV
726842b39a feat: InvalidKeyError message changed to NotFound 404 message 2022-01-26 19:28:14 -05:00
Tim McCormack
7fc20e69f4 feat: Allow safe-session exemption even for exceptions
Change `mark_user_change_as_expected` to no longer take the response object
and instead convey the expected-change information via RequestCache.
This requires edx-django-utils 4.4.2, which fixes the bug where
RequestCache was cleared in the exception phase.

Also, no longer mark `ENFORCE_SAFE_SESSIONS` toggle as
temporary. We'll want it as an opt-out.

I was tempted to take this opportunity to move any existing
`mark_user_change_as_expected` calls to be closer to where the actual
change request.user occurs, reducing risk of both false positives and false
negatives, but it would be better to do that one at a time in case a move
breaks something. (Ideally it would be called right after any
`django.contrib.auth` `login` or `logout` call; previously, we were
constrained by having to make the call after a response object had been
created.) These changes can be made later if it becomes necessary.
2022-01-25 16:03:54 +00:00
Jillian Vogel
ef8f841ac2 temp: let XBlock API users optionally use LabXchange block types
when fetching block metadata and rendering blocks while maintaining the
original usage IDs/OLX.

This change is marked temporary because LabXchange need it during the
transition to a custom runtime, but it's not really useful to anyone
else. We will revert this change with a future PR.
2022-01-20 10:35:59 +10:30
Jawayria
3adfe1de97 chore: Applied lint-amnesty on openedx/core/djangoapps 2021-12-06 14:05:13 +05:00
Ned Batchelder
d9dd10dc97 style: code cleanups from Steven Burch (#29292)
* chore: update deprecated import from collections

* chore: remove outdated imports from markdown library

as it hasn't been supported since 2.0.3 and we're on 3.x.
This was deprecated at least as early as 2012!

* docs: add docstring and remove lint-amnesty to markdown plugin

* chore: remove deprecated etree import

* style: remove unnecessary-comprehension for sets

* style: resolve a number of amnestied pylint complaints

Co-authored-by: stvn <stvn@mit.edu>
2021-11-10 07:11:57 -08:00
M. Zulqarnain
834dabb399 feat: New codemods on OpenedX 2 (#28777) 2021-10-28 16:45:53 +05:00
M. Zulqarnain
39b91154fb feat: New codemods on OpenedX 1 (#28776) 2021-10-27 13:07:36 +05:00
Usama Sadiq
9ee8df0980 fix: Remove pylint constraint and fix warnings (#28646) 2021-10-20 23:00:13 +05:00
Feanil Patel
f9a28d1654 fix: Mark user change as expected in LTIToolLaunchView.post
The lti user gets authenticated and logged in as a part of the LTI View
Post.  This results in the request user changing during the request.  We
mark it here so that it does not produce a false alarm in our
SafeSessions middleware.
2021-10-15 10:10:39 -04:00
João Victor Martins
1fc33070c3 docs: Add ADR for LTI tools in content libraries 2021-10-05 10:11:06 -07:00
sarina
0c74d347f7 fix: abstract edX-specific strings 2021-09-19 14:01:20 -04:00
Samuel Walladge
c3e4976d4d fix: crash in retrieving blockstore bundle links
If the bundle is deleted, `blockstore_cache.get_bundle_version_number(bundle_uuid)`
will raise an error.
Catch this error in `get_bundle_links`,
so the REST api doesn't crash with a 500 error when a linked bundle is deleted.
2021-09-15 10:13:07 -07:00
Jawayria
9f63dc16a4 Merge pull request #28608 from edx/jawayria/bom-2767
chore: Removed django.utils.lru_cache
2021-09-03 19:37:39 +05:00
J. Victor Martins
14e2f29516 feat: Make content libraries an LTI 1.3 tool
Offers blockstore-based content through content libraries acting as an
LTI 1.3 tool:

- Content Library support LTI 1.3 launches offering blockstore-based
  content through resource links.

- Content Library support LTI 1.3. AGS, allowing gradebook updates from
  graded assignments.
2021-09-01 11:56:51 -07:00
Jawayria
389bc0d35d chore: Remove django.utils.lru_cache 2021-09-01 13:53:33 +05:00
João Victor Martins
eec7243141 feat: Add API and command to import blocks from courseware
The functionality is exposed by (a.) A RESTful API, and (b.) A
management command. Both are added to Content Libraries V2. They allow
block importing from a local modulestore instance. Additionally, the
command line supports importing blocks from a remote platform instance
through API calls.

Additionally, fixes were added to parts of the system where needed to
properly export blocks to Content Libraries.
2021-08-17 09:35:34 -07:00
Raul Gallegos
24f9568c4e fix: no library context when not found (#27493)
FAL-1848 (OpenCraft)
2021-05-28 13:01:35 -04:00
Usama Sadiq
13ef0c7762 refactor: pyupgrade second iteration (#27462) 2021-05-11 11:25:22 +05:00
Usama Sadiq
2b55959a8e refactor: apply lint-amnesty on existing violations 2021-04-20 23:51:31 +05:00
Jawayria
df06d1312d refactor: Removed unused imports
Removed unused imports from openedx/core/djangoapps/{content_libraries, coursegraph,courseware_api, crawlers, credentials, credit}
2021-04-06 17:07:13 +05:00
Raul Gallegos
0d691623af fix: setting correct i18n_service to blockstore runtime
xblock information was not being translated correctly when using the blockstore runtime. This makes the i18n_service block-specific so it can look for additional i18n files that can be installed with the XBlock
2021-03-31 14:19:01 -05:00
M. Zulqarnain
5d2b0e8346 refactor: pyupgrade in content_libraries and contentserver apps (#26892) 2021-03-17 17:28:23 +05:00
Aarif
ba16e05899 replaced unittest assertions pytest assertions (#26564) 2021-02-19 16:04:32 +05:00
Fox Piacenti
c840e6f9bb Update Library v2 Indexes to work with ElasticSearch 7. Repair blockstore integration tests. (#26230) 2021-02-08 11:55:47 -05:00
M. Zulqarnain
047a5f5f19 BOM-2319 : Pylint amnesty in openedx content apps (#26347)
* pylint amnesty in openedx content apps

Co-authored-by: Jawayria <jawayriahashmi@gmail.com>
2021-02-08 15:51:22 +05:00
Kyle McCormick
d3ef43047e Fix KeyError in v2 Libraries API (#25753) 2020-12-03 09:49:27 -05:00
Kyle McCormick
4dda73d797 [BD-14] Migrate all environments to use database-backed organizations (#25153)
* Install `organizations` app into LMS and Studio non-optionally.
* Add toggle `ORGANIZATIONS_AUTOCREATE` to Studio.
* Remove the `FEATURES["ORGANIZATIONS_APP"]` toggle.
* Use the new `organizations.api.ensure_organization` function to
  either validate or get-or-create organizations, depending
  on the value of `ORGANIZATIONS_AUTOCREATE`,
  when creating course runs and V2 content libraries.
  We'll soon use it for V1 content libraries as well.
* Remove the `util.organizations_helpers` wrapper layer
  that had to exist because `organizations` was an optional app.
* Add `.get_library_keys()` method to the Split modulestore.
* Add Studio management command for backfilling organizations tables
  (`backfill_orgs_and_org_courses`).

For full details, see
https://github.com/edx/edx-organizations/blob/master/docs/decisions/0001-phase-in-db-backed-organizations-to-all.rst

TNL-7646
2020-12-02 13:58:40 -05:00
0x29a
c83a505635 Replace 'multi_db = True' with 'databases = {alias for alias in connections}'
Check this ticket for details: https://code.djangoproject.com/ticket/29513
2020-11-19 14:06:51 +01: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
Fox Piacenti
c181ed57b1 Add ability to filter library blocks by type. Prevent changing types with unpublished changes. (#25368)
Adds the ability to filter v2 library blocks by block type. Also prevents switching the library type when there are unpublished changes/deletes, as this may cause consistency errors.
2020-10-23 10:50:28 -04:00
Fox Piacenti
73adc729d9 Add a license field to libraries. (#25007) 2020-10-05 11:45:36 -04:00
Robert Raposa
f65bf0ed9d Merge pull request #24794 from regisb/regisb/settings-docs
[BD-21] Document settings with annotations
2020-10-01 11:53:39 -04:00
Usman Khalid
571b1f4d17 Enable the i18n service for the Blockstore service. 2020-09-28 09:34:36 -07:00
Fox Piacenti
2c15bbba2d Add type field/constraint to to libraries v2. (#24861) 2020-09-28 10:58:27 -04:00
Régis Behmo
e555d8a571 [BD-21] Document settings with annotations
We introduce the documentation of django settings via code annotations.
This will allow us to produce a human-readable documentatio of all Open
edX settings.
2020-09-28 12:44:36 +02:00
Fox Piacenti
7bc10e0464 Adjustments to library user access API endpoints required by frontend needs. (#24919) 2020-09-25 09:33:32 -04:00
Sid Verma
72b4afe465 Add ADR for content library indexes 2020-09-18 10:25:59 -04:00
Sid Verma
67f3c0343f Simplify and optimize index searching 2020-09-18 10:25:59 -04:00