Browse Source

Prepara app Eventos para migração

revisaoSidenav
Sesostris Vieira 3 years ago
parent
commit
414daaa484
  1. 1
      requirements/requirements.txt
  2. 46
      sigi/apps/eventos/admin.py
  3. 6
      sigi/apps/eventos/apps.py
  4. 2
      sigi/apps/eventos/forms.py
  5. 21
      sigi/apps/eventos/migrations/0001_initial.py
  6. 6
      sigi/apps/eventos/migrations/0002_auto_20151016_1449.py
  7. 6
      sigi/apps/eventos/migrations/0003_auto_20151104_0810.py
  8. 6
      sigi/apps/eventos/migrations/0004_auto_20160719_0920.py
  9. 4
      sigi/apps/eventos/migrations/0004_remove_evento_curso_moodle_id.py
  10. 4
      sigi/apps/eventos/migrations/0005_auto_20210406_1945.py
  11. 2
      sigi/apps/eventos/migrations/0010_modulo.py
  12. 2
      sigi/apps/eventos/migrations/0015_anexo.py
  13. 90
      sigi/apps/eventos/migrations/0017_alter_anexo_arquivo_alter_anexo_descricao_and_more.py
  14. 46
      sigi/apps/eventos/models.py
  15. 30
      sigi/settings/base.py
  16. BIN
      sigi/static/img/favicon.ico
  17. 1
      sigi/urls.py

1
requirements/requirements.txt

@ -8,4 +8,5 @@ django-bootstrap5==21.3
django-extensions==3.1.5
django-import-export==2.7.1
django-localflavor==3.1
django-tinymce==3.4.0
django-weasyprint==2.1.0

46
sigi/apps/eventos/admin.py

