Skip to content
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

propagate override #39

Merged
merged 11 commits into from
Jan 8, 2024
Merged

propagate override #39

merged 11 commits into from
Jan 8, 2024

Conversation

pbischof42
Copy link

Description

Describe what this pull request changes, and why. Include implications for people using this change.
Design decisions and their rationales should be documented in the repo (docstring / ADR), per
OEP-19, and can be
linked here.

Useful information to include:

  • Which edX user roles will this change impact? Common user roles are "Learner", "Course Author",
    "Developer", and "Operator".
  • Include screenshots for changes to the UI (ideally, both "before" and "after" screenshots, if applicable).
  • Provide links to the description of corresponding configuration changes. Remember to correctly annotate these
    changes.

Supporting information

Link to other information about the change, such as Jira issues, GitHub issues, or Discourse discussions.
Be sure to check they are publicly readable, or if not, repeat the information here.

Testing instructions

Please provide detailed step-by-step instructions for testing this change.

Deadline

"None" if there's no rush, or provide a specific date or event (and reason) if there is one.

Other information

Include anything else that will help reviewers and consumers understand the change.

  • Does this change depend on other changes elsewhere?
  • Any special concerns or limitations? For example: deprecations, migrations, security, or accessibility.
  • If your database migration can't be rolled back easily.

@@ -692,6 +695,9 @@ def _save_xblock(user, xblock, data=None, children_strings=None, metadata=None,
modulestore().publish(xblock.location, user.id)

# Note that children aren't being returned until we have a use case.

_propagate_library_updates(xblock.location.course_key,user.id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: spacing

Suggested change
_propagate_library_updates(xblock.location.course_key,user.id)
_propagate_library_updates(xblock.location.course_key, user.id)

@@ -89,6 +89,9 @@
NEVER = lambda x: False
ALWAYS = lambda x: True

@pluggable_override("PROPAGATE_LIBRARY_UPDATES")
def _propagate_library_updates(library_key_string, user_id):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative to creating a separate function here is to override _save_xblock, get its return value in the override function via the prev_fn arg, and perform the required logic there prior to returning:

def override_save_xblock(_save_xblock, *args, **kwargs):
    response = _save_xblock(*args, **kwargs)
    # Your logic here
    return response

This way we only need to include one line of changes in the edx repo, @pluggable_override("OVERRIDE_SAVE_XBLOCK"). Although on the other hand, defining a custom function tamps down on the scope of what we're overriding / allows us to handle only the arguments we need. @tramck do you have an opinion?

https://github.com/openedx/edx-django-utils/blob/2c975229cbbbfc07f3320b72cbb91f208957f2f5/edx_django_utils/plugins/pluggable_override.py#L26-L28

@@ -89,6 +89,9 @@
NEVER = lambda x: False
ALWAYS = lambda x: True

@pluggable_override("PROPAGATE_LIBRARY_UPDATES")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pluggable override names should always be prefixed with OVERRIDE_

Suggested change
@pluggable_override("PROPAGATE_LIBRARY_UPDATES")
@pluggable_override("OVERRIDE_PROPAGATE_LIBRARY_UPDATES")

@ianj-lewis
Copy link

ianj-lewis commented Nov 8, 2023

Anytime we're making changes to the edx repo, we should include a @medality_custom comment so we can easily find where we've made our own modifications, here's an example:

# @medality_custom: start
def is_library_block(block_key):
return block_key.block_type in ["library_content", "select_from_library"]
def get_xblock_class(block_type):
"""
Returns the class associated to the entry point of the given block type
"""
group = "xblock.v1"
for entry_point in pkg_resources.iter_entry_points(group):
if entry_point.name == block_type:
return pkg_resources.load_entry_point(entry_point.dist, group, block_type)
return None
# @medality_custom: end

cms/djangoapps/contentstore/views/item.py Outdated Show resolved Hide resolved
@pbischof42 pbischof42 merged commit 649815b into medality-olive Jan 8, 2024
5 of 35 checks passed
@pbischof42 pbischof42 deleted the MRI-3762 branch January 8, 2024 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants