Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
773a4f9
125890 first working user list
arthanson Jun 2, 2023
b17dfa0
125890 first working user list
arthanson Jun 2, 2023
a609467
125890 add form fields
arthanson Jun 6, 2023
bd67cfb
125890 basic group objectpermission views
arthanson Jun 6, 2023
4da0b83
125890 basic group objectpermission views
arthanson Jun 7, 2023
2fdd834
125890 fix group permission views
arthanson Jun 9, 2023
f1eadc6
125890 fix objectpermission form
arthanson Jun 9, 2023
4560eb6
125890 fixes
arthanson Jun 9, 2023
30a168a
125890 fixes
arthanson Jun 9, 2023
057fbf0
12589 fix boolean filters
arthanson Jun 12, 2023
78ef1d1
12589 UI fixes
arthanson Jun 12, 2023
3ed852f
12589 UI fixes
arthanson Jun 12, 2023
cc7f768
12589 fix users object_permissions m2m
arthanson Jun 12, 2023
281aa92
12589 fix objectpermissionform
arthanson Jun 12, 2023
1435cd7
12589 fix user/group create
arthanson Jun 13, 2023
3c60911
12589 user RestrictedQuerySet for permission
arthanson Jun 13, 2023
4332ba0
12589 user RestrictedQuerySet for permission
arthanson Jun 13, 2023
5403396
12589 add user group manager
arthanson Jun 13, 2023
d0d74c9
12589 update comments
arthanson Jun 16, 2023
bdfcb93
12589 fix permission model check
arthanson Jun 20, 2023
39608f6
12589 fixes for add/edit user form
arthanson Jun 20, 2023
8267ca5
12589 fix for Objectchange
arthanson Jun 21, 2023
bce8672
12589 test fixes
arthanson Jun 22, 2023
98ac45e
12589 fix tests
arthanson Jun 22, 2023
53b1998
12589 fix tests
arthanson Jun 23, 2023
923afae
12589 fix tests
arthanson Jun 23, 2023
0fee7b7
12589 bulk edit test fixes
arthanson Jun 25, 2023
ef4e9bd
12589 export objects test fixes
arthanson Jun 25, 2023
53fe449
12589 group test fixes
arthanson Jun 25, 2023
ee29b27
12589 cleanup
arthanson Jun 25, 2023
b3b59a2
12589 objectpermission get_absolute_url
arthanson Jun 25, 2023
e7b2154
12589 validation error
arthanson Jun 25, 2023
93ba0c0
12589 validation error
arthanson Jun 25, 2023
c4131af
12589 objectpermission bulk edit
arthanson Jun 26, 2023
c25fee9
12589 objectpermission test fixes
arthanson Jun 26, 2023
8e57521
12589 objectpermission test fixes for create check where create new o…
arthanson Jun 26, 2023
4e418ba
12589 objectpermission test fixes for create check where create new o…
arthanson Jun 26, 2023
171f85d
12589 objectpermission remove bulk import
arthanson Jun 26, 2023
12cd1af
12589 merge feature
arthanson Jun 26, 2023
1f08dc6
12589 update proflie base template
arthanson Jun 26, 2023
54ae418
12589 change password
arthanson Jun 26, 2023
0565663
12589 remove from admin
arthanson Jun 26, 2023
b851f33
12589 merge and add missing files
arthanson Jul 13, 2023
e2cc63f
12589 review changes and add localization
arthanson Jul 13, 2023
2cc7e49
12589 review changes for linkify column
arthanson Jul 13, 2023
7307ee4
12589 fix template
arthanson Jul 13, 2023
40c8e67
12589 translate templates
arthanson Jul 13, 2023
2871cb9
12589 review changes
arthanson Jul 13, 2023
101db0f
12589 review changes
arthanson Jul 14, 2023
002c0bf
12589 review changes
arthanson Jul 14, 2023
6a98397
12589 review changes - permission proxy
arthanson Jul 14, 2023
8d84eec
12589 review changes - change permission check
arthanson Jul 14, 2023
f9f3899
12589 review changes - change permission check
arthanson Jul 14, 2023
32f772d
12589 review changes - change permission check
arthanson Jul 14, 2023
1a33637
12589 change password in edit view
arthanson Jul 14, 2023
68cd6ef
12589 user bulk import
arthanson Jul 17, 2023
cc3c64c
12589 missing test file
arthanson Jul 17, 2023
55d1918
12589 dont check password field for tests
arthanson Jul 17, 2023
17b0456
12589 dont check password field for tests
arthanson Jul 17, 2023
a1af7f2
12589 remove special perm
arthanson Jul 17, 2023
2c7c3bc
12589 update menu permissions for auth models
arthanson Jul 17, 2023
846eef1
Merge branch 'feature' into 12589-user-admin
arthanson Jul 20, 2023
dd70ba9
12589 fix friggin test case
arthanson Jul 20, 2023
6a5c44f
Reorganize account view templates
jeremystretch Jul 20, 2023
d8ad97e
Create menu items manually for users & groups to accomodate proxy models
jeremystretch Jul 20, 2023
937961b
Restore bookmarks tab on account views
jeremystretch Jul 20, 2023
30d9798
Clean up user bulk edit
jeremystretch Jul 20, 2023
f49b43d
Remove unused form classes
jeremystretch Jul 20, 2023
4702cc0
Clean up permissions bulk edit
jeremystretch Jul 20, 2023
56cb542
Clean up user & group import
jeremystretch Jul 20, 2023
d24330f
Clean up filtering for users, groups, and permissions
jeremystretch Jul 20, 2023
b5362f0
Clean up model forms
jeremystretch Jul 20, 2023
34b8d2a
Misc cleanup
jeremystretch Jul 20, 2023
5c2f0c5
Flesh out object templates
jeremystretch Jul 20, 2023
235da43
Clean up tests
jeremystretch Jul 20, 2023
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
51 changes: 51 additions & 0 deletions netbox/netbox/navigation/menu.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.utils.translation import gettext as _

