diff --git a/seminar/admin.py b/seminar/admin.py index e2ec58cd..18997a70 100644 --- a/seminar/admin.py +++ b/seminar/admin.py @@ -11,7 +11,7 @@ from django.db import models from django.contrib.auth.models import User -from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni, Soustredeni_Ucastnici, Soustredeni_Organizatori, Novinky, Organizator +from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni, Soustredeni_Ucastnici, Soustredeni_Organizatori, Novinky, Organizator, Prispevek from autocomplete_light import shortcuts as autocomplete_light @@ -360,6 +360,24 @@ create_modeladmin(ProblemZadanyAdmin, Problem, 'ProblemZadany', verbose_name=u'P #admin.site.register(Problem, ProblemAdmin) +### Prispevek (k tematkum) + +class PrispevekAdminForm(forms.ModelForm): + text_org = forms.CharField(widget=CKEditorWidget(), required=False, + **field_labels(Prispevek, 'text_org')) + text_resitel = forms.CharField(widget=CKEditorWidget(), required=False, + **field_labels(Prispevek, 'text_resitel')) + + class Meta: + model = Prispevek + exclude = [] + +class PrispevekAdmin(VersionAdmin): + form = PrispevekAdminForm + list_display = ['nazev', 'problem', 'reseni', 'zverejnit'] + +admin.site.register(Prispevek, PrispevekAdmin) + ### Soustredeni class SoustredeniAdminForm(forms.ModelForm): diff --git a/seminar/migrations/0038_change_meta_prispevek.py b/seminar/migrations/0038_change_meta_prispevek.py new file mode 100644 index 00000000..5378e57e --- /dev/null +++ b/seminar/migrations/0038_change_meta_prispevek.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('seminar', '0037_prispevek'), + ] + + operations = [ + migrations.AlterModelOptions( + name='prispevek', + options={'verbose_name': 'P\u0159\xedsp\u011bvek k probl\xe9mu', 'verbose_name_plural': 'P\u0159\xedsp\u011bvky k probl\xe9m\u016fm'}, + ), + ] diff --git a/seminar/models.py b/seminar/models.py index edcb2527..05159021 100644 --- a/seminar/models.py +++ b/seminar/models.py @@ -595,6 +595,20 @@ class Prispevek(SeminarModelBase): text_resitel = models.TextField('Řešitelský text', blank = True, null = True) zverejnit = models.BooleanField('Zveřejnit?') + class Meta: + verbose_name = 'Příspěvek k problému' + verbose_name_plural = 'Příspěvky k problémům' + + def __unicode__(self): + if self.reseni: + return force_unicode(self.nazev) + ' (' + \ + force_unicode(self.reseni.resitel) + ') ' + else: + return force_unicode(self.nazev) + ' ' + + @reversion.register(ignore_duplicate_revisions=True) @python_2_unicode_compatible class Organizator(models.Model):