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

Closes #15754: Remove staff_only=True from admin menu items #15784

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions netbox/netbox/navigation/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,10 @@
MenuGroup(
label=_('Authentication'),
items=(
# Proxy model for auth.User
MenuItem(
link=f'users:user_list',
link_text=_('Users'),
permissions=[f'auth.view_user'],
staff_only=True,
buttons=(
MenuItemButton(
link=f'users:user_add',
Expand All @@ -389,12 +387,10 @@
)
)
),
# Proxy model for auth.Group
MenuItem(
link=f'users:group_list',
link_text=_('Groups'),
permissions=[f'auth.view_group'],
staff_only=True,
buttons=(
MenuItemButton(
link=f'users:group_add',
Expand All @@ -414,14 +410,12 @@
link=f'users:token_list',
link_text=_('API Tokens'),
permissions=[f'users.view_token'],
staff_only=True,
buttons=get_model_buttons('users', 'token')
),
MenuItem(
link=f'users:objectpermission_list',
link_text=_('Permissions'),
permissions=[f'users.view_objectpermission'],
staff_only=True,
buttons=get_model_buttons('users', 'objectpermission', actions=['add'])
),
),
Expand All @@ -432,14 +426,12 @@
MenuItem(
link='core:config',
link_text=_('Current Config'),
permissions=['core.view_configrevision'],
staff_only=True
permissions=['core.view_configrevision']
),
MenuItem(
link='core:configrevision_list',
link_text=_('Config Revisions'),
permissions=['core.view_configrevision'],
staff_only=True
permissions=['core.view_configrevision']
),
),
),
Expand All @@ -448,13 +440,11 @@
items=(
MenuItem(
link='core:plugin_list',
link_text=_('Plugins'),
staff_only=True
link_text=_('Plugins')
),
MenuItem(
link='core:background_queue_list',
link_text=_('Background Tasks'),
staff_only=True
link_text=_('Background Tasks')
),
),
),
Expand Down
9 changes: 9 additions & 0 deletions netbox/templates/users/token_edit.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% extends 'generic/object_edit.html' %}
{% load i18n %}

{% block content %}
{% if not request.user.is_superuser %}
{% include 'inc/alerts/warning.html' with title="Creating API Tokens" message="Non-superusers should generally create and modify API tokens under their user profile." %}
{% endif %}
{{ block.super }}
{% endblock %}
1 change: 1 addition & 0 deletions netbox/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class TokenView(generic.ObjectView):
class TokenEditView(generic.ObjectEditView):
queryset = Token.objects.all()
form = forms.TokenForm
template_name = 'users/token_edit.html'


@register_model_view(Token, 'delete')
Expand Down
Loading