-
Notifications
You must be signed in to change notification settings - Fork 4
feat: sync course tabs #526
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
base: main
Are you sure you want to change the base?
Conversation
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 skimmed through the PR and left a few comments.
""" | ||
Listen for the course static tab changes and trigger static tab sync | ||
""" | ||
xblock_info = kwargs.get("xblock_info") | ||
if not xblock_info or not isinstance(xblock_info, XBlockData): | ||
log.error("Received null or incorrect data for event") | ||
return | ||
|
||
if xblock_info.block_type != "static_tab": | ||
return | ||
|
||
course_key = xblock_info.usage_key.course_key | ||
if not CourseSyncOrganization.objects.filter( | ||
organization=course_key.org, is_active=True | ||
).exists(): | ||
return | ||
|
||
course_sync_mappings = CourseSyncMapping.objects.filter( | ||
source_course=course_key, is_active=True | ||
) | ||
if not course_sync_mappings: | ||
return | ||
|
||
for course_sync_mapping in course_sync_mappings: | ||
sync_course_static_tabs.delay( | ||
str(course_sync_mapping.source_course), | ||
str(course_sync_mapping.target_course), | ||
) |
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 think we can probably do some refactoring of the order of the conditions here.
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.
Can you share what's on your mind? I kept the order intentionally because there would be many signals, and I wanted to avoid the database queries.
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.
Ah, I see, makes sense then.
|
||
@receiver(XBLOCK_CREATED) | ||
@receiver(XBLOCK_DELETED) | ||
@receiver(XBLOCK_UPDATED) |
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.
is this raised if we change anything in static pages?
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.
Should we listen for the xBlock published signal? I can think of one reason why that's not here. We already have a signal for the course publish and it would make this duplicate? In any case, we would want to avoid duplicate signals. At the moment I am unsure of these will collide with each other or not.
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.
These are raised when we create, change, or delete the static pages. Static pages have no relation to course publishing.
What are the relevant tickets?
https://github.com/mitodl/hq/issues/7546
Description (What does it do?)
Sync static tabs with the target courses.
Screenshots (if appropriate):
How can this be tested?
Additional Context