gestioCOF/gestion/admin.py
Martin Pépin 745e7a1c0c register the events stuff into the admin site
A simple admin interface which may be modified later
2017-04-01 14:26:05 +01:00

69 lines
1.2 KiB
Python

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,
]