From e6b0efe1a73dd555fc6f4f019979e5f262538510 Mon Sep 17 00:00:00 2001 From: "Bc. Petr Pecha" Date: Thu, 25 Jun 2015 11:01:39 +0200 Subject: [PATCH] Organizatori | admin + odstraneni chyby, kdyz chybi obrazek organizatora --- seminar/admin.py | 10 ++++++++-- seminar/models.py | 9 +++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/seminar/admin.py b/seminar/admin.py index dcb7797d..6ca5d238 100644 --- a/seminar/admin.py +++ b/seminar/admin.py @@ -8,7 +8,7 @@ from ckeditor.widgets import CKEditorWidget from django.db.models import Count from django.db import models -from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni, Soustredeni_Ucastnici, Novinky +from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni, Soustredeni_Ucastnici, Novinky, Organizator import autocomplete_light @@ -329,5 +329,11 @@ class NovinkyAdminForm(forms.ModelForm): class NovinkyAdmin(admin.ModelAdmin): form = NovinkyAdminForm - admin.site.register(Novinky, NovinkyAdmin) + +### Organizator + +@admin.register(Organizator) +class OrganizatorAdmin(admin.ModelAdmin): + list_filter = ['organizuje_do_roku'] + diff --git a/seminar/models.py b/seminar/models.py index c731fa4c..23578780 100644 --- a/seminar/models.py +++ b/seminar/models.py @@ -670,10 +670,11 @@ class Organizator(models.Model): verbose_name_plural = 'Organizátoři' def save(self): - original = Image.open(self.foto) - jmeno = os.path.basename(self.foto.file.name) - Organizator._vyrobMiniaturu(original, jmeno, 500, self.foto) - Organizator._vyrobMiniaturu(original, jmeno, 200, self.foto_male) + if self.foto: + original = Image.open(self.foto) + jmeno = os.path.basename(self.foto.file.name) + Organizator._vyrobMiniaturu(original, jmeno, 500, self.foto) + Organizator._vyrobMiniaturu(original, jmeno, 200, self.foto_male) super(Organizator, self).save() @staticmethod