2013-05-28 15:20:06 +02:00
|
|
|
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 _
|
2013-06-30 11:01:12 +02:00
|
|
|
from musicians.models import Musician
|
2019-01-05 11:27:15 +01:00
|
|
|
# from eventplanner.admin import EventParticipationInline
|
2013-05-28 15:20:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
# Define an inline admin descriptor for Musician model
|
|
|
|
# which acts a bit like a singleton
|
2019-01-05 11:27:15 +01:00
|
|
|
class MusicianInline(admin.StackedInline):
|
2013-05-28 15:20:06 +02:00
|
|
|
model = Musician
|
|
|
|
can_delete = False
|
|
|
|
verbose_name_plural = _('musicians')
|
|
|
|
verbose_name = _('musician')
|
2013-06-02 16:00:01 +02:00
|
|
|
|
|
|
|
|
2019-01-05 11:27:15 +01:00
|
|
|
# Define a new User admin
|
|
|
|
class UserAdmin(UserAdmin):
|
|
|
|
inlines = (MusicianInline,)
|
|
|
|
|
2013-06-02 16:00:01 +02:00
|
|
|
|
|
|
|
class MusicianAdmin(admin.ModelAdmin):
|
|
|
|
readonly_fields = ('user',)
|
2019-01-05 11:27:15 +01:00
|
|
|
# inlines = ( EventParticipationInline, )
|
2013-06-02 16:00:01 +02:00
|
|
|
model = Musician
|
|
|
|
|
2013-05-28 15:20:06 +02:00
|
|
|
|
|
|
|
# Re-register UserAdmin
|
2019-01-05 11:27:15 +01:00
|
|
|
admin.site.unregister(User)
|
2013-05-28 15:20:06 +02:00
|
|
|
admin.site.register(User, UserAdmin)
|
2019-01-05 11:27:15 +01:00
|
|
|
admin.site.register(Musician, MusicianAdmin)
|