Organizatori | admin

+ odstraneni chyby, kdyz chybi obrazek organizatora
This commit is contained in:
Bc. Petr Pecha 2015-06-25 11:01:39 +02:00
parent 1777656d27
commit e6b0efe1a7
2 changed files with 13 additions and 6 deletions

View file

@ -8,7 +8,7 @@ from ckeditor.widgets import CKEditorWidget
from django.db.models import Count from django.db.models import Count
from django.db import models 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 import autocomplete_light
@ -329,5 +329,11 @@ class NovinkyAdminForm(forms.ModelForm):
class NovinkyAdmin(admin.ModelAdmin): class NovinkyAdmin(admin.ModelAdmin):
form = NovinkyAdminForm form = NovinkyAdminForm
admin.site.register(Novinky, NovinkyAdmin) admin.site.register(Novinky, NovinkyAdmin)
### Organizator
@admin.register(Organizator)
class OrganizatorAdmin(admin.ModelAdmin):
list_filter = ['organizuje_do_roku']

View file

@ -670,10 +670,11 @@ class Organizator(models.Model):
verbose_name_plural = 'Organizátoři' verbose_name_plural = 'Organizátoři'
def save(self): def save(self):
original = Image.open(self.foto) if self.foto:
jmeno = os.path.basename(self.foto.file.name) original = Image.open(self.foto)
Organizator._vyrobMiniaturu(original, jmeno, 500, self.foto) jmeno = os.path.basename(self.foto.file.name)
Organizator._vyrobMiniaturu(original, jmeno, 200, self.foto_male) Organizator._vyrobMiniaturu(original, jmeno, 500, self.foto)
Organizator._vyrobMiniaturu(original, jmeno, 200, self.foto_male)
super(Organizator, self).save() super(Organizator, self).save()
@staticmethod @staticmethod