Skip to content

Conversation

@mrbazzan
Copy link
Contributor

@mrbazzan mrbazzan commented Oct 24, 2025

Description

ca9c318736bfa5345a3e7 introduces an import processor which
has already been defined. This PR removes the duplicate and extends the custom hook to work as described
in the docs.

Related resources

  • #...
  • #...

Checklist

  • I have opened this pull request against master
  • I have added or modified the tests when changing logic
  • I have followed the conventional commits guidelines to add meaningful information into the changelog
  • I have read the contribution guidelines and I have joined #workgroup-pr-review on
    Discord to find a “pr review buddy” who is going to review my pull request.

Summary by Sourcery

Consolidate and simplify the plugin import processing by removing duplicate helper methods and always using the unified custom_process_hook interface with explicit plugin_data parameter, and update tests accordingly.

Enhancements:

  • Remove duplicate import processor and obsolete helper methods from datastructures
  • Require plugin_data in custom_process_hook signature and streamline hook invocation
  • Update tests to pass plugin_data to custom_process_hook and reflect its simplified API

Tests:

  • Adjust tests to supply plugin_data to custom_process_hook and validate its return signature

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Oct 24, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Centralize and simplify the import processing hook by removing duplicate logic in the restore method, updating the custom_process_hook signature to always accept plugin data, and adjusting tests to match the new signature.

Class diagram for updated import processing hook logic

classDiagram
    class PluginRestorer {
        +restore(placeholder, language, parent=None)
        -data
    }
    class custom_process_hook {
        +custom_process_hook(transfer_hook, plugin, plugin_data)
    }
    PluginRestorer --> custom_process_hook: uses
Loading

Flow diagram for centralized import processing hook

flowchart TD
    A["restore() in PluginRestorer"] --> B["custom_process_hook('DJANGOCMS_TRANSFER_PROCESS_IMPORT_PLUGIN_DATA', plugin, data)"]
    B --> C["User-defined import processor function called with (plugin, data)"]
Loading

File-Level Changes

Change Details Files
Consolidate plugin import processing into a single hook invocation
  • Removed explicit call to the user site import processor in restore
  • Deleted duplicate _call_user_site_import_processor_if_necessary and _resolve_function_from_full_path methods
  • Removed redundant plugin.save() call
  • Updated custom_process_hook invocation to include plugin data
djangocms_transfer/datastructures.py
Simplify custom_process_hook signature and logic
  • Changed signature to require plugin_data parameter
  • Removed conditional branching around plugin_data
  • Always invoke the user-provided function with plugin and plugin_data
djangocms_transfer/__init__.py
Adjust tests to the updated hook signature
  • Added plugin_data argument to custom_process_hook calls
  • Updated expected return values/assertions to include plugin_data
tests/transfer/test_helper.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

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


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.

@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.82%. Comparing base (ca9c318) to head (74cbcbe).

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #51      +/-   ##
==========================================
+ Coverage   58.43%   58.82%   +0.38%     
==========================================
  Files          10       10              
  Lines         409      391      -18     
  Branches       58       56       -2     
==========================================
- Hits          239      230       -9     
+ Misses        156      148       -8     
+ Partials       14       13       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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