2017-02-09 21:04:32 +01:00
|
|
|
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
|
2017-02-09 21:04:32 +01:00
|
|
|
|
2017-03-18 21:48:45 +01:00
|
|
|
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,
|
|
|
|
]
|
|
|
|
|
2017-03-18 21:48:45 +01:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2017-03-18 21:48:45 +01:00
|
|
|
# ---
|
|
|
|
# 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,
|
|
|
|
]
|