gestioCOF/gestion/admin.py

70 lines
1.2 KiB
Python
Raw Normal View History

from django.contrib import admin
2017-02-18 19:06:43 +01:00
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from .models import (
Profile, Club, Event,
EventOption, EventCommentField, EventOptionChoice
)
2017-02-18 19:06:43 +01:00
2017-02-20 01:16:50 +01:00
# ---
# The user related stuff
# ---
2017-02-18 19:06:43 +01:00
class ProfileInline(admin.StackedInline):
model = Profile
inline_classes = ["collapse open"]
class UserProfileAdmin(UserAdmin):
inlines = [
ProfileInline,
]
admin.site.unregister(User)
admin.site.register(User, UserProfileAdmin)
2017-02-18 19:06:43 +01:00
2017-02-20 01:16:50 +01:00
# ---
# 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,
]