Commit 2b501ced by Őry Máté

one: add full names to admin

parent 3fd9cafc
...@@ -5,6 +5,11 @@ from django.utils.translation import ugettext_lazy as _ ...@@ -5,6 +5,11 @@ from django.utils.translation import ugettext_lazy as _
from one import models from one import models
import string import string
def owner_person(obj):
p = obj.owner
return "%s %s (%s)" % (p.last_name, p.first_name, p.username)
owner_person.short_description = _('owner')
class PersonInline(contrib.admin.StackedInline): class PersonInline(contrib.admin.StackedInline):
model = models.Person model = models.Person
max_num = 1 max_num = 1
...@@ -47,13 +52,13 @@ submit_vm.short_description = _('Submit VM') ...@@ -47,13 +52,13 @@ submit_vm.short_description = _('Submit VM')
class TemplateAdmin(contrib.admin.ModelAdmin): class TemplateAdmin(contrib.admin.ModelAdmin):
model=models.Template model=models.Template
list_display = ('name', 'state', 'owner', 'system', 'public') list_display = ('name', 'state', owner_person, 'system', 'public')
list_filter = ('owner', 'public') list_filter = ('owner', 'public')
class InstanceAdmin(contrib.admin.ModelAdmin): class InstanceAdmin(contrib.admin.ModelAdmin):
model=models.Instance model=models.Instance
actions = [update_state, submit_vm] actions = [update_state, submit_vm]
list_display = ('id', 'name', 'owner', 'state') list_display = ('id', 'name', owner_person, 'state')
readonly_fields = ('ip', 'active_since', 'pw', 'template') readonly_fields = ('ip', 'active_since', 'pw', 'template')
list_filter = ('owner', 'template', 'state') list_filter = ('owner', 'template', 'state')
...@@ -64,7 +69,7 @@ class NetworkAdmin(contrib.admin.ModelAdmin): ...@@ -64,7 +69,7 @@ class NetworkAdmin(contrib.admin.ModelAdmin):
class ShareAdmin(contrib.admin.ModelAdmin): class ShareAdmin(contrib.admin.ModelAdmin):
model=models.Network model=models.Network
list_filter = ('group', 'template', ) list_filter = ('group', 'template', )
list_display = ('name', 'owner', 'template', 'group', ) list_display = ('name', owner_person, 'template', 'group', )
contrib.admin.site.register(models.Template, TemplateAdmin) contrib.admin.site.register(models.Template, TemplateAdmin)
contrib.admin.site.register(models.Instance, InstanceAdmin) contrib.admin.site.register(models.Instance, InstanceAdmin)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment