From f051f62e8faf58a7aec1b5e0d3e35b0f3df5eb54 Mon Sep 17 00:00:00 2001 From: "Tomas \"Jethro\" Pokorny" Date: Wed, 5 Oct 2016 08:55:28 +0200 Subject: [PATCH] Pridan prototyp adminu pro konfery. --- seminar/admin.py | 17 +++++++++- seminar/migrations/0042_auto_20161005_0847.py | 31 +++++++++++++++++++ seminar/models.py | 6 ++-- 3 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 seminar/migrations/0042_auto_20161005_0847.py diff --git a/seminar/admin.py b/seminar/admin.py index 45cc5fb7..3a61d461 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, Prispevek, Pohadka +from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni, Soustredeni_Ucastnici, Soustredeni_Organizatori, Novinky, Organizator, Prispevek, Pohadka, Konfera from autocomplete_light import shortcuts as autocomplete_light @@ -181,6 +181,7 @@ class Soustredeni_UcastniciInline(admin.TabularInline): qs = super(Soustredeni_UcastniciInline, self).get_queryset(request) return qs.select_related('resitel', 'soustredeni') + class Soustredeni_OrganizatoriInline(admin.TabularInline): form = autocomplete_light.modelform_factory(Soustredeni_Organizatori, autocomplete_fields=['organizator'], fields=['organizator'],) model = Soustredeni_Organizatori @@ -468,6 +469,20 @@ class SoustredeniAdmin(VersionAdmin): admin.site.register(Soustredeni, SoustredeniAdmin) +### Konfery +class KonferaAdminForm(forms.ModelForm): + class Meta: + model=Konfera + exclude = [] + +class KonferaAdmin(VersionAdmin): + form = KonferaAdminForm + list_filter = ['soustredeni'] + list_display = ['nazev','soustredeni','organizator','typ_prezentace'] +# inlines = [Konfera_UcastniciInline] + +admin.site.register(Konfera,KonferaAdmin) + ### Novinky class NovinkyAdminForm(forms.ModelForm): diff --git a/seminar/migrations/0042_auto_20161005_0847.py b/seminar/migrations/0042_auto_20161005_0847.py new file mode 100644 index 00000000..27930952 --- /dev/null +++ b/seminar/migrations/0042_auto_20161005_0847.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion +import seminar.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('seminar', '0041_konfery'), + ] + + operations = [ + migrations.AlterField( + model_name='konfera', + name='materialy', + field=models.FileField(help_text='Dal\u0161\xed materi\xe1ly ke konfe\u0159e zabalen\xe9 do jednoho souboru', upload_to=seminar.models.generate_filename_konfera, verbose_name='materialy', blank=True), + ), + migrations.AlterField( + model_name='konfera', + name='prezentace', + field=models.FileField(help_text='Prezentace nebo fotka posteru', upload_to=seminar.models.generate_filename_konfera, verbose_name='prezentace', blank=True), + ), + migrations.AlterField( + model_name='konfera', + name='prispevek', + field=models.ForeignKey(related_name='konfery', on_delete=django.db.models.deletion.SET_NULL, blank=True, to='seminar.Problem', help_text='\xda\u010dastnick\xfd p\u0159\xedp\u011bvek o konfe\u0159e', null=True, verbose_name='p\u0159\xedsp\u011bvek do \u010d\xedsla'), + ), + ] diff --git a/seminar/models.py b/seminar/models.py index 4c8fc3f0..5a478feb 100644 --- a/seminar/models.py +++ b/seminar/models.py @@ -859,7 +859,7 @@ class Konfera(models.Model): org_poznamka = models.TextField(u'neveřejná poznámka', blank=True, help_text=u'Neveřejná poznámka ke konfeře(plain text)') prispevek = models.ForeignKey(Problem, verbose_name=u'příspěvek do čísla', related_name='konfery', - help_text=u'Účastnický přípěvek o konfeře',on_delete = models.SET_NULL, null=True) + help_text=u'Účastnický přípěvek o konfeře',on_delete = models.SET_NULL, null=True, blank=True) TYP_VELETRH = 'veletrh' TYP_PREZENTACE = 'prezentace' TYP_CHOICES = [ @@ -868,9 +868,9 @@ class Konfera(models.Model): ] typ_prezentace = models.CharField(u'typ prezentace', max_length=16, choices=TYP_CHOICES, blank=False, default=TYP_VELETRH) prezentace = models.FileField(u'prezentace',help_text = u'Prezentace nebo fotka posteru', - upload_to = generate_filename_konfera) + upload_to = generate_filename_konfera, blank=True) materialy = models.FileField(u'materialy',help_text = u'Další materiály ke konfeře zabalené do jednoho souboru', - upload_to = generate_filename_konfera) + upload_to = generate_filename_konfera, blank=True) def __str__(self): return force_unicode(u"%s: (%s)" % (self.nazev, self.soustredeni))