Browse Source

Vylepseni admin rozhrani

remotes/origin/feincms
Tomas Gavenciak 10 years ago
parent
commit
013b492f40
  1. 44
      seminar/admin.py
  2. 4
      seminar/models.py

44
seminar/admin.py

@ -5,7 +5,7 @@ import reversion
from solo.admin import SingletonModelAdmin from solo.admin import SingletonModelAdmin
from ckeditor.widgets import CKEditorWidget from ckeditor.widgets import CKEditorWidget
from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni
### Nastaveni ### Nastaveni
@ -13,7 +13,7 @@ admin.site.register(Nastaveni, SingletonModelAdmin)
### Skola ### Skola
class SkolaAdmin(reversion.VersionAdmin, admin.ModelAdmin): class SkolaAdmin(reversion.VersionAdmin):
fieldsets = [ fieldsets = [
(None, {'fields': ['nazev', 'kratky_nazev']}), (None, {'fields': ['nazev', 'kratky_nazev']}),
(u'Interní ID', {'fields': ['aesop_id', 'izo'], 'classes': ['collapse']}), (u'Interní ID', {'fields': ['aesop_id', 'izo'], 'classes': ['collapse']}),
@ -27,7 +27,7 @@ admin.site.register(Skola, SkolaAdmin)
### Resitel ### Resitel
class ResitelAdmin(reversion.VersionAdmin, admin.ModelAdmin): class ResitelAdmin(reversion.VersionAdmin):
fieldsets = [ fieldsets = [
(None, {'fields': ['jmeno', 'prijmeni', 'user']}), (None, {'fields': ['jmeno', 'prijmeni', 'user']}),
(u'Škola', {'fields': ['skola', 'rok_maturity']}), (u'Škola', {'fields': ['skola', 'rok_maturity']}),
@ -36,6 +36,7 @@ class ResitelAdmin(reversion.VersionAdmin, admin.ModelAdmin):
(u'Adresa', {'fields': ['ulice', 'mesto', 'psc', 'stat']}), (u'Adresa', {'fields': ['ulice', 'mesto', 'psc', 'stat']}),
] ]
list_display = ['jmeno', 'prijmeni', 'user', 'pohlavi_muz', 'skola', 'rok_maturity'] list_display = ['jmeno', 'prijmeni', 'user', 'pohlavi_muz', 'skola', 'rok_maturity']
list_display_links = ['skola']
list_filter = ['pohlavi_muz', 'rok_maturity', 'zasilat'] list_filter = ['pohlavi_muz', 'rok_maturity', 'zasilat']
search_fields = ['jmeno', 'prijmeni', 'ulice', 'user', 'mesto', 'email'] search_fields = ['jmeno', 'prijmeni', 'ulice', 'user', 'mesto', 'email']
@ -44,12 +45,13 @@ admin.site.register(Resitel, ResitelAdmin)
### Cislo ### Cislo
class CisloAdmin(reversion.VersionAdmin, admin.ModelAdmin): class CisloAdmin(reversion.VersionAdmin):
fieldsets = [ fieldsets = [
(None, {'fields': ['cislo', 'rocnik']}), (None, {'fields': ['cislo', 'rocnik', 'verejne_db']}),
(u'Data', {'fields': ['datum_vydani', 'datum_deadline']}), (u'Data', {'fields': ['datum_vydani', 'datum_deadline']}),
] ]
list_display = ['kod', 'rocnik', 'cislo', 'datum_vydani', 'datum_deadline'] list_display = ['kod', 'rocnik', 'cislo', 'datum_vydani', 'datum_deadline', 'verejne']
list_display_links = ['rocnik']
list_filter = ['rocnik'] list_filter = ['rocnik']
admin.site.register(Cislo, CisloAdmin) admin.site.register(Cislo, CisloAdmin)
@ -61,11 +63,11 @@ class CisloInline(admin.StackedInline):
### Rocnik ### Rocnik
class RocnikAdmin(reversion.VersionAdmin, admin.ModelAdmin): class RocnikAdmin(reversion.VersionAdmin):
fieldsets = [ fieldsets = [
(None, {'fields': ['rocnik', 'prvni_rok']}), (None, {'fields': ['rocnik', 'prvni_rok']}),
] ]
list_display = ['rocnik', 'prvni_rok'] list_display = ['rocnik', 'prvni_rok', 'verejne']
inlines = [CisloInline] inlines = [CisloInline]
admin.site.register(Rocnik, RocnikAdmin) admin.site.register(Rocnik, RocnikAdmin)
@ -73,12 +75,14 @@ admin.site.register(Rocnik, RocnikAdmin)
### PrilohaReseni ### PrilohaReseni
class PrilohaReseniAdmin(reversion.VersionAdmin, admin.ModelAdmin): class PrilohaReseniAdmin(reversion.VersionAdmin):
readonly_fields = ['timestamp'] readonly_fields = ['timestamp']
fieldsets = [ fieldsets = [
(None, {'fields': ['reseni', 'soubor', 'timestamp']}), (None, {'fields': ['reseni', 'soubor', 'timestamp']}),
(u'Poznámky', {'fields': ['poznamka']}),
] ]
list_display = ['reseni', 'soubor', 'timestamp'] list_display = ['reseni', 'soubor', 'timestamp']
list_display_links = ['reseni']
list_filter = ['reseni', 'timestamp'] list_filter = ['reseni', 'timestamp']
search_fields = [] search_fields = []
@ -91,12 +95,14 @@ class PrilohaReseniInline(admin.StackedInline):
### Reseni ### Reseni
class ReseniAdmin(reversion.VersionAdmin, admin.ModelAdmin): class ReseniAdmin(reversion.VersionAdmin):
readonly_fields = ['timestamp'] readonly_fields = ['timestamp']
fieldsets = [ fieldsets = [
(None, {'fields': ['problem', 'resitel', 'body', 'cislo_body', 'timestamp']}), (None, {'fields': ['problem', 'resitel', 'body', 'cislo_body', 'timestamp']}),
(u'Poznámky', {'fields': ['poznamka']}),
] ]
list_display = ['problem', 'resitel', 'body', 'timestamp'] list_display = ['problem', 'resitel', 'body', 'timestamp']
list_display_links = ['problem', 'resitel']
list_filter = ['body', 'timestamp'] list_filter = ['body', 'timestamp']
search_fields = [] search_fields = []
inlines = [PrilohaReseniInline] inlines = [PrilohaReseniInline]
@ -117,7 +123,7 @@ class ProblemAdminForm(forms.ModelForm):
model = Problem model = Problem
exclude = [] exclude = []
class ProblemAdmin(reversion.VersionAdmin, admin.ModelAdmin): class ProblemAdmin(reversion.VersionAdmin):
form = ProblemAdminForm form = ProblemAdminForm
# readonly_fields = ['autor'] # readonly_fields = ['autor']
fieldsets = [ fieldsets = [
@ -125,9 +131,23 @@ class ProblemAdmin(reversion.VersionAdmin, admin.ModelAdmin):
(u'Vydání', {'fields': ['cislo_zadani', 'kod', 'cislo_reseni', 'opravovatel']}), (u'Vydání', {'fields': ['cislo_zadani', 'kod', 'cislo_reseni', 'opravovatel']}),
(u'Texty', {'fields': ['text_problemu', 'text_problemu_org']}), (u'Texty', {'fields': ['text_problemu', 'text_problemu_org']}),
] ]
list_display = ['nazev', 'typ', 'stav', 'autor', 'kod', 'opravovatel'] list_display = ['kod', 'nazev', 'typ', 'stav', 'autor', 'opravovatel', 'verejne', 'cislo_zadani']
list_display_links = ['autor', 'opravovatel', 'cislo_zadani']
list_filter = ['typ', 'stav', 'autor', 'opravovatel'] list_filter = ['typ', 'stav', 'autor', 'opravovatel']
search_fields = ['nazev', 'kod', 'text_problemu_org', 'text_problemu'] search_fields = ['nazev', 'kod', 'text_problemu_org', 'text_problemu']
inlines = [ReseniInline] inlines = [ReseniInline]
admin.site.register(Problem, ProblemAdmin) 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']
admin.site.register(Soustredeni, SoustredeniAdmin)

4
seminar/models.py

@ -200,6 +200,7 @@ class Rocnik(SeminarModelBase):
def verejne(self): def verejne(self):
return len(self.verejne_cisla()) > 0 return len(self.verejne_cisla()) > 0
verejne.boolean = True
def verejna_cisla(self): def verejna_cisla(self):
vc = [c for c in self.cisla.all() if c.verejne()] vc = [c for c in self.cisla.all() if c.verejne()]
@ -252,6 +253,7 @@ class Cislo(SeminarModelBase):
def verejne(self): def verejne(self):
return self.verejne_db return self.verejne_db
verejne.boolean = True
def verejne_url(self): def verejne_url(self):
return reverse('seminar_cislo', kwargs={'pk': self.id}) return reverse('seminar_cislo', kwargs={'pk': self.id})
@ -327,6 +329,7 @@ class Problem(SeminarModelBase):
def verejne(self): def verejne(self):
return (self.cislo_zadani and self.cislo_zadani.verejne()) return (self.cislo_zadani and self.cislo_zadani.verejne())
verejne.boolean = True
def verejne_url(self): def verejne_url(self):
return reverse('seminar_problem', kwargs={'pk': self.id}) return reverse('seminar_problem', kwargs={'pk': self.id})
@ -432,6 +435,7 @@ class Soustredeni(SeminarModelBase):
def verejne(self): def verejne(self):
return self.verejne_db return self.verejne_db
verejne.boolean = True
def verejne_url(self): def verejne_url(self):
return reverse('seminar_soustredeni', kwargs={'pk': self.id}) return reverse('seminar_soustredeni', kwargs={'pk': self.id})

Loading…
Cancel
Save