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: Support LinkFormField of djangocms-link 5+ #241

Merged
merged 106 commits into from
Nov 20, 2024

Conversation

fsbraun
Copy link
Member

@fsbraun fsbraun commented Oct 27, 2024

This PR replaces the built-in link functionality with the new re-usable LinkFormField by djangocms-link.

Summary by Sourcery

Replace the built-in link functionality with the reusable LinkFormField from djangocms-link, simplifying link management and updating configurations. Refactor the codebase to remove redundant link fields and update the build and CI configurations to align with the new setup.

New Features:

  • Integrate the reusable LinkFormField from djangocms-link to replace the built-in link functionality.

Enhancements:

  • Refactor the link handling logic to utilize the new LinkFormField, simplifying the codebase and removing redundant link fields.

Build:

  • Update the pyproject.toml to include new configurations for tools like black, ruff, isort, flake8, and coverage.

CI:

  • Modify the CI workflow to use pytest for running tests and generating coverage reports.

Tests:

  • Add a migration test to verify the conversion of link configurations to the new format and back.

@fsbraun fsbraun closed this Nov 19, 2024
@fsbraun fsbraun reopened this Nov 19, 2024
@fsbraun
Copy link
Member Author

fsbraun commented Nov 19, 2024

@sourcery-ai review

Copy link
Contributor

sourcery-ai bot commented Nov 19, 2024

Reviewer's Guide by Sourcery

This PR replaces the built-in link functionality with djangocms-link's reusable LinkFormField. The implementation involves removing the custom link handling code and integrating with djangocms-link's field and helpers. The changes include data migration to convert existing link data to the new format.

ER diagram for link data migration

erDiagram
    FrontendUIItem {
        JSON config
    }
    FrontendUIItem ||--o{ Link : contains
    Link {
        String external_link
        String internal_link
        String file_link
        String phone
        String mailto
        String anchor
    }
    Link ||--o{ LinkFormField : converted_to
    LinkFormField {
        String link
    }
Loading

Class diagram for LinkFormField integration

classDiagram
    class LinkFormMixin {
        +LinkFormField link
        +ChoiceField target
        +Boolean link_is_optional
    }
    class AbstractLinkForm {
    }
    class EntangledModelFormMixin {
    }
    LinkFormMixin --|> EntangledModelFormMixin
    AbstractLinkForm --|> LinkFormMixin

    class GetLinkMixin {
        +String get_link()
    }
    GetLinkMixin --|> LinkFormMixin

    class LinkFormField {
    }
    LinkFormMixin o-- LinkFormField

    class Site {
    }
    GetLinkMixin o-- Site
Loading

File-Level Changes

Change Details Files
Replace custom link form fields with djangocms-link's LinkFormField
  • Remove custom link form fields (external_link, internal_link, file_link, etc.)
  • Add LinkFormField from djangocms-link package
  • Update form validation to use djangocms-link's validation
  • Remove custom link widgets and field classes
djangocms_frontend/contrib/link/forms.py
Add data migration for converting existing link data
  • Create migration to convert old link format to new djangocms-link format
  • Add forward and backward migration functions
  • Handle various link types (external, internal, file, phone, mailto)
djangocms_frontend/migrations/0002_migrate_links.py
Refactor link handling helpers
  • Remove custom link choice and queryset functions
  • Update get_link method to use djangocms-link helpers
  • Simplify link URL generation code
djangocms_frontend/contrib/link/helpers.py
Update dependencies and configuration
  • Add djangocms-link>=5.0.0 as a dependency
  • Remove obsolete link-related settings
  • Add migration warning for deprecated settings
setup.py
djangocms_frontend/apps.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.
  • 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.

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

Here's what I looked at during the review
  • 🟡 General issues: 5 issues found
  • 🟢 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_frontend/migrations/0002_migrate_links.py Outdated Show resolved Hide resolved
README.rst Outdated Show resolved Hide resolved
docs/source/index.rst Outdated Show resolved Hide resolved
docs/source/how-to/internal-link-targets.rst Outdated Show resolved Hide resolved
docs/source/custom_components.rst Outdated Show resolved Hide resolved
djangocms_frontend/plugin_tag.py Show resolved Hide resolved
README.rst Outdated Show resolved Hide resolved
docs/source/index.rst Outdated Show resolved Hide resolved
@fsbraun fsbraun merged commit 1d6a629 into django-cms:master Nov 20, 2024
20 checks passed
@fsbraun fsbraun deleted the feat/djangocms-link-support branch November 20, 2024 21:46
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