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

fix: Editing of existing snippet not allows (unversioned snippets) #177

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

fsbraun
Copy link
Member

@fsbraun fsbraun commented Jan 21, 2025

Description

Fix for #176

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 #pr-review on
    Discord to find a “pr review buddy” who is
    going to review my pull request.

Summary by Sourcery

Bug Fixes:

  • Fix an issue that prevented editing existing snippets if they were not versioned.

Copy link

sourcery-ai bot commented Jan 21, 2025

Reviewer's Guide by Sourcery

The pull request fixes a bug where editing an existing snippet was not allowed when versioning was enabled. The fix involves modifying the queryset to exclude snippets with the same snippet_grouper, regardless of whether versioning is enabled or not.

Sequence diagram for snippet validation flow

sequenceDiagram
    participant User
    participant Form as SnippetForm
    participant DB as Database

    User->>Form: Submit snippet edit
    Form->>Form: clean()
    Form->>DB: Query snippets
    Note over Form,DB: Exclude snippets with same grouper
    DB-->>Form: Return filtered snippets
    Form->>Form: Check for duplicate names
    alt Duplicate name exists
        Form-->>User: Validation error
    else Name is unique
        Form-->>User: Validation passes
    end
Loading

Class diagram for snippet form changes

classDiagram
    class SnippetForm {
        +clean()
    }
    class Snippet {
        +name: str
        +slug: str
        +snippet_grouper: ForeignKey
    }
    SnippetForm ..> Snippet: validates
    note for SnippetForm "Modified clean() to always exclude
snippets with same grouper"
Loading

File-Level Changes

Change Details Files
Modified the queryset to exclude snippets with the same snippet_grouper.
  • Removed the conditional logic that checked if versioning was enabled.
  • Modified the queryset to always exclude snippets with the same snippet_grouper.
src/djangocms_snippet/forms.py

Possibly linked issues


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

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