Skip to content

fix: update form entry references and enhance admin search fields - #28

Merged
metaforx merged 1 commit into
mainfrom
fix/plugin-selection
May 5, 2026
Merged

fix: update form entry references and enhance admin search fields#28
metaforx merged 1 commit into
mainfrom
fix/plugin-selection

Conversation

@metaforx

@metaforx metaforx commented May 5, 2026

Copy link
Copy Markdown
Owner

Summary by Sourcery

Update admin integrations to reference proxy form entries and improve CMS plugin configuration.

New Features:

  • Add search support for form entries by name and slug in the admin.

Enhancements:

  • Switch CMS Fobi form plugin model to reference the FormEntryProxy instead of the base FormEntry.
  • Configure the CMS Fobi form plugin to use raw ID fields for selecting form entries.
  • Align admin class declarations and URL name generation formatting for consistency.

@sourcery-ai

sourcery-ai Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Updates admin and CMS integration for Fobi forms by pointing CMS plugins to the FormEntry proxy model, improving admin usability (search and raw ID widget), and making minor admin style cleanups, including the corresponding schema migration.

ER diagram for FobiFormPluginModel relationship update

erDiagram
  unfold_fobi_FormEntryProxy {
    int id
    string name
    string slug
  }

  unfold_fobi_cms_FobiFormPluginModel {
    int id
    int form_entry_id
  }

  unfold_fobi_FormEntryProxy ||--o{ unfold_fobi_cms_FobiFormPluginModel : referenced_by
Loading

Class diagram for updated admin and CMS plugin integration

classDiagram
  class FormEntryAdmin {
    +list search_fields
    +list inlines
    +get_urls()
    +redirect_to_edit(request, object_id)
    +response_change(request, obj)
  }

  class ProxyOnlyFobiAdminMixin
  class FobiFormEntryAdmin
  class ModelAdmin

  FormEntryAdmin ..|> ProxyOnlyFobiAdminMixin
  FormEntryAdmin ..|> FobiFormEntryAdmin
  FormEntryAdmin ..|> ModelAdmin

  class FormEntryProxy {
    +id: int
    +name: str
    +slug: str
  }

  class CMSPlugin

  class FobiFormPluginModel {
    +id: int
    +form_entry: ForeignKey
  }

  class UnfoldCMSPluginBase
  class IntegrationProcessor

  class FobiFormPlugin {
    +raw_id_fields: list
    +name: str
    +render_template: str
    +can_redirect: bool
  }

  FobiFormPluginModel ..|> CMSPlugin
  FobiFormPluginModel --> FormEntryProxy : form_entry

  FobiFormPlugin ..|> UnfoldCMSPluginBase
  FobiFormPlugin ..|> IntegrationProcessor
  FobiFormPlugin --> FobiFormPluginModel : uses_model
Loading

File-Level Changes

Change Details Files
Point CMS Fobi form plugin to use the FormEntry proxy model and add the corresponding migration.
  • Change FobiFormPluginModel.form_entry ForeignKey target from the base FormEntry model to the unfold_fobi.FormEntryProxy proxy model.
  • Add a schema migration that alters the fobiformpluginmodel.form_entry field to reference unfold_fobi.formentryproxy with PROTECT on delete and the existing verbose name.
src/unfold_fobi/contrib/cms/models.py
src/unfold_fobi/contrib/cms/migrations/0002_alter_fobiformpluginmodel_form_entry.py
Improve Django admin UX for managing Fobi form entries in both the main admin and the CMS plugin admin.
  • Add search_fields for name and slug on the FormEntry admin to make form entries searchable in the Django admin.
  • Configure the CMS FobiFormPlugin admin to use a raw ID widget for selecting form_entry for better performance/usability with large datasets.
  • Flatten a few multi-line admin class and variable declarations for style consistency without changing behavior, including the change_url_name assignment and several admin class definitions.
src/unfold_fobi/fobi_admin.py
src/unfold_fobi/contrib/cms/cms_plugins.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Consider keeping the multi-base admin class definitions and the long f-string assignment split across multiple lines to maintain readability and consistency with the existing style in this module.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider keeping the multi-base admin class definitions and the long f-string assignment split across multiple lines to maintain readability and consistency with the existing style in this module.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@metaforx
metaforx merged commit b1c3881 into main May 5, 2026
4 checks passed
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.

1 participant