@ -1,31 +1,10 @@
# -*- coding: utf-8 -*-
#
# sigi.apps.eventos.admin
#
# Copyright (C) 2015 Interlegis
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from django import forms
from django.contrib import admin
from django.db import models
from django.http import HttpResponseRedirect
from django.utils.translation import gettext as _
from tinymce.models import HTMLField
from tinymce.widgets import AdminTinyMCE
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
@admin.register(TipoEvento)
@ -40,6 +19,8 @@ class FuncaoAdmin(admin.ModelAdmin):
@admin.register(ModeloDeclaracao)
class ModeloDeclaracaoAdmin(admin.ModelAdmin):
list_display = ('nome', 'formato')
formfield_overrides = {HTMLField: {'widget': AdminTinyMCE}}
class EquipeInline(admin.TabularInline):
model = Equipe
@ -68,25 +49,6 @@ class EventoAdmin(admin.ModelAdmin):
search_fields = ('nome', 'tipo_evento__nome', 'casa_anfitria__search_text',
'municipio__search_text', 'solicitante')
inlines = (EquipeInline, ConviteInline, ModuloInline, AnexoInline)
actions = ['adicionar_eventos', ]
def adicionar_eventos(self, request, queryset):
if 'carrinho_eventos' in request.session:
q1 = len(request.session['carrinho_eventos'])
else:
q1 = 0
response = adicionar_eventos_carrinho(request, queryset=queryset)
q2 = len(request.session['carrinho_eventos'])
quant = q2 - q1
if quant:
self.message_user(request, str(q2 - q1) + " " +
_("Eventos adicionados no carrinho"))
else:
self.message_user(request, _("Os Eventos selecionados "
"já foram adicionados anteriormente"))
return HttpResponseRedirect('.')
adicionar_eventos.short_description = _("Armazenar eventos no carrinho "
"para exportar")
def lookup_allowed(self, lookup, value):
return (super(EventoAdmin, self).lookup_allowed(lookup, value) or

6
sigi/apps/eventos/apps.py

@ -0,0 +1,6 @@
from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
class EventosConfig(AppConfig):
name = 'sigi.apps.eventos'
verbose_name = _('Eventos Interlegis')

2
sigi/apps/eventos/forms.py

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from django import forms
from django.utils.translation import gettext as _
from sigi.apps.eventos.models import ModeloDeclaracao, Evento

21
sigi/apps/eventos/migrations/0001_initial.py

@ -19,8 +19,8 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('data_convite', models.DateField(verbose_name='Data do convite')),
('aceite', models.BooleanField(default=False, verbose_name='Aceitou o convite')),
('participo', models.BooleanField(default=False, verbose_name='Participou do evento')),
('casa', models.ForeignKey(verbose_name='Casa convidada', to='casas.CasaLegislativa')),
('participou', models.BooleanField(default=False, verbose_name='Participou do evento')),
('casa', models.ForeignKey(verbose_name='Casa convidada', to='casas.CasaLegislativa', on_delete=models.CASCADE)),
],
options={
'ordering': ('evento', 'casa', '-data_convite'),
@ -56,9 +56,8 @@ class Migration(migrations.Migration):
('status', models.CharField(max_length=1, verbose_name='Status', choices=[(b'P', 'Previs\xe3o'), (b'A', 'A confirmar'), (b'O', 'Confirmado'), (b'R', 'Realizado'), (b'C', 'Cancelado')])),
('data_cancelamento', models.DateField(null=True, verbose_name='Data de cancelamento', blank=True)),
('motivo_cancelamento', models.TextField(verbose_name='Motivo do cancelamento', blank=True)),
('curso_moodle_id', models.IntegerField(null=True, verbose_name='Curso saberes', blank=True)),
('casa_anfitria', models.ForeignKey(verbose_name='Casa anfitri\xe3', blank=True, to='casas.CasaLegislativa', null=True)),
('municipio', models.ForeignKey(to='contatos.Municipio')),
('casa_anfitria', models.ForeignKey(verbose_name='Casa anfitri\xe3', blank=True, to='casas.CasaLegislativa', null=True, on_delete=models.CASCADE)),
('municipio', models.ForeignKey(to='contatos.Municipio', on_delete=models.CASCADE)),
],
options={
'ordering': ('-data_inicio',),
@ -97,37 +96,37 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='evento',
name='tipo_evento',
field=models.ForeignKey(to='eventos.TipoEvento'),
field=models.ForeignKey(to='eventos.TipoEvento', on_delete=models.CASCADE),
preserve_default=True,
),
migrations.AddField(
model_name='equipe',
name='evento',
field=models.ForeignKey(to='eventos.Evento'),
field=models.ForeignKey(to='eventos.Evento', on_delete=models.CASCADE),
preserve_default=True,
),
migrations.AddField(
model_name='equipe',
name='funcao',
field=models.ForeignKey(verbose_name='Fun\xe7\xe3o na equipe', to='eventos.Funcao'),
field=models.ForeignKey(verbose_name='Fun\xe7\xe3o na equipe', to='eventos.Funcao', on_delete=models.CASCADE),
preserve_default=True,
),
migrations.AddField(
model_name='equipe',
name='membro',
field=models.ForeignKey(related_name='equipe_evento', to='servidores.Servidor'),
field=models.ForeignKey(related_name='equipe_evento', to='servidores.Servidor', on_delete=models.CASCADE),
preserve_default=True,
),
migrations.AddField(
model_name='convite',
name='evento',
field=models.ForeignKey(to='eventos.Evento'),
field=models.ForeignKey(to='eventos.Evento', on_delete=models.CASCADE),
preserve_default=True,
),
migrations.AddField(
model_name='convite',
name='servidor',
field=models.ForeignKey(verbose_name='Servidor que convido', to='servidores.Servidor'),
field=models.ForeignKey(verbose_name='Servidor que convido', to='servidores.Servidor', on_delete=models.CASCADE),
preserve_default=True,
),
migrations.AlterUniqueTogether(

6
sigi/apps/eventos/migrations/0002_auto_20151016_1449.py

@ -11,10 +11,4 @@ class Migration(migrations.Migration):
]
operations = [
migrations.AlterField(
model_name='evento',
name='curso_moodle_id',
field=models.IntegerField(blank=True, null=True, verbose_name='Curso saberes', choices=[(None, '---------'), (None, "Erro ao acessar o saberes: 'invalidtoken (moodle_exception): Token inv\xe1lido - token n\xe3o encontrado'")]),
preserve_default=True,
),
]

6
sigi/apps/eventos/migrations/0003_auto_20151104_0810.py

