From e733d654149692379065c67c8c8cf9566e2a88a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rog=C3=A9rio=20Fr=C3=A1?= Date: Fri, 16 Dec 2016 11:10:48 -0200 Subject: [PATCH] logo partidos --- sapl/parlamentares/models.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sapl/parlamentares/models.py b/sapl/parlamentares/models.py index 1509e2425..ea8c972c9 100644 --- a/sapl/parlamentares/models.py +++ b/sapl/parlamentares/models.py @@ -86,7 +86,15 @@ class Coligacao(models.Model): def __str__(self): return self.nome + +def get_logo_media_path(instance, subpath, filename): + return './sapl/partidos/%s/%s/%s' % (instance, subpath, filename) + +def logo_upload_path(instance, filename): + return get_logo_media_path(instance, 'logo', filename) + + class Partido(models.Model): sigla = models.CharField(max_length=9, verbose_name=_('Sigla')) nome = models.CharField(max_length=50, verbose_name=_('Nome')) @@ -94,6 +102,12 @@ class Partido(models.Model): blank=True, null=True, verbose_name=_('Data Criação')) data_extincao = models.DateField( blank=True, null=True, verbose_name=_('Data Extinção')) + logo_partido = models.ImageField( + blank=True, + null=True, + upload_to=logo_upload_path, + verbose_name=_('Logo Partido'), + validators=[restringe_tipos_de_arquivo_img]) class Meta: verbose_name = _('Partido')