from django import forms from django.contrib import admin from pyrosapp.models import * # 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)