from django.contrib import admin from django.contrib.auth.admin import UserAdmin from django.contrib.auth.models import User from .models import ( Profile, Club, Event, EventOption, EventCommentField, EventOptionChoice ) # --- # The user related stuff # --- class ProfileInline(admin.StackedInline): model = Profile inline_classes = ["collapse open"] class UserProfileAdmin(UserAdmin): inlines = [ ProfileInline, ] admin.site.unregister(User) admin.site.register(User, UserProfileAdmin) # --- # Clubs # --- @admin.register(Club) class ClubAdmin(admin.ModelAdmin): pass # --- # Events # --- class EventOptionChoiceInline(admin.TabularInline): model = EventOptionChoice class EventOptionInline(admin.TabularInline): model = EventOption show_change_link = True class EventCommentFieldInline(admin.TabularInline): model = EventCommentField @admin.register(EventOption) class EventOptionAdmin(admin.ModelAdmin): search_fields = ('event__title', 'name') inlines = [ EventOptionChoiceInline, ] @admin.register(Event) class EventAdmin(admin.ModelAdmin): search_fields = ['title', 'location', 'description'] inlines = [ EventOptionInline, EventCommentFieldInline, ]