admin.py 1.38 KB
Newer Older
1
2
3
4
5
# Future Imports
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)

# Django Imports
6
from django.contrib import admin
7
8

# App Imports
David Haynes's avatar
David Haynes committed
9
from .models import Facility, Schedule, OpenTime, Category, Location
10
11
12

class OpenTimeInline(admin.TabularInline):
    model = OpenTime
13
    fk_name = 'schedule'
14
    max_num = 7
15

Ben Waters's avatar
Ben Waters committed
16
17
class OpenTimeAdmin(admin.ModelAdmin):
    pass
18

Ben Waters's avatar
Ben Waters committed
19
class FacilityAdmin(admin.ModelAdmin):
20
    model = Facility
David Haynes's avatar
David Haynes committed
21
22
    list_display = ['name', ]
    list_filter = ['facility_category', 'facility_location']
23
24
    fieldsets = (
        (None, {
David Haynes's avatar
David Haynes committed
25
26
            'fields': ('name', 'facility_category', 'facility_location',
                       'main_schedule', 'special_schedules', ),
27
28
        }),
        ('Advanced', {
David Haynes's avatar
David Haynes committed
29
30
            'fields': ('owners', ),
            'classes': ('collapse', ),
31
        }),
32
    )
33
34

class ScheduleAdmin(admin.ModelAdmin):
35
    list_display = ['name', 'modified']
36
    inlines = [OpenTimeInline, ]
37
38
    fieldsets = (
        (None, {
39
40
            # (name, (start, end))
            'fields': ('name', ('valid_start', 'valid_end'))
David Haynes's avatar
David Haynes committed
41
        }),
42
    )
43

Benjamin S Waters's avatar
Benjamin S Waters committed
44
45
class CategoryAdmin(admin.ModelAdmin):
    pass
46

David Haynes's avatar
David Haynes committed
47
48
49
class LocationAdmin(admin.ModelAdmin):
    pass

Ben Waters's avatar
Ben Waters committed
50
admin.site.register(Facility, FacilityAdmin)
51
admin.site.register(Schedule, ScheduleAdmin)
Benjamin S Waters's avatar
Benjamin S Waters committed
52
admin.site.register(Category, CategoryAdmin)
David Haynes's avatar
David Haynes committed
53
admin.site.register(Location, LocationAdmin)