from netbox.registry import registry
from utilities.choices import ButtonColorChoices
from . import *

#
Expand Down Expand Up @@ -351,6 +352,56 @@
label=_('Admin'),
icon_class='mdi mdi-account-multiple',
groups=(
MenuGroup(
label=_('Users'),
items=(
# Proxy model for auth.User
MenuItem(
link=f'users:netboxuser_list',
link_text=_('Users'),
permissions=[f'auth.view_user'],
buttons=(
MenuItemButton(
link=f'users:netboxuser_add',
title='Add',
icon_class='mdi mdi-plus-thick',
permissions=[f'auth.add_user'],
color=ButtonColorChoices.GREEN
),
MenuItemButton(
link=f'users:netboxuser_import',
title='Import',
icon_class='mdi mdi-upload',
permissions=[f'auth.add_user'],
color=ButtonColorChoices.CYAN
)
)
),
# Proxy model for auth.Group
MenuItem(
link=f'users:netboxgroup_list',
link_text=_('Groups'),
permissions=[f'auth.view_group'],
buttons=(
MenuItemButton(
link=f'users:netboxgroup_add',
title='Add',
icon_class='mdi mdi-plus-thick',
permissions=[f'auth.add_group'],
color=ButtonColorChoices.GREEN
),
MenuItemButton(
link=f'users:netboxgroup_import',
title='Import',
icon_class='mdi mdi-upload',
permissions=[f'auth.add_group'],
color=ButtonColorChoices.CYAN
)
)
),
get_model_item('users', 'objectpermission', _('Permissions'), actions=['add']),
),
),
MenuGroup(
label=_('Configuration'),
items=(
Expand Down
1 change: 1 addition & 0 deletions netbox/netbox/views/generic/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def get_permitted_actions(self, user, model=None):
Return a tuple of actions for which the given user is permitted to do.
"""
model = model or self.queryset.model

return [
action for action in self.actions if user.has_perms([
get_permission_for_model(model, name) for name in self.action_perms[action]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'users/base.html' %}
{% extends 'users/account/base.html' %}
{% load helpers %}
{% load render_table from django_tables2 %}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
{% extends 'base/layout.html' %}
{% load i18n %}

{% block tabs %}
<ul class="nav nav-tabs px-3">
<li role="presentation" class="nav-item">
<a class="nav-link{% if active_tab == 'profile' %} active{% endif %}" href="{% url 'users:profile' %}">Profile</a>
<a class="nav-link{% if active_tab == 'profile' %} active{% endif %}" href="{% url 'users:profile' %}">{% trans "Profile" %}</a>
</li>
<li role="presentation" class="nav-item">
<a class="nav-link{% if active_tab == 'bookmarks' %} active{% endif %}" href="{% url 'users:bookmarks' %}">Bookmarks</a>
<a class="nav-link{% if active_tab == 'bookmarks' %} active{% endif %}" href="{% url 'users:bookmarks' %}">{% trans "Bookmarks" %}</a>
</li>
<li role="presentation" class="nav-item">
<a class="nav-link{% if active_tab == 'preferences' %} active{% endif %}" href="{% url 'users:preferences' %}">Preferences</a>
<a class="nav-link{% if active_tab == 'preferences' %} active{% endif %}" href="{% url 'users:preferences' %}">{% trans "Preferences" %}</a>
</li>
{% if not request.user.ldap_username %}
<li role="presentation" class="nav-item">
<a class="nav-link{% if active_tab == 'password' %} active{% endif %}" href="{% url 'users:change_password' %}">Password</a>
<a class="nav-link{% if active_tab == 'password' %} active{% endif %}" href="{% url 'users:change_password' %}">{% trans "Password" %}</a>
</li>
{% endif %}
<li role="presentation" class="nav-item">
<a class="nav-link{% if active_tab == 'api-tokens' %} active{% endif %}" href="{% url 'users:token_list' %}">API Tokens</a>
<a class="nav-link{% if active_tab == 'api-tokens' %} active{% endif %}" href="{% url 'users:token_list' %}">{% trans "API Tokens" %}</a>
</li>
</ul>
{% endblock %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'users/base.html' %}
{% extends 'users/account/base.html' %}
{% load buttons %}
{% load helpers %}
{% load render_table from django_tables2 %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'users/base.html' %}
{% extends 'users/account/base.html' %}
{% load form_helpers %}

{% block title %}Change Password{% endblock %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'users/base.html' %}
{% extends 'users/account/base.html' %}
{% load helpers %}
{% load form_helpers %}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'users/base.html' %}
{% extends 'users/account/base.html' %}
{% load helpers %}
{% load render_table from django_tables2 %}

Expand Down
48 changes: 48 additions & 0 deletions netbox/templates/users/group.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{% extends 'generic/object.html' %}
{% load i18n %}
{% load helpers %}
{% load render_table from django_tables2 %}

{% block title %}{% trans "Group" %} {{ object.name }}{% endblock %}

{% block subtitle %}{% endblock %}

{% block content %}
<div class="row mb-3">
<div class="col-md-6">
<div class="card">
<h5 class="card-header">{% trans "Group" %}</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">{% trans "Name" %}</th>
<td>{{ object.name }}</td>
</tr>
</table>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card">
<h5 class="card-header">{% trans "Users" %}</h5>
<div class="list-group list-group-flush">
{% for user in object.user_set.all %}
<a href="{% url 'users:netboxuser' pk=user.pk %}" class="list-group-item list-group-item-action">{{ user }}</a>
{% empty %}
<div class="list-group-item text-muted">{% trans "None" %}</div>
{% endfor %}
</div>
</div>
<div class="card">
<h5 class="card-header">{% trans "Assigned Permissions" %}</h5>
<div class="list-group list-group-flush">
{% for perm in object.object_permissions.all %}
<a href="{% url 'users:objectpermission' pk=perm.pk %}" class="list-group-item list-group-item-action">{{ perm }}</a>
{% empty %}
<div class="list-group-item text-muted">{% trans "None" %}</div>
{% endfor %}
</div>
</div>
</div>
</div>
{% endblock %}
97 changes: 97 additions & 0 deletions netbox/templates/users/objectpermission.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{% extends 'generic/object.html' %}
{% load i18n %}
{% load helpers %}
{% load render_table from django_tables2 %}

{% block title %}{% trans "Permission" %} {{ object.name }}{% endblock %}

{% block subtitle %}{% endblock %}

{% block content %}
<div class="row mb-3">
<div class="col-md-6">
<div class="card">
<h5 class="card-header">{% trans "Permission" %}</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">{% trans "Name" %}</th>
<td>{{ object.name }}</td>
</tr>
<tr>
<th scope="row">{% trans "Description" %}</th>
<td>{{ object.description|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Enabled" %}</th>
<td>{% checkmark object.enabled %}</td>
</tr>
</table>
</div>
</div>
<div class="card">
<h5 class="card-header">{% trans "Actions" %}</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">{% trans "View" %}</th>
<td>{% checkmark object.can_view %}</td>
</tr>
<tr>
<th scope="row">{% trans "Add" %}</th>
<td>{% checkmark object.can_add %}</td>
</tr>
<tr>
<th scope="row">{% trans "Change" %}</th>
<td>{% checkmark object.can_change %}</td>
</tr>
<tr>
<th scope="row">{% trans "Delete" %}</th>
<td>{% checkmark object.can_delete %}</td>
</tr>
</table>
</div>
</div>
<div class="card">
<h5 class="card-header">{% trans "Constraints" %}</h5>
<div class="card-body">
{% if object.constraints %}
<pre>{{ object.constraints|json }}</pre>
{% else %}
<span class="text-muted">None</span>
{% endif %}
</div>
</div>
</div>
<div class="col-md-6">
<div class="card">
<h5 class="card-header">{% trans "Object Types" %}</h5>
<ul class="list-group list-group-flush">
{% for user in object.object_types.all %}
<li class="list-group-item">{{ user }}</li>
{% endfor %}
</ul>
</div>
<div class="card">
<h5 class="card-header">{% trans "Assigned Users" %}</h5>
<div class="list-group list-group-flush">
{% for user in object.users.all %}
<a href="{% url 'users:netboxuser' pk=user.pk %}" class="list-group-item list-group-item-action">{{ user }}</a>
{% empty %}
<div class="list-group-item text-muted">{% trans "None" %}</div>
{% endfor %}
</div>
</div>
<div class="card">
<h5 class="card-header">{% trans "Assigned Groups" %}</h5>
<div class="list-group list-group-flush">
{% for group in object.groups.all %}
<a href="{% url 'users:netboxgroup' pk=group.pk %}" class="list-group-item list-group-item-action">{{ group }}</a>
{% empty %}
<div class="list-group-item text-muted">{% trans "None" %}</div>
{% endfor %}
</div>
</div>
</div>
</div>
{% endblock %}
84 changes: 84 additions & 0 deletions netbox/templates/users/user.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{% extends 'generic/object.html' %}
{% load i18n %}
{% load helpers %}
{% load render_table from django_tables2 %}

{% block title %}{% trans "User" %} {{ object.username }}{% endblock %}

{% block subtitle %}{% endblock %}

{% block content %}
<div class="row mb-3">
<div class="col-md-6">
<div class="card">
<h5 class="card-header">{% trans "User" %}</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">{% trans "Username" %}</th>
<td>{{ object.username }}</td>
</tr>
<tr>
<th scope="row">{% trans "Full Name" %}</th>
<td>{{ object.get_full_name|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Email" %}</th>
<td>{{ object.email|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Account Created" %}</th>
<td>{{ object.date_joined|annotated_date }}</td>
</tr>
<tr>
<th scope="row">{% trans "Active" %}</th>
<td>{% checkmark object.active %}</td>
</tr>
<tr>
<th scope="row">{% trans "Staff" %}</th>
<td>{% checkmark object.is_staff %}</td>
</tr>
<tr>
<th scope="row">{% trans "Superuser" %}</th>
<td>{% checkmark object.is_superuser %}</td>
</tr>
</table>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card">
<h5 class="card-header">{% trans "Assigned Groups" %}</h5>
<div class="list-group list-group-flush">
{% for group in object.groups.all %}
<a href="{% url 'users:netboxgroup' pk=group.pk %}" class="list-group-item list-group-item-action">{{ group }}</a>
{% empty %}
<div class="list-group-item text-muted">{% trans "None" %}</div>
{% endfor %}
</div>
</div>
<div class="card">
<h5 class="card-header">{% trans "Assigned Permissions" %}</h5>
<div class="list-group list-group-flush">
{% for perm in object.object_permissions.all %}
<a href="{% url 'users:objectpermission' pk=perm.pk %}" class="list-group-item list-group-item-action">{{ perm }}</a>
{% empty %}
<div class="list-group-item text-muted">{% trans "None" %}</div>
{% endfor %}
</div>
</div>
</div>
</div>
{% if perms.extras.view_objectchange %}
<div class="row">
<div class="col-md-12">
<div class="card">
<h5 class="card-header text-center">{% trans "Recent Activity" %}</h5>
<div class="card-body table-responsive">
{% render_table changelog_table 'inc/table.html' %}
</div>
</div>
</div>
</div>
{% endif %}
{% endblock %}
Loading