@ -11,10 +11,4 @@ class Migration(migrations.Migration):
]
operations = [
migrations.AlterField(
model_name='evento',
name='curso_moodle_id',
field=models.IntegerField(blank=True, null=True, verbose_name='Curso saberes', choices=[(None, '---------'), (59L, 'Oficina Interlegis em Montes Claros, MG')]),
preserve_default=True,
),
]

6
sigi/apps/eventos/migrations/0004_auto_20160719_0920.py

@ -11,10 +11,4 @@ class Migration(migrations.Migration):
]
operations = [
migrations.AlterField(
model_name='evento',
name='curso_moodle_id',
field=models.IntegerField(blank=True, null=True, verbose_name='Curso saberes', choices=[(None, '---------'), (851L, 'Implanta\xe7\xe3o SAPL em Cuiab\xe1')]),
preserve_default=True,
),
]

4
sigi/apps/eventos/migrations/0004_remove_evento_curso_moodle_id.py

@ -11,8 +11,4 @@ class Migration(migrations.Migration):
]
operations = [
migrations.RemoveField(
model_name='evento',
name='curso_moodle_id',
),
]

4
sigi/apps/eventos/migrations/0005_auto_20210406_1945.py

@ -15,13 +15,13 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='convite',
name='casa',
field=models.ForeignKey(verbose_name='Casa convidada', to='casas.Orgao'),
field=models.ForeignKey(verbose_name='Casa convidada', to='casas.Orgao', on_delete=models.CASCADE),
preserve_default=True,
),
migrations.AlterField(
model_name='evento',
name='casa_anfitria',
field=models.ForeignKey(verbose_name='Casa anfitri\xe3', blank=True, to='casas.Orgao', null=True),
field=models.ForeignKey(verbose_name='Casa anfitri\xe3', blank=True, to='casas.Orgao', null=True, on_delete=models.CASCADE),
preserve_default=True,
),
]

2
sigi/apps/eventos/migrations/0010_modulo.py

@ -25,7 +25,7 @@ class Migration(migrations.Migration):
('carga_horaria', models.PositiveIntegerField(default=0, verbose_name='carga hor\xe1ria')),
('qtde_participantes', models.PositiveIntegerField(default=0, help_text='Deixar Zero significa que todos os participantes do evento participaram do m\xf3dulo', verbose_name='n\xfamero de participantes')),
('apresentador', models.ForeignKey(related_name='modulo_apresentador', on_delete=django.db.models.deletion.PROTECT, verbose_name='Apresentador', blank=True, to='servidores.Servidor', null=True)),
('evento', models.ForeignKey(verbose_name='Evento', to='eventos.Evento')),
('evento', models.ForeignKey(verbose_name='Evento', to='eventos.Evento', on_delete=models.CASCADE)),
('monitor', models.ForeignKey(related_name='modulo_monitor', on_delete=django.db.models.deletion.PROTECT, blank=True, to='servidores.Servidor', help_text='Monitor, mediador, auxiliar, etc.', null=True, verbose_name='Monitor')),
],
options={

2
sigi/apps/eventos/migrations/0015_anexo.py

@ -19,7 +19,7 @@ class Migration(migrations.Migration):
('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')),
('evento', models.ForeignKey(verbose_name='evento', to='eventos.Evento', on_delete=models.CASCADE)),
],
options={
'ordering': ('-data_pub',),

90
sigi/apps/eventos/migrations/0017_alter_anexo_arquivo_alter_anexo_descricao_and_more.py

@ -0,0 +1,90 @@
# Generated by Django 4.0.1 on 2022-01-19 16:24
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('servidores', '0008_alter_servico_id_alter_servidor_foto_and_more'),
('eventos', '0016_merge'),
]
operations = [
migrations.AlterField(
model_name='anexo',
name='arquivo',
field=models.FileField(max_length=500, upload_to='apps/eventos/anexo/arquivo'),
),
migrations.AlterField(
model_name='anexo',
name='descricao',
field=models.CharField(max_length=70, verbose_name='descrição'),
),
migrations.AlterField(
model_name='anexo',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
),
migrations.AlterField(
model_name='convite',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
),
migrations.AlterField(
model_name='convite',
name='servidor',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='servidores.servidor', verbose_name='Servidor que convidou'),
),
migrations.AlterField(
model_name='equipe',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
),
migrations.AlterField(
model_name='evento',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
),
migrations.AlterField(
model_name='evento',
name='status',
field=models.CharField(choices=[('P', 'Previsão'), ('A', 'A confirmar'), ('O', 'Confirmado'), ('R', 'Realizado'), ('C', 'Cancelado')], max_length=1, verbose_name='Status'),
),
migrations.AlterField(
model_name='funcao',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
),
migrations.AlterField(
model_name='modelodeclaracao',
name='formato',
field=models.CharField(choices=[('A4 portrait', 'A4 retrato'), ('A4 landscape', 'A4 paisagem'), ('letter portrait', 'Carta retrato'), ('letter landscape', 'Carta paisagem')], default='A4 portrait', max_length=30, verbose_name='Formato da página'),
),
migrations.AlterField(
model_name='modelodeclaracao',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
),
migrations.AlterField(
model_name='modulo',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
),
migrations.AlterField(
model_name='modulo',
name='tipo',
field=models.CharField(choices=[('A', 'Aula'), ('P', 'Palestra'), ('R', 'Apresentação')], max_length=1, verbose_name='Tipo'),
),
migrations.AlterField(
model_name='tipoevento',
name='categoria',
field=models.CharField(choices=[('C', 'Curso'), ('E', 'Encontro'), ('O', 'Oficina'), ('S', 'Seminário'), ('V', 'Visita')], max_length=1, verbose_name='Categoaria'),
),
migrations.AlterField(
model_name='tipoevento',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
),
]

