mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-13 16:47:34 -06:00
Merge pull request #19630 from netbox-community/19599-user-changelog-sorting
Fixes #19599: Prevent exception when sorting user's recent activity
This commit is contained in:
commit
5fe5b2e7c4
@ -191,12 +191,9 @@ class ProfileView(LoginRequiredMixin, View):
|
|||||||
def get(self, request):
|
def get(self, request):
|
||||||
|
|
||||||
# Compile changelog table
|
# Compile changelog table
|
||||||
changelog = ObjectChange.objects.valid_models().restrict(request.user, 'view').filter(
|
changelog = ObjectChange.objects.valid_models().restrict(request.user, 'view').filter(user=request.user)[:20]
|
||||||
user=request.user
|
|
||||||
).prefetch_related(
|
|
||||||
'changed_object_type'
|
|
||||||
)[:20]
|
|
||||||
changelog_table = ObjectChangeTable(changelog)
|
changelog_table = ObjectChangeTable(changelog)
|
||||||
|
changelog_table.orderable = False
|
||||||
changelog_table.configure(request)
|
changelog_table.configure(request)
|
||||||
|
|
||||||
return render(request, self.template_name, {
|
return render(request, self.template_name, {
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
{% extends 'account/base.html' %}
|
{% extends 'account/base.html' %}
|
||||||
{% load helpers %}
|
|
||||||
{% load render_table from django_tables2 %}
|
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% block title %}{% trans "User Profile" %}{% endblock %}
|
{% block title %}{% trans "User Profile" %}{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row mb-3">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h2 class="card-header">{% trans "Account Details" %}</h2>
|
<h2 class="card-header">{% trans "Account Details" %}</h2>
|
||||||
@ -64,12 +62,7 @@
|
|||||||
{% if perms.core.view_objectchange %}
|
{% if perms.core.view_objectchange %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="card">
|
{% include 'users/inc/user_activity.html' with user=user table=changelog_table %}
|
||||||
<h2 class="card-header text-center">{% trans "Recent Activity" %}</h2>
|
|
||||||
<div class="table-responsive">
|
|
||||||
{% render_table changelog_table 'inc/table.html' %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
16
netbox/templates/users/inc/user_activity.html
Normal file
16
netbox/templates/users/inc/user_activity.html
Normal file
@ -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>
|
@ -1,14 +1,12 @@
|
|||||||
{% extends 'generic/object.html' %}
|
{% extends 'generic/object.html' %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load helpers %}
|
|
||||||
{% load render_table from django_tables2 %}
|
|
||||||
|
|
||||||
{% block title %}{% trans "User" %} {{ object.username }}{% endblock %}
|
{% block title %}{% trans "User" %} {{ object.username }}{% endblock %}
|
||||||
|
|
||||||
{% block subtitle %}{% endblock %}
|
{% block subtitle %}{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row mb-3">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h2 class="card-header">{% trans "User" %}</h2>
|
<h2 class="card-header">{% trans "User" %}</h2>
|
||||||
@ -74,12 +72,7 @@
|
|||||||
{% if perms.core.view_objectchange %}
|
{% if perms.core.view_objectchange %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="card">
|
{% include 'users/inc/user_activity.html' with user=object table=changelog_table %}
|
||||||
<h2 class="text-center">{% trans "Recent Activity" %}</h2>
|
|
||||||
<div class="card-body table-responsive">
|
|
||||||
{% render_table changelog_table 'inc/table.html' %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -75,8 +75,9 @@ class UserView(generic.ObjectView):
|
|||||||
template_name = 'users/user.html'
|
template_name = 'users/user.html'
|
||||||
|
|
||||||
def get_extra_context(self, request, instance):
|
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 = ObjectChangeTable(changelog)
|
||||||
|
changelog_table.orderable = False
|
||||||
changelog_table.configure(request)
|
changelog_table.configure(request)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user