Skip to content

Commit e5e7a66

Browse files
committed
Apply fix to user view as well
1 parent 357ae44 commit e5e7a66

File tree

5 files changed

+23
-31
lines changed

5 files changed

+23
-31
lines changed

netbox/account/views.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,7 @@ class ProfileView(LoginRequiredMixin, View):
191191
def get(self, request):
192192

193193
# Compile changelog table
194-
changelog = ObjectChange.objects.valid_models().restrict(request.user, 'view').filter(
195-
user=request.user
196-
).prefetch_related(
197-
'changed_object_type'
198-
)[:20]
194+
changelog = ObjectChange.objects.valid_models().restrict(request.user, 'view').filter(user=request.user)[:20]
199195
changelog_table = ObjectChangeTable(changelog)
200196
changelog_table.orderable = False
201197
changelog_table.configure(request)

netbox/templates/account/profile.html

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
{% extends 'account/base.html' %}
2-
{% load helpers %}
3-
{% load render_table from django_tables2 %}
42
{% load i18n %}
53

64
{% block title %}{% trans "User Profile" %}{% endblock %}
75

86
{% block content %}
9-
<div class="row mb-3">
7+
<div class="row">
108
<div class="col-md-6">
119
<div class="card">
1210
<h2 class="card-header">{% trans "Account Details" %}</h2>
@@ -64,19 +62,7 @@ <h2 class="card-header">{% trans "Assigned Groups" %}</h2>
6462
{% if perms.core.view_objectchange %}
6563
<div class="row">
6664
<div class="col-md-12">
67-
<div class="card">
68-
<h2 class="card-header text-center">
69-
{% trans "Recent Activity" %}
70-
<div class="card-actions">
71-
<a href="{% url 'core:objectchange_list' %}?user_id={{ request.user.pk }}" class="btn btn-ghost-primary btn-sm">
72-
<i class="mdi mdi-arrow-right-thick" aria-hidden="true"></i> {% trans "View All" %}
73-
</a>
74-
</div>
75-
</h2>
76-
<div class="table-responsive">
77-
{% render_table changelog_table 'inc/table.html' %}
78-
</div>
79-
</div>
65+
{% include 'users/inc/user_activity.html' with user=user table=changelog_table %}
8066
</div>
8167
</div>
8268
{% endif %}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{% load i18n %}
2+
{% load render_table from django_tables2 %}
3+
4+
<div class="card">
5+
<h2 class="card-header text-center">
6+
{% trans "Recent Activity" %}
7+
<div class="card-actions">
8+
<a href="{% url 'core:objectchange_list' %}?user_id={{ user.pk }}" class="btn btn-ghost-primary btn-sm">
9+
<i class="mdi mdi-arrow-right-thick" aria-hidden="true"></i> {% trans "View All" %}
10+
</a>
11+
</div>
12+
</h2>
13+
<div class="table-responsive">
14+
{% render_table table 'inc/table.html' %}
15+
</div>
16+
</div>

netbox/templates/users/user.html

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
{% extends 'generic/object.html' %}
22
{% load i18n %}
3-
{% load helpers %}
4-
{% load render_table from django_tables2 %}
53

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

86
{% block subtitle %}{% endblock %}
97

108
{% block content %}
11-
<div class="row mb-3">
9+
<div class="row">
1210
<div class="col-md-6">
1311
<div class="card">
1412
<h2 class="card-header">{% trans "User" %}</h2>
@@ -74,12 +72,7 @@ <h2 class="card-header">{% trans "Assigned Permissions" %}</h2>
7472
{% if perms.core.view_objectchange %}
7573
<div class="row">
7674
<div class="col-md-12">
77-
<div class="card">
78-
<h2 class="text-center">{% trans "Recent Activity" %}</h2>
79-
<div class="card-body table-responsive">
80-
{% render_table changelog_table 'inc/table.html' %}
81-
</div>
82-
</div>
75+
{% include 'users/inc/user_activity.html' with user=object table=changelog_table %}
8376
</div>
8477
</div>
8578
{% endif %}

netbox/users/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ class UserView(generic.ObjectView):
7575
template_name = 'users/user.html'
7676

7777
def get_extra_context(self, request, instance):
78-
changelog = ObjectChange.objects.restrict(request.user, 'view').filter(user=instance)[:20]
78+
changelog = ObjectChange.objects.valid_models().restrict(request.user, 'view').filter(user=instance)[:20]
7979
changelog_table = ObjectChangeTable(changelog)
80+
changelog_table.orderable = False
8081
changelog_table.configure(request)
8182

8283
return {

0 commit comments

Comments
 (0)