Repository: netbox-community/netbox

Issue:
Display friendly username in ChangeLog
### NetBox version

v3.1.7

### Feature type

Change to existing functionality

### Proposed functionality

Display friendly user name besides of its raw username, in Change Logs.

In ChangeLog tables, "username - 2020-06-23 14:41" would become "First Last (@username) - 2020-06-23 14:41"

### Use case

We usually need to easily identify which real person is behind a username, to discuss a change with a team-mate or to solve an issue. In corporate Active Directory environment, we sometimes end up with dumb usernames, by chance this comes with the person real name. To display this person real name alongside with its raw username in ChangeLogs would ease this identification.

### Database changes

None

### External dependencies

None


Discussion:
> In corporate Active Directory environment, we sometimes end up with dumb usernames, by chance this comes with the person real name.

In most cases, displaying the username is going to be sufficient. To accommodate your use case, it would be reasonable to add an alternative column which renders the user's complete name (where available) that can be swapped in for the default username. However, the current default of displaying on the username should be retained.
I like what you suggest @jeremystretch , and it sounds way better than what I implemented.

From the GUI at "Other > Change Log", I reconfigured the columns, but it doesn't seem to alter the changelog table as shown in the homepage. Can this be changed ?

Other question: Can we pre-configure tables for all users ?
> From the GUI at "Other > Change Log", I reconfigured the columns, but it doesn't seem to alter the changelog table as shown in the homepage. Can this be changed ?

Yep, that's a bug; I've opened #8578 for that. (The dedicated change log view will render the table correctly but the home view does not.) Thanks for the catch!

> Other question: Can we pre-configure tables for all users ?

This will be supported in NetBox v3.2 under FR #7759: Defining a `DEFAULT_USER_PREFERENCES` parameter will allow administrators to define the default columns and ordering for individual tables.

Resolving patch:
diff --git a/netbox/extras/tables.py b/netbox/extras/tables.py
--- a/netbox/extras/tables.py
+++ b/netbox/extras/tables.py
@@ -29,6 +29,14 @@
 {% endif %}
 """
 
+OBJECTCHANGE_FULL_NAME = """
+{% if record.user.first_name or record.user.last_name %}
+    {{ record.user.first_name }} {{ record.user.last_name }}
+{% else %}
+    {{ record.user|default:record.user_name }}
+{% endif %}
+"""
+
 OBJECTCHANGE_OBJECT = """
 {% if record.changed_object and record.changed_object.get_absolute_url %}
     <a href="{{ record.changed_object.get_absolute_url }}">{{ record.object_repr }}</a>
@@ -204,6 +212,14 @@ class ObjectChangeTable(BaseTable):
         linkify=True,
         format=settings.SHORT_DATETIME_FORMAT
     )
+    user_name = tables.Column(
+        verbose_name='Username'
+    )
+    full_name = tables.TemplateColumn(
+        template_code=OBJECTCHANGE_FULL_NAME,
+        verbose_name='Full Name',
+        orderable=False
+    )
     action = ChoiceFieldColumn()
     changed_object_type = ContentTypeColumn(
         verbose_name='Type'
@@ -219,7 +235,7 @@ class ObjectChangeTable(BaseTable):
 
     class Meta(BaseTable.Meta):
         model = ObjectChange
-        fields = ('id', 'time', 'user_name', 'action', 'changed_object_type', 'object_repr', 'request_id')
+        fields = ('id', 'time', 'user_name', 'full_name', 'action', 'changed_object_type', 'object_repr', 'request_id')
 
 
 class ObjectJournalTable(BaseTable):


Test patch: