2009-01-16 16:32:31 +01:00
|
|
|
from django.contrib import admin
|
|
|
|
|
2011-10-13 20:51:33 +02:00
|
|
|
from . import models
|
|
|
|
|
2009-01-16 16:32:31 +01:00
|
|
|
|
|
|
|
class WidgetAdmin(admin.AdminSite):
|
|
|
|
pass
|
|
|
|
|
2013-10-10 22:42:30 +02:00
|
|
|
|
2009-03-31 01:16:34 +02:00
|
|
|
class CarAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ['make', 'model', 'owner']
|
|
|
|
list_editable = ['owner']
|
2009-01-16 16:32:31 +01:00
|
|
|
|
2013-10-10 22:42:30 +02:00
|
|
|
|
2009-01-16 16:32:31 +01:00
|
|
|
class CarTireAdmin(admin.ModelAdmin):
|
|
|
|
def formfield_for_foreignkey(self, db_field, request, **kwargs):
|
|
|
|
if db_field.name == "car":
|
|
|
|
kwargs["queryset"] = models.Car.objects.filter(owner=request.user)
|
|
|
|
return db_field.formfield(**kwargs)
|
|
|
|
return super(CarTireAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)
|
|
|
|
|
2013-10-10 22:42:30 +02:00
|
|
|
|
2010-03-02 03:28:49 +01:00
|
|
|
class EventAdmin(admin.ModelAdmin):
|
2013-08-05 01:06:47 +02:00
|
|
|
raw_id_fields = ['main_band', 'supporting_bands']
|
2010-03-02 03:28:49 +01:00
|
|
|
|
2012-02-23 09:07:07 +01:00
|
|
|
|
|
|
|
class SchoolAdmin(admin.ModelAdmin):
|
|
|
|
filter_vertical = ('students',)
|
|
|
|
filter_horizontal = ('alumni',)
|
|
|
|
|
2009-07-16 18:16:13 +02:00
|
|
|
site = WidgetAdmin(name='widget-admin')
|
2009-01-16 16:32:31 +01:00
|
|
|
|
2009-03-31 01:16:34 +02:00
|
|
|
site.register(models.User)
|
|
|
|
site.register(models.Car, CarAdmin)
|
2009-01-16 16:32:31 +01:00
|
|
|
site.register(models.CarTire, CarTireAdmin)
|
2011-08-02 01:38:11 +02:00
|
|
|
|
|
|
|
site.register(models.Member)
|
|
|
|
site.register(models.Band)
|
2010-03-02 03:28:49 +01:00
|
|
|
site.register(models.Event, EventAdmin)
|
2011-08-02 01:38:11 +02:00
|
|
|
site.register(models.Album)
|
|
|
|
|
|
|
|
site.register(models.Inventory)
|
|
|
|
|
|
|
|
site.register(models.Bee)
|
|
|
|
|
|
|
|
site.register(models.Advisor)
|
2012-02-23 09:07:07 +01:00
|
|
|
|
2013-07-29 19:19:04 +02:00
|
|
|
site.register(models.School, SchoolAdmin)
|
2013-09-07 18:52:14 +02:00
|
|
|
|
2013-10-10 22:42:30 +02:00
|
|
|
site.register(models.Profile)
|