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 group names as menu item display condition #502

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ShlomoCode
Copy link

@ShlomoCode ShlomoCode commented Jul 30, 2023

from django docs:

django.contrib.auth.models.Group models are a generic way of categorizing users so you can apply permissions, or some other label, to those users. A user can belong to any number of groups.
A user in a group automatically has the permissions granted to that group. For example, if the group Site editors has the permission can_edit_home_page, any user in that group will have that permission.

Beyond permissions, groups are a convenient way to categorize users to give them some label, or extended functionality. For example, you could create a group 'Special users', and you could write code that could, say, give them access to a members-only portion of your site, or send them members-only email messages.

This PR adds support for the groups option as a display condition for a menu item (user_menu/top_menu).
It is very useful in my opinion to be able to control the display option not only based on model permissions but also based on the groups.

It works in the form of AND, if both groups and permissions are defined, and the user has only the groups or only permissions, the item will not be shown to him (open to comments maybe it should work differently).

usage example:

   "topmenu_links": [
        {"name": "Home Page", "url": "home", "groups": ["some_group_name"]},
    ]

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.

2 participants