Skip to content

Conversation

@mwvolo
Copy link
Member

@mwvolo mwvolo commented Dec 5, 2025

Note

Adds a RootPage.school relation with admin autocomplete and API school_data, enables Wagtail autocomplete, and updates School syncing, indexing, and serializers.

  • Pages/CMS:
    • Add RootPage.school (ForeignKey to salesforce.School) with AutocompletePanel; expose APIField('school_data') (cached) via SchoolSerializer.
    • Inject editor JS (pages/static/pages/conditional-school-field.js) via Wagtail hook to conditionally show the school field when the layout has a landing block.
    • Restrict RootPage.parent_page_types to ['wagtailcore.Page'].
  • Salesforce/Models & API:
    • Add School.industry field and Wagtail search indexing/autocomplete configuration; migrations included.
    • Extend SchoolSerializer to include salesforce_id and industry (read-only).
  • Data Sync:
    • Update update_schools command to fetch only HE/K12 accounts, include Industry, track seen IDs, and delete schools missing from Salesforce; improved summary output.
  • URLs/Admin:
    • Register Wagtail autocomplete admin routes at admin/autocomplete/.
  • Dependencies/Settings:
    • Add wagtail-autocomplete to requirements and INSTALLED_APPS.

Written by Cursor Bugbot for commit 3d492e4. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a 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.

Copy link
Contributor

Copilot AI left a 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 School foreign key to RootPage with autocomplete selection and API exposure via school_data property
  • Updates Salesforce School model with search/autocomplete capabilities and new industry field
  • Enhances update_schools management 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.

mwvolo and others added 6 commits December 5, 2025 14:30
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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):
Copy link

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.

Fix in Cursor Fix in Web

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.

2 participants