You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

118 lines
3.7 KiB

# -*- coding: utf-8 -*-
from django.contrib import admin
from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni
### Skola
class SkolaAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['nazev', 'kratky_nazev']}),
(u'Interní ID', {'fields': ['aesop_id', 'izo'], 'classes': ['collapse']}),
(u'Adresa', {'fields': ['ulice', 'mesto', 'psc', 'stat']}),
]
list_display = ['nazev', 'aesop_id', 'mesto']
search_fields = ['nazev', 'mesto', 'ulice']
admin.site.register(Skola, SkolaAdmin)
### Resitel
class ResitelAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['jmeno', 'prijmeni', 'user']}),
(u'Škola', {'fields': ['skola', 'rok_maturity']}),
(u'Seminář', {'fields': ['datum_souhlasu_udaje', 'datum_souhlasu_zasilani', 'datum_prihlaseni', 'zasilat']}),
(u'Osobní údaje', {'fields': ['pohlavi_muz', 'datum_narozeni', 'email', 'telefon']}),
(u'Adresa', {'fields': ['ulice', 'mesto', 'psc', 'stat']}),
]
list_display = ['jmeno', 'prijmeni', 'user', 'pohlavi_muz', 'skola', 'rok_maturity']
list_filter = ['pohlavi_muz', 'rok_maturity', 'zasilat']
search_fields = ['jmeno', 'prijmeni', 'ulice', 'user', 'mesto', 'email']
admin.site.register(Resitel, ResitelAdmin)
### Cislo
class CisloAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['cislo', 'rocnik']}),
(u'Data', {'fields': ['datum_vydani', 'datum_deadline']}),
]
list_display = ['kod', 'rocnik', 'cislo', 'datum_vydani', 'datum_deadline']
list_filter = ['rocnik']
admin.site.register(Cislo, CisloAdmin)
class CisloInline(admin.StackedInline):
model = Cislo
extra = 0
### Rocnik
class RocnikAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['rocnik', 'prvni_rok']}),
]
list_display = ['rocnik', 'prvni_rok']
inlines = [CisloInline]
admin.site.register(Rocnik, RocnikAdmin)
### PrilohaReseni
class PrilohaReseniAdmin(admin.ModelAdmin):
readonly_fields = ['timestamp']
fieldsets = [
(None, {'fields': ['reseni', 'soubor', 'timestamp']}),
]
list_display = ['reseni', 'soubor', 'timestamp']
list_filter = ['reseni', 'timestamp']
search_fields = []
admin.site.register(PrilohaReseni, PrilohaReseniAdmin)
class PrilohaReseniInline(admin.StackedInline):
model = PrilohaReseni
extra = 1
### Reseni
class ReseniAdmin(admin.ModelAdmin):
readonly_fields = ['timestamp']
fieldsets = [
(None, {'fields': ['problem', 'resitel', 'body', 'cislo_body', 'timestamp']}),
]
list_display = ['problem', 'resitel', 'body', 'timestamp']
list_filter = ['problem', 'resitel', 'body', 'timestamp']
search_fields = []
inlines = [PrilohaReseniInline]
admin.site.register(Reseni, ReseniAdmin)
class ReseniInline(admin.StackedInline):
model = Reseni
extra = 0
### Problem
from feincms.admin import item_editor
class ProblemAdmin(item_editor.ItemEditor):
# readonly_fields = ['autor']
fieldsets = [
(None, {'fields': ['nazev', 'typ', 'stav', 'autor']}),
(u'Vydání', {'fields': ['cislo_zadani', 'kod', 'cislo_reseni', 'opravovatel']}),
item_editor.FEINCMS_CONTENT_FIELDSET,
]
list_display = ['nazev', 'typ', 'stav', 'autor', 'kod', 'opravovatel']
list_filter = ['typ', 'stav', 'autor', 'opravovatel']
search_fields = ['nazev', 'autor', 'kod']#, 'text_problemu_org', 'text_problemu']
inlines = [ReseniInline]
admin.site.register(Problem, ProblemAdmin)