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.
 
 
 
 
 
 

159 lines
5.1 KiB

# -*- coding: utf-8 -*-
from django.contrib import admin
from django import forms
import reversion
from solo.admin import SingletonModelAdmin
from ckeditor.widgets import CKEditorWidget
from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni
### Nastaveni
admin.site.register(Nastaveni, SingletonModelAdmin)
### Skola
class SkolaAdmin(reversion.VersionAdmin):
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', 'ulice', 'stat']
search_fields = ['nazev', 'mesto', 'ulice']
admin.site.register(Skola, SkolaAdmin)
### Resitel
class ResitelAdmin(reversion.VersionAdmin):
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_display_links = ['skola']
list_filter = ['pohlavi_muz', 'rok_maturity', 'zasilat']
search_fields = ['jmeno', 'prijmeni', 'ulice', 'user', 'mesto', 'email']
admin.site.register(Resitel, ResitelAdmin)
### Cislo
class CisloAdmin(reversion.VersionAdmin):
fieldsets = [
(None, {'fields': ['cislo', 'rocnik', 'verejne_db']}),
(u'Data', {'fields': ['datum_vydani', 'datum_deadline']}),
]
list_display = ['kod', 'rocnik', 'cislo', 'datum_vydani', 'datum_deadline', 'verejne']
list_display_links = ['cislo', 'kod']
list_filter = ['rocnik']
view_on_site = Cislo.verejne_url
admin.site.register(Cislo, CisloAdmin)
class CisloInline(admin.StackedInline):
model = Cislo
extra = 0
### Rocnik
class RocnikAdmin(reversion.VersionAdmin):
fieldsets = [
(None, {'fields': ['rocnik', 'prvni_rok']}),
]
list_display = ['rocnik', 'prvni_rok', 'verejne']
inlines = [CisloInline]
view_on_site = Rocnik.verejne_url
admin.site.register(Rocnik, RocnikAdmin)
### PrilohaReseni
class PrilohaReseniAdmin(reversion.VersionAdmin):
readonly_fields = ['timestamp']
fieldsets = [
(None, {'fields': ['reseni', 'soubor', 'timestamp']}),
(u'Poznámky', {'fields': ['poznamka']}),
]
list_display = ['reseni', 'soubor', 'timestamp']
list_display_links = ['reseni']
list_filter = ['reseni', 'timestamp']
search_fields = []
admin.site.register(PrilohaReseni, PrilohaReseniAdmin)
class PrilohaReseniInline(admin.StackedInline):
model = PrilohaReseni
extra = 1
### Reseni
class ReseniAdmin(reversion.VersionAdmin):
readonly_fields = ['timestamp']
fieldsets = [
(None, {'fields': ['problem', 'resitel', 'body', 'cislo_body', 'timestamp']}),
(u'Poznámky', {'fields': ['poznamka']}),
]
list_display = ['problem', 'resitel', 'body', 'timestamp']
list_display_links = ['problem', 'resitel']
list_filter = ['body', 'timestamp']
search_fields = []
inlines = [PrilohaReseniInline]
admin.site.register(Reseni, ReseniAdmin)
class ReseniInline(admin.TabularInline):
model = Reseni
readonly_fields = ['poznamka']
extra = 0
### Problem
class ProblemAdminForm(forms.ModelForm):
text_problemu = forms.CharField(widget=CKEditorWidget())
text_problemu_org = forms.CharField(widget=CKEditorWidget())
class Meta:
model = Problem
exclude = []
class ProblemAdmin(reversion.VersionAdmin):
form = ProblemAdminForm
# readonly_fields = ['autor']
fieldsets = [
(None, {'fields': ['nazev', 'typ', 'stav', 'autor', 'body']}),
(u'Vydání', {'fields': ['cislo_zadani', 'kod', 'cislo_reseni', 'opravovatel']}),
(u'Texty', {'fields': ['text_problemu', 'text_problemu_org']}),
]
list_display = ['nazev', 'typ', 'kod', 'stav', 'autor', 'opravovatel', 'verejne', 'cislo_zadani']
list_select_related = True
list_display_links = ['nazev']
list_filter = ['typ', 'stav', 'autor', 'opravovatel']
search_fields = ['nazev', 'kod', 'text_problemu_org', 'text_problemu']
inlines = [ReseniInline]
view_on_site = Problem.verejne_url
admin.site.register(Problem, ProblemAdmin)
### Soustredeni
class SoustredeniAdmin(reversion.VersionAdmin):
fieldsets = [
(None, {'fields': ['rocnik', 'misto', 'verejne_db']}),
(u'Data', {'fields': ['datum_zacatku', 'datum_konce']}),
]
list_display = ['rocnik', 'misto', 'datum_zacatku', 'verejne']
list_filter = ['rocnik']
view_on_site = Soustredeni.verejne_url
admin.site.register(Soustredeni, SoustredeniAdmin)