blechreiz-website/musicians/admin.py

42 lines
1023 B
Python

from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from django.utils.translation import ugettext as _
from musicians.models import Musician, PhoneNumber
from eventplanner.admin import EventParticipationInline
class PhoneNumberInline( admin.TabularInline ):
model = PhoneNumber
extra = 3
# Define an inline admin descriptor for Musician model
# which acts a bit like a singleton
class MusicianInline( admin.StackedInline ):
model = Musician
can_delete = False
verbose_name_plural = _('musicians')
verbose_name = _('musician')
# Define a new User admin
class UserAdmin( UserAdmin ):
inlines = (MusicianInline, PhoneNumberInline, )
class MusicianAdmin(admin.ModelAdmin):
readonly_fields = ('user',)
inlines = ( EventParticipationInline, )
model = Musician
# Re-register UserAdmin
admin.site.unregister( User )
admin.site.register(User, UserAdmin)
admin.site.register( Musician, MusicianAdmin )