diff --git a/sigi/apps/eventos/admin.py b/sigi/apps/eventos/admin.py index 048ce57..198ef32 100644 --- a/sigi/apps/eventos/admin.py +++ b/sigi/apps/eventos/admin.py @@ -23,7 +23,8 @@ from django.contrib import admin from django.db import models from django.http import HttpResponseRedirect from django.utils.translation import ugettext as _ -from sigi.apps.eventos.models import ModeloDeclaracao, Modulo, TipoEvento, Funcao, Evento, Equipe, Convite +from sigi.apps.eventos.models import (ModeloDeclaracao, Modulo, TipoEvento, + Funcao, Evento, Equipe, Convite, Anexo) from sigi.apps.eventos.views import adicionar_eventos_carrinho from sigi.apps.eventos.forms import EventoAdminForm @@ -50,6 +51,10 @@ class ConviteInline(admin.TabularInline): class ModuloInline(admin.TabularInline): model = Modulo +class AnexoInline(admin.TabularInline): + model = Anexo + exclude = ('data_pub',) + @admin.register(Evento) class EventoAdmin(admin.ModelAdmin): form = EventoAdminForm @@ -62,7 +67,7 @@ class EventoAdmin(admin.ModelAdmin): raw_id_fields = ('casa_anfitria', 'municipio',) search_fields = ('nome', 'tipo_evento__nome', 'casa_anfitria__search_text', 'municipio__search_text', 'solicitante') - inlines = (EquipeInline, ConviteInline, ModuloInline) + inlines = (EquipeInline, ConviteInline, ModuloInline, AnexoInline) actions = ['adicionar_eventos', ] def adicionar_eventos(self, request, queryset): diff --git a/sigi/apps/eventos/migrations/0015_anexo.py b/sigi/apps/eventos/migrations/0015_anexo.py new file mode 100644 index 0000000..8dab092 --- /dev/null +++ b/sigi/apps/eventos/migrations/0015_anexo.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import datetime + + +class Migration(migrations.Migration): + + dependencies = [ + ('eventos', '0014_auto_20211124_0736'), + ] + + operations = [ + migrations.CreateModel( + name='Anexo', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('arquivo', models.FileField(max_length=500, upload_to=b'apps/eventos/anexo/arquivo')), + ('descricao', models.CharField(max_length=b'70', verbose_name='descri\xe7\xe3o')), + ('data_pub', models.DateTimeField(default=datetime.datetime.now, verbose_name='data da publica\xe7\xe3o do anexo')), + ('evento', models.ForeignKey(verbose_name='evento', to='eventos.Evento')), + ], + options={ + 'ordering': ('-data_pub',), + }, + bases=(models.Model,), + ), + ] diff --git a/sigi/apps/eventos/models.py b/sigi/apps/eventos/models.py index 220dff8..041fb0e 100644 --- a/sigi/apps/eventos/models.py +++ b/sigi/apps/eventos/models.py @@ -284,3 +284,23 @@ class ModeloDeclaracao(models.Model): nome=self.nome, formato=self.get_formato_display() ) + +class Anexo(models.Model): + evento = models.ForeignKey( + Evento, + on_delete=models.CASCADE, + verbose_name=_(u'evento') + ) + # caminho no sistema para o documento anexo + arquivo = models.FileField(upload_to='apps/eventos/anexo/arquivo', max_length=500) + descricao = models.CharField(_(u'descrição'), max_length='70') + data_pub = models.DateTimeField( + _(u'data da publicação do anexo'), + default=datetime.now + ) + + class Meta: + ordering = ('-data_pub',) + + def __unicode__(self): + return unicode("%s publicado em %s" % (self.descricao, self.data_pub))