Browse Source

Fixes #121

pull/126/head
Sesostris Vieira 3 years ago
parent
commit
b61bd74201
  1. 9
      sigi/apps/eventos/admin.py
  2. 29
      sigi/apps/eventos/migrations/0015_anexo.py
  3. 20
      sigi/apps/eventos/models.py

9
sigi/apps/eventos/admin.py

@ -23,7 +23,8 @@ from django.contrib import admin
from django.db import models from django.db import models
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
from django.utils.translation import ugettext as _ 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.views import adicionar_eventos_carrinho
from sigi.apps.eventos.forms import EventoAdminForm from sigi.apps.eventos.forms import EventoAdminForm
@ -50,6 +51,10 @@ class ConviteInline(admin.TabularInline):
class ModuloInline(admin.TabularInline): class ModuloInline(admin.TabularInline):
model = Modulo model = Modulo
class AnexoInline(admin.TabularInline):
model = Anexo
exclude = ('data_pub',)
@admin.register(Evento) @admin.register(Evento)
class EventoAdmin(admin.ModelAdmin): class EventoAdmin(admin.ModelAdmin):
form = EventoAdminForm form = EventoAdminForm
@ -62,7 +67,7 @@ class EventoAdmin(admin.ModelAdmin):
raw_id_fields = ('casa_anfitria', 'municipio',) raw_id_fields = ('casa_anfitria', 'municipio',)
search_fields = ('nome', 'tipo_evento__nome', 'casa_anfitria__search_text', search_fields = ('nome', 'tipo_evento__nome', 'casa_anfitria__search_text',
'municipio__search_text', 'solicitante') 'municipio__search_text', 'solicitante')
inlines = (EquipeInline, ConviteInline, ModuloInline) inlines = (EquipeInline, ConviteInline, ModuloInline, AnexoInline)
actions = ['adicionar_eventos', ] actions = ['adicionar_eventos', ]
def adicionar_eventos(self, request, queryset): def adicionar_eventos(self, request, queryset):

29
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,),
),
]

20
sigi/apps/eventos/models.py

@ -284,3 +284,23 @@ class ModeloDeclaracao(models.Model):
nome=self.nome, nome=self.nome,
formato=self.get_formato_display() 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))

Loading…
Cancel
Save