-
Notifications
You must be signed in to change notification settings - Fork 17
School data portal pages #1650
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?
School data portal pages #1650
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.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
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.
Pull request overview
This PR adds school data portal functionality by integrating wagtail-autocomplete and linking schools from Salesforce to landing pages. It enables CMS users to associate landing pages with specific schools and expose school information through the API.
- Adds
Schoolforeign key toRootPagewith autocomplete selection and API exposure viaschool_dataproperty - Updates Salesforce
Schoolmodel with search/autocomplete capabilities and newindustryfield - Enhances
update_schoolsmanagement command to filter by industry (HE/K12), sync industry data, and clean up deleted schools - Integrates wagtail-autocomplete package with custom JavaScript to conditionally show the school field only for landing page layouts
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| salesforce/models.py | Adds search indexing and autocomplete methods to School model; adds industry field |
| salesforce/migrations/0114_school_industry.py | Migration adding industry field to School model |
| salesforce/management/commands/update_schools.py | Updates command to include Industry field, filter by HE/K12, track and delete missing schools |
| requirements/base.txt | Adds wagtail-autocomplete==0.12.0 dependency |
| pages/wagtail_hooks.py | Registers hook to inject conditional school field JavaScript |
| pages/static/pages/conditional-school-field.js | JavaScript to show/hide school field based on landing page layout type |
| pages/models.py | Adds school foreign key to RootPage with autocomplete panel and API field exposure; removes HomePage from parent_page_types |
| pages/migrations/0163_rootpage_school.py | Migration adding school field to RootPage |
| openstax/urls.py | Includes wagtail-autocomplete admin URLs |
| openstax/settings/base.py | Adds wagtailautocomplete to INSTALLED_APPS |
Comments suppressed due to low confidence (1)
salesforce/models.py:8
- Import of 'AutocompletePanel' is not used.
from wagtailautocomplete.edit_handlers import AutocompletePanel
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…x/openstax-cms into school-data-portal-pages
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| def conditional_school_field_js(request): | ||
| """Inject JavaScript to conditionally show school field only for RootPage edit views""" | ||
| # Only inject JS if editing a RootPage instance | ||
| if hasattr(request, 'instance') and isinstance(getattr(request, 'instance', None), RootPage): |
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.
Bug: JS injection check relies on non-existent request attribute
The insert_editor_js hook checks for request.instance to determine whether to inject the JavaScript, but Django request objects do not have an instance attribute. Wagtail does not attach the page instance being edited to the request object. This means the condition hasattr(request, 'instance') will always be False, and the conditional school field JavaScript will never be loaded when editing RootPage instances.
Note
Adds a
RootPage.schoolrelation with admin autocomplete and APIschool_data, enables Wagtail autocomplete, and updates School syncing, indexing, and serializers.RootPage.school(ForeignKeytosalesforce.School) withAutocompletePanel; exposeAPIField('school_data')(cached) viaSchoolSerializer.pages/static/pages/conditional-school-field.js) via Wagtail hook to conditionally show theschoolfield when thelayouthas alandingblock.RootPage.parent_page_typesto['wagtailcore.Page'].School.industryfield and Wagtail search indexing/autocomplete configuration; migrations included.SchoolSerializerto includesalesforce_idandindustry(read-only).update_schoolscommand to fetch only HE/K12 accounts, includeIndustry, track seen IDs, and delete schools missing from Salesforce; improved summary output.admin/autocomplete/.wagtail-autocompleteto requirements andINSTALLED_APPS.Written by Cursor Bugbot for commit 3d492e4. This will update automatically on new commits. Configure here.