Skip to content
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
7 changes: 2 additions & 5 deletions netbox/account/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,9 @@ class ProfileView(LoginRequiredMixin, View):
def get(self, request):

# Compile changelog table
changelog = ObjectChange.objects.valid_models().restrict(request.user, 'view').filter(
user=request.user
).prefetch_related(
'changed_object_type'
)[:20]
changelog = ObjectChange.objects.valid_models().restrict(request.user, 'view').filter(user=request.user)[:20]
changelog_table = ObjectChangeTable(changelog)
changelog_table.orderable = False
changelog_table.configure(request)

return render(request, self.template_name, {
Expand Down
11 changes: 2 additions & 9 deletions netbox/templates/account/profile.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{% extends 'account/base.html' %}
{% load helpers %}
{% load render_table from django_tables2 %}
{% load i18n %}

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

{% block content %}
<div class="row mb-3">
<div class="row">
<div class="col-md-6">
<div class="card">
<h2 class="card-header">{% trans "Account Details" %}</h2>
Expand Down Expand Up @@ -64,12 +62,7 @@ <h2 class="card-header">{% trans "Assigned Groups" %}</h2>
{% if perms.core.view_objectchange %}
<div class="row">
<div class="col-md-12">
<div class="card">
<h2 class="card-header text-center">{% trans "Recent Activity" %}</h2>
<div class="table-responsive">
{% render_table changelog_table 'inc/table.html' %}
</div>
</div>
{% include 'users/inc/user_activity.html' with user=user table=changelog_table %}
</div>
</div>
{% endif %}
Expand Down
16 changes: 16 additions & 0 deletions netbox/templates/users/inc/user_activity.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% load i18n %}
{% load render_table from django_tables2 %}

<div class="card">
<h2 class="card-header text-center">
{% trans "Recent Activity" %}
<div class="card-actions">
<a href="{% url 'core:objectchange_list' %}?user_id={{ user.pk }}" class="btn btn-ghost-primary btn-sm">
<i class="mdi mdi-arrow-right-thick" aria-hidden="true"></i> {% trans "View All" %}
</a>
</div>
</h2>
<div class="table-responsive">
{% render_table table 'inc/table.html' %}
</div>
</div>
11 changes: 2 additions & 9 deletions netbox/templates/users/user.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
{% 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="row">
<div class="col-md-6">
<div class="card">
<h2 class="card-header">{% trans "User" %}</h2>
Expand Down Expand Up @@ -74,12 +72,7 @@ <h2 class="card-header">{% trans "Assigned Permissions" %}</h2>
{% if perms.core.view_objectchange %}
<div class="row">
<div class="col-md-12">
<div class="card">
<h2 class="text-center">{% trans "Recent Activity" %}</h2>
<div class="card-body table-responsive">
{% render_table changelog_table 'inc/table.html' %}
</div>
</div>
{% include 'users/inc/user_activity.html' with user=object table=changelog_table %}
</div>
</div>
{% endif %}
Expand Down
3 changes: 2 additions & 1 deletion netbox/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ class UserView(generic.ObjectView):
template_name = 'users/user.html'

def get_extra_context(self, request, instance):
changelog = ObjectChange.objects.restrict(request.user, 'view').filter(user=instance)[:20]
changelog = ObjectChange.objects.valid_models().restrict(request.user, 'view').filter(user=instance)[:20]
changelog_table = ObjectChangeTable(changelog)
changelog_table.orderable = False
changelog_table.configure(request)

return {
Expand Down
Loading