1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Show user config in admin UI

This commit is contained in:
Jeremy Stretch
2020-04-23 15:53:43 -04:00
parent 750deac2cf
commit afa0565a44
3 changed files with 12 additions and 3 deletions

View File

@ -3,17 +3,25 @@ from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as UserAdmin_
from django.contrib.auth.models import User
from .models import Token
from .models import Token, UserConfig
# Unregister the built-in UserAdmin so that we can use our custom admin view below
admin.site.unregister(User)
class UserConfigInline(admin.TabularInline):
model = UserConfig
readonly_fields = ('data',)
can_delete = False
verbose_name = 'Preferences'
@admin.register(User)
class UserAdmin(UserAdmin_):
list_display = [
'username', 'email', 'first_name', 'last_name', 'is_superuser', 'is_staff', 'is_active'
]
inlines = (UserConfigInline,)
class TokenAdminForm(forms.ModelForm):

View File

@ -1,5 +1,3 @@
# Generated by Django 3.0.5 on 2020-04-23 15:49
from django.conf import settings
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
@ -23,6 +21,8 @@ class Migration(migrations.Migration):
],
options={
'ordering': ['user'],
'verbose_name': 'User Preferences',
'verbose_name_plural': 'User Preferences'
},
),
]

View File

@ -29,6 +29,7 @@ class UserConfig(models.Model):
class Meta:
ordering = ['user']
verbose_name = verbose_name_plural = 'User Preferences'
def get(self, path):
"""