Commit Graph

546 Commits

Author SHA1 Message Date
Usama Sadiq
956a28996a fix: refactor index_together to indexes for Django 5.2 support (#36693) 2025-05-12 11:46:47 +05:00
Braden MacDonald
2e91a05112 fix: Bugs with "Publish All Changes" in Library [FC-0083] (#36640)
* fix: "[created] received a naive datetime"
* fix: leaky "isolation" of events was causing test failures
* fix: make lib events more specific, emit them async, handle hierarchy correctly
* chore: bump openedx-events to 10.2.0 for new library PUBLISHED events
2025-05-08 11:57:07 -07:00
Jillian
5b3caa93e2 feat: store content.child_usage_keys in Container search document [FC-0083] (#36528)
* feat: store content.child_usage_keys in Container search document
  Stores the draft children + published children (if applicable)

Related fixes:
* fix: lib_api.get_container does not take a "user" arg
* refactor: fetch_customizable_fields_from_container does not need a "user" arg
* refactor: moves tags_count into LibraryItem
   because anything that appears in a library may be tagged.
* refactor: remove get_container_from_key from public API
   API users must use get_container and ContainerMetadata.
* refactor: made set_library_item_collections take an entity_key string instead of
  a PublishableEntity instance, so we don't need to fetch a Container object to call it.
* refactor: changed ContainerLink.update_or_create to take the container PK
  instead of a Container object, since this is enough.
  Added container_pk to ContainerMetadata to support this.
2025-05-02 10:47:25 +09:30
Navin Karkera
c2d9e40be4 refactor: update sync model helper function docs and minor cleanup (#36599)
* refactor: update sync model helper function docs

Adds some comments to explain certain confusing sections

* refactor: sync library content method

* feat: use edited_on block field

* test: modified field in course block index

* fix: extract uncommon methods to child class from base
2025-04-30 13:40:52 -07:00
Braden MacDonald
867e246606 chore: bump opaque-keys to v3, update content libraries key usages (#36588)
See https://github.com/openedx/opaque-keys/pull/379
2025-04-23 22:03:01 +00:00
Chris Chávez
f5e0500854 feat: Add new publish field on container search document (#36551)
* Added publish_display_name and last_published on container search document.
* This change is used in feat: Add unit from library in course [FC-0083] frontend-app-authoring#1829 to show only published units in the unit picker, also to show the published_display_name in the picker, and avoid empty titles.
* Which edX user roles will this change impact? "Developer".
2025-04-22 16:58:57 +00:00
Rômulo Penido
1047ed4d5b feat: collections support for containers [FC-0083] (#36504)
Adds support for adding Containers to Collections.
2025-04-15 13:12:51 -05:00
Jillian
11bab7d2ed refactor!: use LibraryCollectionLocator and LibraryContainerLocator [FC-0083] (#36476)
efactors the content_libraries.api to use LibraryCollectionLocator and LibraryContainerLocator keys, instead of passing separate LibraryUsageKeyV2 keys along with the collection/container locators.

Renames misleading uses of collection_usage_key to collection_locator, including in the content_libraries.api and content.search.api method names and parameters.

This change impacts Developers, but should not affect end users.

This refactoring seems reasonable to do without going through deprecation, given the minimal use of these APIs.
2025-04-11 10:21:58 -05:00
Chris Chávez
dc4144ec95 feat: add restore container API, delete index when deleting container (#36464) 2025-04-10 15:15:53 -07:00
Muhammad Umar Khan
b9556211be chore: fix cache content size calculation error (#36511)
Co-authored-by: M Umar Khan <umar.khan@A006-01609.local>
2025-04-10 15:22:28 +05:00
Rômulo Penido
a0d99315ad feat: container support for tags [FC-0083] (#36484)
* feat: container tag support

* fix: fixes from review

* docs: fix typo
2025-04-10 11:14:54 +05:30
Chris Chávez
1c14c3a518 feat: Update containers in search index on components update/delete [FC-0083] (#36432)
* feat: Added get_containers_contains_component in containers api with tests

* feat: Add publish_status to containers search document

* feat: Add LIBRARY_CONTAINER_UPDATED whend deleted a component inside a container

* feat: Send LIBRARY_CONTAINER_UPDATED signal when updating component of container

* fix: Bugs sending LIBRARY_CONTAINER_UPDATED signal

* feat: Add publish_status of container as PublishStatus.Never by default

* refactor: ContentLibraryContainersTest to use update_container_children to add components

* style: Clean code after fix conflicts

* fix: Broken lint

* fix: lint
2025-04-02 18:46:41 +05:30
Navin Karkera
bcaa79cc38 feat: api for adding, removing and updating components in container (#36434)
* feat: add components to container api

* feat: remove and replace components in container api

* refactor: container childern api

* chore: fix lint issues

* temp: install openedx-learning dev branch

* feat: update publish_status and children count in index

* chore: fix mypy issues

* test: fix reindex test

* refactor: rebase and fix conflicts

* test: update test to check signals

* docs: document can_stand_alone flag

* chore: bump openedx-learning version
2025-03-31 17:40:17 +05:30
Braden MacDonald
1ca57ec129 Basic CRUD REST Endpoints for units in content libraries [FC-0083] (#36371)
* refactor: convert libraries API from attr.s to dataclass, fix types

* fix: make corresponding updates to 'search' code

* feat: use new version of openedx-learning with containers support

* temp: Use opencraft branch of opaquekeys

* refactor: Use LibraryElementKey instead of LibraryCollectionKey

* refactor: split libraries API & REST API up into smaller modules

* feat: new REST API for units in content libraries

* feat: python+REST API to get a unit

* feat: auto-generate slug/key/ID from title of units

* feat: generate search index documents for containers

* refactor: rename LibraryElementKey to LibraryItemKey

* fix: lint error

* feat: adds new units to search index on create/update

and when running reindex_studio.

Updates requirements for openedx-events and openedx-learning to support
these changes.

* fix: pylint

* fix: temp requirement

* fix: search index container events/tasks

* feat: add get_library_container_usage_key to libraries API

and use it when search indexing containers

* fix: index all containers during reindex_studio

* chore: bump openedx-events requirement

* fix: address review comments

* chore: bumps openedx-learning to 0.19.1

* fix: rename api method to library_container_locator

since container keys are locators, not usage keys

* chore: bumps opaque-keys dependency

* test: fix misnamed unit_usage_key

* feat: adds APIs to update or delete a container (#757)

* feat: adds python and REST APIs to update a container's display_name
* refactor: adds _get_container method to api to reduce code duplication
* feat: adds python and REST APIs to delete a container
* test: add container permission tests

---------

Co-authored-by: XnpioChV <xnpiochv@gmail.com>
Co-authored-by: Jillian Vogel <jill@opencraft.com>
Co-authored-by: Rômulo Penido <romulo.penido@gmail.com>
2025-03-28 18:55:04 +05:30
Muhammad Umar Khan
ae6b9c1b4a chore: add monitoring on blockstructure_size (#36424)
Co-authored-by: M Umar Khan <umar.khan@A006-01609.local>
2025-03-21 14:41:19 +05:00
Muhammad Umar Khan
4195186b04 chore: skip data caching for blockstructure content more than or equal to 2MB (#36397)
Co-authored-by: M Umar Khan <umar.khan@A006-01609.local>
2025-03-18 14:05:10 +05:00
Braden MacDonald
f700c89357 refactor: convert content libraries python API from attr.s to dataclass, fix types [FC-0083] (#36381)
* refactor: convert libraries API from attr.s to dataclass, fix types
* fix: make corresponding updates to 'search' code
2025-03-18 02:40:55 +10:30
Daniel Valenzuela
182bfc4031 feat: add publish status to library meilisearch index [FC-0076] (#36031)
Adds the publish status field to the libraries v2 meilisearch index in order to support filtering by component publish status: published, modified, never.
2025-02-05 17:30:19 +00:00
Navin Karkera
cd9b90fc21 feat: show math in plain text in library cards (#36055)
Converts mathjax equations to unicode to be rendered as plain text in library card previews
2025-01-13 13:09:47 -05:00
Kyle D. McCormick
50944e9d75 build: Very explicitly annotate a model field so that it passes mypy
This clunky yet type-safe workaround to this django-stubs issue, which
arose when we upgraded django-stubs in the previous commits:
https://github.com/typeddjango/django-stubs/issues/1802
2025-01-02 14:42:09 -05:00
Navin Karkera
971afe6095 feat: api to restore soft-deleted component [FC-0076] (#35993)
Adds API to handle restoring soft-deleted library blocks.
2024-12-13 13:17:46 -05:00
Tim McCormack
b6774f59f3 docs: Remove mention of storage_backing_for_cache flag
The Waffle switch `block_structure.storage_backing_for_cache` was removed in https://github.com/openedx/edx-platform/pull/35185 -- this is just a lingering reference in a setting comment.
2024-12-09 17:20:34 -05:00
Daniel Valenzuela
b07464ba2d feat: incremental reindex_studio management command (#35864)
This allows large instances to run an (interruptable, resumable) reindex task that can cover thousands of courses.
2024-12-06 12:30:38 -08:00
Chris Chávez
d5850c812c fix: keep library collection card component count in sync (#35734)
Fixed component counter synchronization in these cases:

* When deleting a component inside a collection.
* With the library published, when adding a new component in a collection and reverting library changes.
* With the library published, when deleting a component inside a collection and reverting library changes.

Also adds a published > num_counts field in collections in the search index.
2024-11-19 15:45:34 -05:00
Irtaza Akram
ec2a698604 cleanup references of python 2 & <3.11 (#35799)
* chore: cleanup of old python references
2024-11-15 16:58:20 +05:00
Peter Pinch
5d1566c4c2 Merge pull request #35655 from mitodl/asad/bypass-access-checks-when-populating-cache
fix: bypass access checks when populating course blocks cache
2024-11-06 12:22:25 -05:00
Brian Mesick
767e1a2c07 Merge pull request #35779 from openedx/bmtcril/pii_safelist_update
chore: Add missing PII annotations, update safelist
2024-11-06 16:27:09 +00:00
Brian Mesick
e478975105 chore: Add missing PII annotations, update safelist
PII Annotations are very out of date, this commit adds most that were
missing in edx-platform, and some additional annotations to the
safelist. It is not comprehensive, several other upstream Open edX
packages also need to be updated. It also does not include removing
annotations that have been moved upstream, or been removed entirely.
Those are separate follow-on tasks.
2024-11-05 12:58:36 -05:00
Feanil Patel
4768568b5a fixup! feat!: Drop the block_structure.storage_backing_for_cache waffle switch. 2024-11-05 10:44:17 -05:00
Feanil Patel
8741417806 docs: Cross link to wiki docs related to block structures.
Provide a link to more docs from the code in case we need more context
in the future.
2024-11-05 10:44:17 -05:00
Feanil Patel
e5f698a5a7 feat: Remove the unused StubModel class.
Now that the model backed cache is on by default, we don't need to keep
the StubModel object around.
2024-11-05 10:44:16 -05:00
Feanil Patel
e52253d3e1 test: Change call counts with model back as default.
We don't call the modulestore or update the cache here now that we are
backed by the database model.  Previously the cache would change because
the `_encode_root_cache_key` function in `BlockStructureStore` class
used the `BlockstoreBlockData.VERSION` as a part of the cache key when
the data was not being cached in a DB model.
2024-11-05 10:44:16 -05:00
Feanil Patel
9164e92465 test: Update a BlockStructureFactory test mixin.
Previously, we were not caching BlockStructures to the database when we
were adding them to the store by default.  Now that we are doing that,
the BlockStructureFactory test failed because it was taking a shortcut
that would no longer work.  It was just creating a blockstructure that
had relations but not any block information.

Now that we're always persisting updates to the database, this broke
because to persist the structure to the database, we have to look up the
block information from the block_structure which now fails.

This change updates the test mixin to add more data so that the content
can be persisted to the database successfully as a part of this test.
2024-11-05 10:44:16 -05:00
Feanil Patel
fab0267757 feat!: Drop the block_structure.storage_backing_for_cache waffle switch.
This work is part of DEPR https://github.com/openedx/public-engineering/issues/32

Now that we've removed all uses for this switch remove the decleration
as well.

BREAKING CHANGE: The `block_structure.storage_backing_for_cache` will no
longer exist and its value will be ignored. If you have this switch set
in your instance you can remove it. The backing cache is now always ON.
2024-11-05 10:44:16 -05:00
Feanil Patel
261b4985cd feat!: Drop an unnecessary function.
Remove the `enable_storage_backing_for_cache_in_request` function and
its uses in the platform.  The function is no longer needed because the
storage backing for the block_structure cache will be ON by default
moving forward.

BREAKING CHANGE: This `enable_storage_backing_for_cache_in_request`
function no longer exists and any calls to it should be removed.  The
cache it enables is now always ON.
2024-11-05 10:44:16 -05:00
Feanil Patel
57cdbfa013 test: Remove test variants that test without a cache.
Since the cache is now always on, remove test cases that test the case
when it's disabled.
2024-11-05 10:44:16 -05:00
Feanil Patel
16d440a4e9 feat: Turn ON the storage backing for cache by default.
Any places where the storage backing cache for block structures was on
conditionally previously it will be ON by default.
2024-11-05 10:44:16 -05:00
Asad Ali
65fd18bdcf refactor: revert imports 2024-10-31 23:26:23 +05:00
Asad Ali
d81c2d8be5 refactor: revert imports 2024-10-31 23:24:40 +05:00
Asad Ali
9ed41b0759 test: add tests for known and unknown user 2024-10-31 23:20:41 +05:00
Asad Ali
d9a27b6ba7 style: pylint 2024-10-31 23:20:40 +05:00
Asad Ali
cf3c10ba34 test: add tests 2024-10-31 23:20:40 +05:00
Asad Ali
1f86786b15 fix: bypass access checks when populating course blocks cache 2024-10-31 23:20:40 +05:00
Cristhian Garcia
e8cdb06410 feat!: remove all references to content library types (#35726)
At one point, we envisioned having different kinds of libraries, e.g.
a "Video" library would be distinct from a "Problem" library. Later on,
we decided on a more generalized form of Libraries, where any given
library can hold any combination of content–which would then be
organized using collections and tagging.

Due to this shift in perspective, these values haven't actually been
used for a long time. This is just getting rid of them altogether.
2024-10-25 14:16:56 -04:00
Chris Chávez
fb25a5d635 feat: Store published name and description in studio search index (#35678) 2024-10-21 12:25:49 -07:00
Navin Karkera
70df3deea6 feat: set collections for a library component [FC-0062] (#35600)
* feat: add & remove collections to component

Co-authored-by: Rômulo Penido <romulo.penido@gmail.com>
Co-authored-by: Chris Chávez <xnpiochv@gmail.com>
2024-10-15 15:11:54 +00:00
Braden MacDonald
8f47c0b274 fix: whitespace issues in some capa problem index_dictionary content (#35543) 2024-09-26 09:34:58 -07:00
Jillian
5446877a86 Soft delete collections (#35496)
* refactor: use django signals to trigger LIBRARY_COLLECTION events

* refactor: use collection usage_key as search document id

This change standardises the search document "id" to be a meilisearch ID
generated from the usage key, for all types of indexed objects.

This is important for collections so we can locate the collection
document in the search index solely from the data provided by the
LIBRARY_COLLECTION_DELETED event (library_key + collection_key), even if
the collection has been deleted from the database.

* refactor: avoid fetching more data than we have to.

* get_library_collection_usage_key and
  searchable_doc_tags_for_collection do not need a Collection object;
  the usage key can be created from the library_key and collection_key.

* updated searchable_doc_for_collection to require the parts of the
  collection usage key + an optional collection. This allows us to
  identify the collection's search document from its usage key without
  requiring an existing Collection object (in case it's been deleted).
  Also removes the edge case for indexing Collections not associated
  with a ContentLibrary -- this won't ever really happen.

* feat: remove soft- and hard-deleted collections from search index

* feat: adds library_component_usage_key to content_libraries.api

* refactor: send CONTENT_OBJECT_ASSOCIATON_CHANGED on django model signals

so that added/removed collections are removed/re-added to component documents.

Special case: When a collection is soft-deleted/restored, we detect this
in the search index and update the collection's component documents
directly, without a CONTENT_OBJECT_ASSOCIATON_CHANGED signal.


* chore: bumps openedx-learning to 0.13.0
2024-09-25 13:29:18 -05:00
Navin Karkera
c71414a247 feat: add block_id field to filterable attributes of meilisearch (#35493) 2024-09-20 12:12:41 -05:00
Braden MacDonald
00632d9cae feat: When editing a v2 library xblock, update search index synchronously (#35495) 2024-09-18 10:06:36 -07:00