Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

added snippets changelog to the toolbar under admin menu#181

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
svandeneertwegh wants to merge7 commits intodjango-cms:master
base:master
Choose a base branch
Loading
fromsvandeneertwegh:added_to_admin_menu-toolbar

Conversation

svandeneertwegh
Copy link

@svandeneertweghsvandeneertwegh commentedMar 5, 2025
edited by sourcery-aibot
Loading

Description

This PR adds the snippets manage url to the cms toolbar admin menu.

Related resources

Summary by Sourcery

Adds a link to the snippets changelist in the admin menu of the CMS toolbar, allowing users to manage snippets directly from the toolbar.

@sourcery-aiSourcery AI
Copy link
Contributor

sourcery-aibot commentedMar 5, 2025
edited
Loading

Reviewer's Guide by Sourcery

This pull request adds a 'Snippets' link to the admin menu in the CMS toolbar. This allows users to quickly access and manage snippets from the toolbar.

Sequence diagram for adding Snippets link to admin menu

sequenceDiagram    participant User    participant CMSToolbar    participant AdminMenu    User->>CMSToolbar: Open CMS Toolbar    CMSToolbar->>AliasToolbar: populate()    AliasToolbar->>AliasToolbar: add_aliases_link_to_admin_menu()    AliasToolbar->>CMSToolbar: get_or_create_menu(ADMIN_MENU_IDENTIFIER)    CMSToolbar->>AdminMenu: Get or create Admin Menu    AdminMenu-->>CMSToolbar: Returns AdminMenu    AliasToolbar->>AliasToolbar: admin_reverse('djangocms_snippet_snippet_changelist')    AliasToolbar->>AdminMenu: add_sideframe_item(_("Snippets"), url, position)    AdminMenu-->>AliasToolbar: Returns    AliasToolbar-->>CMSToolbar: Returns    CMSToolbar-->>User: Renders toolbar with Snippets link
Loading

File-Level Changes

ChangeDetailsFiles
Added a toolbar to include a link to the snippet changelist in the admin menu.
  • CreatedAliasToolbar class that inherits fromCMSToolbar.
  • Implementedpopulate method to calladd_aliases_link_to_admin_menu.
  • Implementedadd_aliases_link_to_admin_menu to add a sideframe item for Snippets in the admin menu.
  • Implementedget_insert_position to determine the alphabetical position of the Snippets link within the admin menu.
src/djangocms_snippet/cms_toolbars.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!
  • Generate a plan of action for an issue: Comment@sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access yourdashboard 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-aisourcery-aibot left a comment

Choose a reason for hiding this comment

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

Hey@svandeneertwegh - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding a permission check toadd_aliases_link_to_admin_menu to ensure only authorized users see the link.
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.

sourcery-ai[bot] reacted with thumbs up emojisourcery-ai[bot] reacted with thumbs down emoji
position=self.get_insert_position(admin_menu, self.plural_name),
)

@classmethod
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (complexity): Consider refactoring to separate the break setup and insertion point calculation into distinct helper functions, and use hasattr to check for attributes instead of try/except blocks, to improve code organization and readability..

You can reduce complexity by separating the two concerns: ensuring the breaks are set up and calculating the alphabetical insertion point. For instance, you could extract the break logic into its own helper and refactor the loop to check for the attribute rather than handling an exception. For example:

@classmethoddefensure_shortcuts_break(cls,admin_menu):start=admin_menu.find_first(Break,identifier=SHORTCUTS_BREAK)ifnotstart:end=admin_menu.find_first(Break,identifier=ADMINISTRATION_BREAK)admin_menu.add_break(SHORTCUTS_BREAK,position=end.index)start=admin_menu.find_first(Break,identifier=SHORTCUTS_BREAK)end=admin_menu.find_first(Break,identifier=ADMINISTRATION_BREAK)returnstart,end@classmethoddefcompute_insert_index(cls,admin_menu,start,end,item_name):items=admin_menu.get_items()[start.index+1:end.index]foridx,iteminenumerate(items):# Check if item has a name attribute instead of using try/except.ifhasattr(item,'name'):ifforce_str(item_name.lower())<force_str(item.name.lower()):returnidx+start.index+1returnend.index@classmethoddefget_insert_position(cls,admin_menu,item_name):start,end=cls.ensure_shortcuts_break(admin_menu)returncls.compute_insert_index(admin_menu,start,end,item_name)

This refactoring keeps functionality intact while isolating break management and order computation, increasing clarity and maintainability.

sourcery-ai[bot] reacted with thumbs up emojisourcery-ai[bot] reacted with thumbs down emoji
@fsbraun
Copy link
Member

@svandeneertwegh Thanks for the PR!

Can you add a check if the user has add or change permissions for snippets? Only then the menu entry makes sense...

svandeneertwegh reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@sourcery-aisourcery-ai[bot]sourcery-ai[bot] left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@svandeneertwegh@fsbraun

[8]ページ先頭

©2009-2025 Movatter.jp