Blame view

src/pyrosapp/admin.py 3.87 KB
509509a8   haribo   Replacing admin.p...
1
from django import forms
64501c9d   Etienne Pallier   first full projec...
2
from django.contrib import admin
509509a8   haribo   Replacing admin.p...
3
from pyrosapp.models import *
64501c9d   Etienne Pallier   first full projec...
4

509509a8   haribo   Replacing admin.p...
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# Many To Many interface adapter

class UserAndSPInline(admin.TabularInline):
    model = ScientificProgram.users.through

class SequenceAndSHInline(admin.TabularInline):
    model = ScheduleHistory.sequences.through

class ScheduleHistoryAdmin(admin.ModelAdmin):
    inlines = [
        SequenceAndSHInline,
    ]
    exclude = ('sequences',)


# One To Many interface adapters

class SequenceInline(admin.TabularInline):
    model = Sequence
    fields = ("name",)
    show_change_link = True

class RequestInline(admin.TabularInline):
    model = Request
    fields = ("name",)
    show_change_link = True

class AlbumInline(admin.TabularInline):
    model = Album
    fields = ("name",)
    show_change_link = True

class PlanInline(admin.TabularInline):
    model = Plan
    fields = ("name",)
    show_change_link = True

class ImageInline(admin.TabularInline):
    model = Image
    fields = ("name",)
    show_change_link = True

class DetectorInline(admin.TabularInline):
    model = Detector
    fields = ("name",)
    show_change_link = True

class UserInline(admin.TabularInline):
    model = User
    fields = ("name",)
    show_change_link = True

class FilterInline(admin.TabularInline):
    model = Filter
    fields = ("name",)
    show_change_link = True

class AlertInline(admin.TabularInline):
    model = Alert
    fields = ("request.name",)
    show_change_link = True



class RequestAdmin(admin.ModelAdmin):
    inlines = [
        SequenceInline,
    ]

class ScheduleAdmin(admin.ModelAdmin):
    inlines = [
        SequenceInline,
    ]

class SequenceAdmin(admin.ModelAdmin):
    inlines = [
        AlbumInline,
        SequenceAndSHInline, # for M2M interface
    ]

class UserAdmin(admin.ModelAdmin):
    inlines = [
        RequestInline,
        UserAndSPInline, # for M2M interface
    ]

class StrategyObsAdmin(admin.ModelAdmin):
    inlines = [
        AlertInline,
    ]

class ScientificProgramAdmin(admin.ModelAdmin):
    inlines = [
        RequestInline,
        UserAndSPInline, # for M2M interface
    ]
    exclude = ('users',) # for M2M interface

class CountryAdmin(admin.ModelAdmin):
    inlines = [
        UserInline,
    ]

class UserLevelAdmin(admin.ModelAdmin):
    inlines = [
        UserInline,
    ]

class FilterAdmin(admin.ModelAdmin):
    inlines = [
        PlanInline,
    ]

class NrtAnalysisAdmin(admin.ModelAdmin):
    inlines = [
        ImageInline,
    ]

class DetectorAdmin(admin.ModelAdmin):
    inlines = [
        FilterInline,
        AlbumInline,
    ]

class TelescopeAdmin(admin.ModelAdmin):
    inlines = [
        DetectorInline,
    ]

class PlanAdmin(admin.ModelAdmin):
    inlines = [
        ImageInline,
    ]

class AlbumAdmin(admin.ModelAdmin):
    inlines = [
        PlanInline,
    ]

class SequenceTypeAdmin(admin.ModelAdmin):
    inlines = [
        SequenceInline,
    ]


# Link the models to the admin interface

admin.site.register(Album, AlbumAdmin)
admin.site.register(Alert)
admin.site.register(Country, CountryAdmin)
admin.site.register(Detector, DetectorAdmin)
admin.site.register(Device)
admin.site.register(Filter, FilterAdmin)
admin.site.register(Image)
admin.site.register(NrtAnalysis, NrtAnalysisAdmin)
admin.site.register(Plan, PlanAdmin)
admin.site.register(Request, RequestAdmin)
admin.site.register(Schedule, ScheduleAdmin)
admin.site.register(ScheduleHistory, ScheduleHistoryAdmin)
admin.site.register(ScientificProgram, ScientificProgramAdmin)
admin.site.register(Sequence, SequenceAdmin)
admin.site.register(SequenceType, SequenceTypeAdmin)
admin.site.register(SiteWatch)
admin.site.register(SiteWatchHistory)
admin.site.register(StrategyObs, StrategyObsAdmin)
admin.site.register(Telescope, TelescopeAdmin)
admin.site.register(User, UserAdmin)
admin.site.register(UserLevel, UserLevelAdmin)
admin.site.register(WeatherWatch)
admin.site.register(WeatherWatchHistory)