admin.py 1.34 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
Benjamin S Waters's avatar
Benjamin S Waters committed
9
from .models import Facility, Schedule, OpenTime, Category
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
21
22
    model = Facility
    list_display = ['name', 'location' ]
    list_filter = ['facility_category', ]
23
24
25
    fieldsets = (
        (None, {
             'fields': ('name', 'facility_category',
26
27
28
29
30
31
32
                        ('location', 'on_campus'),
                        'main_schedule', 'special_schedules', ),
        }),
        ('Advanced', {
             'fields': ('owners', ),
             'classes': ('collapse', ),
        }),
33
    )
34
35

class ScheduleAdmin(admin.ModelAdmin):
36
    list_display = ['name', 'modified']
37
    inlines = [OpenTimeInline, ]
38
39
40
41
42
43
    fieldsets = (
        (None, {
             'fields': ('name',
                       ('valid_start', 'valid_end'),)
               }),
    )
44

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

Ben Waters's avatar
Ben Waters committed
48
admin.site.register(Facility, FacilityAdmin)
49
admin.site.register(Schedule, ScheduleAdmin)
50
#admin.site.register(OpenTime, OpenTimeAdmin)
Benjamin S Waters's avatar
Benjamin S Waters committed
51
admin.site.register(Category, CategoryAdmin)