46
sigi/apps/eventos/models.py

@ -1,17 +1,14 @@
# -*- coding: utf-8 -*-
from datetime import datetime
import random
from django.db import models
from django.db.models import Sum
from django.utils.functional import lazy
from django.utils.translation import gettext as _
from django.contrib.contenttypes import generic
from sigi.apps.casas.models import Orgao
from sigi.apps.contatos.models import Municipio
from sigi.apps.servidores.models import Servidor
from django.core.exceptions import ValidationError
from tinymce.models import HTMLField
class TipoEvento(models.Model):
CATEGORIA_CHOICES = (
('C', _('Curso')),
@ -31,7 +28,7 @@ class TipoEvento(models.Model):
ordering = ("nome",)
verbose_name, verbose_name_plural = _("Tipo de evento"), _("Tipos de evento")
def __unicode__(self):
def __str__(self):
return self.nome
class Evento(models.Model):
@ -93,12 +90,11 @@ class Evento(models.Model):
ordering = ("-data_inicio",)
verbose_name, verbose_name_plural = _("Evento"), _("Eventos")
def __unicode__(self):
return _("%(nome)s (%(tipo_evento)s): de %(data_inicio)s a %(data_termino)s") % dict(
nome=self.nome,
tipo_evento=unicode(self.tipo_evento),
data_inicio=self.data_inicio,
data_termino=self.data_termino)
def __str__(self):
return _(
f"{self.nome} ({self.tipo_evento}): "
f"de {self.data_inicio} a {self.data_termino}"
)
def save(self, *args, **kwargs):
if self.status != 'C':
@ -121,7 +117,7 @@ class Funcao(models.Model):
ordering = ("nome",)
verbose_name, verbose_name_plural = _("Função"), _("Funções")
def __unicode__(self):
def __str__(self):
return self.nome
class Equipe(models.Model):
@ -145,8 +141,8 @@ class Equipe(models.Model):
ordering = ('evento', 'funcao', 'membro',)
verbose_name, verbose_name_plural = _("Membro da equipe"), _("Membros da equipe")
def __unicode__(self):
return "%s (%s)" % (unicode(self.membro), unicode(self.funcao),)
def __str__(self):
return _(f"{self.membro} ({self.funcao})")
class Convite(models.Model):
evento = models.ForeignKey(
@ -188,7 +184,7 @@ class Modulo(models.Model):
('P', _('Palestra')),
('R', _('Apresentação')),
)
evento = models.ForeignKey(Evento, verbose_name=_("Evento"))
evento = models.ForeignKey(Evento, verbose_name=_("Evento"), on_delete=models.CASCADE)
nome = models.CharField(_("Nome"), max_length=100)
descricao = models.TextField(_("Descrição do módulo"))
tipo = models.CharField(_('Tipo'), max_length=1, choices=TIPO_CHOICES)
@ -235,11 +231,8 @@ class Modulo(models.Model):
verbose_name = _("Módulo do evento")
verbose_name_plural = _("Módulos do evento")
def __unicode__(self):
return _("{nome} ({tipo})").format(
nome=self.nome,
tipo=self.get_tipo_display()
)
def __str__(self):
return _(f"{self.nome} ({self.get_tipo_display()})")
class ModeloDeclaracao(models.Model):
FORMATO_CHOICES = (
@ -279,11 +272,8 @@ class ModeloDeclaracao(models.Model):
verbose_name = _("modelo de declaração")
verbose_name_plural = _("modelos de declaração")
def __unicode__(self):
return _("{nome} ({formato})").format(
nome=self.nome,
formato=self.get_formato_display()
)
def __str__(self):
return _(f"{self.nome} ({self.get_formato_display()})")
class Anexo(models.Model):
evento = models.ForeignKey(
@ -293,7 +283,7 @@ class Anexo(models.Model):
)
# caminho no sistema para o documento anexo
arquivo = models.FileField(upload_to='apps/eventos/anexo/arquivo', max_length=500)
descricao = models.CharField(_('descrição'), max_length='70')
descricao = models.CharField(_('descrição'), max_length=70)
data_pub = models.DateTimeField(
_('data da publicação do anexo'),
default=datetime.now
@ -302,5 +292,5 @@ class Anexo(models.Model):
class Meta:
ordering = ('-data_pub',)
def __unicode__(self):
return unicode("%s publicado em %s" % (self.descricao, self.data_pub))
def __str__(self):
return _(f"{self.descricao} publicado em {self.data_pub}")

30
sigi/settings/base.py

@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/4.0/ref/settings/
"""
from pathlib import Path
from django.utils.translation import gettext_lazy as _
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
@ -26,10 +27,14 @@ INSTALLED_APPS = [
'sigi.apps.convenios',
'sigi.apps.inventario',
'sigi.apps.servicos',
'sigi.apps.eventos',
'localflavor',
'import_export',
'tinymce',
'django_bootstrap5',
'django.forms',
# 'material',
# 'material.admin',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
@ -105,3 +110,28 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
IMPORT_EXPORT_USE_TRANSACTIONS = True
IMPORT_EXPORT_SKIP_ADMIN_LOG = True
# Django Material Admin settings
#
# MATERIAL_ADMIN_SITE = {
# 'HEADER': _('SIGI'),
# 'TITLE': _('SIGI - Sistema de Informações do Interlegis'),
# 'FAVICON': 'img/favicon.ico',
# # 'MAIN_BG_COLOR': 'color', # Admin site main color, css color should be specified
# # 'MAIN_HOVER_COLOR': 'color', # Admin site main hover color, css color should be specified
# 'PROFILE_PICTURE': 'img/interlegis.jpeg', # Admin site profile picture (path to static should be specified)
# 'PROFILE_BG': 'img/engitec.jpeg', # Admin site profile background (path to static should be specified)
# 'LOGIN_LOGO': 'img/interlegis.jpeg', # Admin site logo on login page (path to static should be specified)
# 'LOGOUT_BG': 'img/engitec.jpeg', # Admin site background on login/logout pages (path to static should be specified)
# 'SHOW_THEMES': True, # Show default admin themes button
# 'TRAY_REVERSE': True, # Hide object-tools and additional-submit-line by default
# 'NAVBAR_REVERSE': True, # Hide side navbar by default
# # 'SHOW_COUNTS': True, # Show instances counts for each model
# # 'APP_ICONS': { # Set icons for applications(lowercase), including 3rd party apps, {'application_name': 'material_icon_name', ...}
# # 'sites': 'send',
# # },
# # 'MODEL_ICONS': { # Set icons for models(lowercase), including 3rd party models, {'model_name': 'material_icon_name', ...}
# # 'site': 'contact_mail',
# # }
# }

BIN
sigi/static/img/favicon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

1
sigi/urls.py

@ -20,6 +20,7 @@ from django.conf import settings
urlpatterns = [
path('admin/casas/', include('sigi.apps.casas.urls')),
path('admin/', admin.site.urls),
path('tinymce/', include('tinymce.urls')),
]
if settings.DEBUG:

Loading…
Cancel
Save