Skip to content
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

feat: Remove explicit django CMS dependency #36

Merged
merged 13 commits into from
Dec 10, 2024
Merged

Conversation

fsbraun
Copy link
Member

@fsbraun fsbraun commented Dec 8, 2024

Summary by Sourcery

Remove the explicit dependency on django CMS by conditionally importing CMS-related modules and functionalities only if 'cms' is installed. This change allows the package to be used independently of django CMS, enhancing its flexibility and usability in different environments. Update the package version to 0.4.0 to reflect these changes.

Enhancements:

  • Make the django CMS dependency optional by checking if 'cms' is installed before importing related modules and functionalities.

Chores:

  • Update the package version from 0.3.3 to 0.4.0 to reflect the changes.

Copy link
Contributor

sourcery-ai bot commented Dec 8, 2024

Reviewer's Guide by Sourcery

This PR removes the explicit dependency on django CMS, making the package more flexible by allowing it to be used independently. The implementation wraps django CMS-specific code in conditional imports and adds checks to ensure proper configuration when django CMS is not present. The changes primarily focus on restructuring the code to handle both django CMS and non-django CMS scenarios.

Class diagram for AbstractText with conditional CMSPlugin

classDiagram
    class AbstractText {
        +OneToOneField cmsplugin_ptr
        +TextField body
        +JSONField json
        +CharField rte
        +search_fields
        +__str__()
        +__init__(*args, **kwargs)
        +clean()
        +save(*args, **kwargs)
        +clean_plugins()
        +copy_referenced_plugins()
        +get_referenced_plugins()
        +add_existing_child_plugins_to_pairs(plugins_pairs)
        +_get_inline_plugin_ids()
        +post_copy(old_instance, ziplist)
        +notify_on_autoadd_children(request, conf, children)
    }
    class CMSPlugin {
    }
    AbstractText --> CMSPlugin : "if apps.is_installed('cms')"
Loading

Class diagram for TextConfig with new check_no_cms_config

classDiagram
    class TextConfig {
        +ready()
    }
    class AppConfig {
    }
    TextConfig --> AppConfig
    TextConfig : +check_no_cms_config()
Loading

File-Level Changes

Change Details Files
Introduce conditional django CMS imports and functionality
  • Wrap django CMS imports in apps.is_installed('cms') checks
  • Move Text and AbstractText model definitions inside conditional block
  • Refactor plugin discovery to work with and without django CMS
djangocms_text/models.py
djangocms_text/apps.py
Add configuration validation for non-django CMS usage
  • Add check to ensure migrations are deactivated when django CMS is not installed
  • Implement check_no_cms_config function to validate settings
djangocms_text/apps.py
Refactor utility functions and dependencies
  • Move get_url_endpoint function to widgets.py
  • Update imports to use correct toolbar base classes
  • Remove django CMS as a required dependency in pyproject.toml
djangocms_text/utils.py
djangocms_text/widgets.py
djangocms_text/cms_toolbars.py
pyproject.toml
Update version and documentation
  • Bump version from 0.3.3 to 0.4.0
  • Remove django-cms>=3.11 from dependencies list
djangocms_text/__init__.py
pyproject.toml

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.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a 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. You can also use
    this command to specify where the summary should be inserted.

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.

We have skipped reviewing this pull request. We don't review packaging changes - Let us know if you'd like us to change this.

Copy link

codecov bot commented Dec 8, 2024

Codecov Report

Attention: Patch coverage is 87.12871% with 13 lines in your changes missing coverage. Please review.

Project coverage is 80.43%. Comparing base (1fd3132) to head (119dd76).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
djangocms_text/apps.py 42.85% 5 Missing and 3 partials ⚠️
djangocms_text/models.py 93.90% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #36      +/-   ##
==========================================
+ Coverage   80.21%   80.43%   +0.21%     
==========================================
  Files          17       17              
  Lines         940      930      -10     
  Branches      106      104       -2     
==========================================
- Hits          754      748       -6     
+ Misses        143      138       -5     
- Partials       43       44       +1     

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

@sveetch
Copy link
Contributor

sveetch commented Dec 9, 2024

Hi,

Does this means this package would be usable without djangocms ?

@fsbraun
Copy link
Member Author

fsbraun commented Dec 9, 2024

This is what I would like to put up for discussion. It would only offer an HTMLField and the dynamic link capability would not work (without a third-party extension). More changes than this PR are required.

@sveetch
Copy link
Contributor

sveetch commented Dec 9, 2024

That would be very interesting so we could introduce its usage in non-cms apps that live in a CMS project to have the same editor everywhere, however i imagine it could be difficult to manage with the cms specific features.

It would only offer an HTMLField

The HTMLField is nice but from experience i think the widget would be important also.

@fsbraun
Copy link
Member Author

fsbraun commented Dec 9, 2024

@sveetch That's already possible today: You can use HTMLField in any non-CMS app within a CMS project. In the future, you could use HTMLField also in a non-CMS project and later add django CMS.

@vinitkumar
Copy link
Member

This is a great idea. Let's do it.

@fsbraun
Copy link
Member Author

fsbraun commented Dec 10, 2024

@sourcery-ai review

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 @fsbraun - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • The MIGRATION_MODULES setting should be a dictionary, not a list (link)

Overall Comments:

  • There appears to be an import error - get_url_endpoint() was moved to widgets.py but utils.py still shows up as an import source in some files. This needs to be fixed to prevent runtime errors.
Here's what I looked at during the review
  • 🔴 General issues: 1 blocking issue
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

README.rst Outdated Show resolved Hide resolved
djangocms_text/models.py Outdated Show resolved Hide resolved
djangocms_text/models.py Outdated Show resolved Hide resolved
djangocms_text/models.py Outdated Show resolved Hide resolved
@fsbraun
Copy link
Member Author

fsbraun commented Dec 10, 2024

@sourcery-ai review

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 @fsbraun - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

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.

djangocms_text/apps.py Show resolved Hide resolved
@fsbraun
Copy link
Member Author

fsbraun commented Dec 10, 2024

@sourcery-ai review

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 @fsbraun - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding documentation about the features and limitations when using the package without django CMS
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

djangocms_text/apps.py Outdated Show resolved Hide resolved
@fsbraun fsbraun merged commit 696b3ee into main Dec 10, 2024
31 checks passed
@fsbraun fsbraun deleted the feat/no-cms-dependency branch December 10, 2024 11:34
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.

3 participants