mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-17 04:32:51 -06:00
Show user config in admin UI
This commit is contained in:
parent
750deac2cf
commit
afa0565a44
@ -3,17 +3,25 @@ from django.contrib import admin
|
|||||||
from django.contrib.auth.admin import UserAdmin as UserAdmin_
|
from django.contrib.auth.admin import UserAdmin as UserAdmin_
|
||||||
from django.contrib.auth.models import User
|
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
|
# Unregister the built-in UserAdmin so that we can use our custom admin view below
|
||||||
admin.site.unregister(User)
|
admin.site.unregister(User)
|
||||||
|
|
||||||
|
|
||||||
|
class UserConfigInline(admin.TabularInline):
|
||||||
|
model = UserConfig
|
||||||
|
readonly_fields = ('data',)
|
||||||
|
can_delete = False
|
||||||
|
verbose_name = 'Preferences'
|
||||||
|
|
||||||
|
|
||||||
@admin.register(User)
|
@admin.register(User)
|
||||||
class UserAdmin(UserAdmin_):
|
class UserAdmin(UserAdmin_):
|
||||||
list_display = [
|
list_display = [
|
||||||
'username', 'email', 'first_name', 'last_name', 'is_superuser', 'is_staff', 'is_active'
|
'username', 'email', 'first_name', 'last_name', 'is_superuser', 'is_staff', 'is_active'
|
||||||
]
|
]
|
||||||
|
inlines = (UserConfigInline,)
|
||||||
|
|
||||||
|
|
||||||
class TokenAdminForm(forms.ModelForm):
|
class TokenAdminForm(forms.ModelForm):
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
# Generated by Django 3.0.5 on 2020-04-23 15:49
|
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
import django.contrib.postgres.fields.jsonb
|
import django.contrib.postgres.fields.jsonb
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
@ -23,6 +21,8 @@ class Migration(migrations.Migration):
|
|||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'ordering': ['user'],
|
'ordering': ['user'],
|
||||||
|
'verbose_name': 'User Preferences',
|
||||||
|
'verbose_name_plural': 'User Preferences'
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
@ -29,6 +29,7 @@ class UserConfig(models.Model):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['user']
|
ordering = ['user']
|
||||||
|
verbose_name = verbose_name_plural = 'User Preferences'
|
||||||
|
|
||||||
def get(self, path):
|
def get(self, path):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user