From 70916514b35b9537e289c20c8bf142939b95aa6c Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Mon, 4 Apr 2016 14:10:26 -0300 Subject: [PATCH] Adiciona migrations esquecidas --- materia/migrations/0027_auto_20160404_1409.py | 27 ++++++++ .../migrations/0016_auto_20160404_1409.py | 22 ++++++ sapl/utils.py | 68 ++++++++++--------- sessao/migrations/0016_auto_20160404_1409.py | 27 ++++++++ 4 files changed, 111 insertions(+), 33 deletions(-) create mode 100644 materia/migrations/0027_auto_20160404_1409.py create mode 100644 parlamentares/migrations/0016_auto_20160404_1409.py create mode 100644 sessao/migrations/0016_auto_20160404_1409.py diff --git a/materia/migrations/0027_auto_20160404_1409.py b/materia/migrations/0027_auto_20160404_1409.py new file mode 100644 index 000000000..c15f9015f --- /dev/null +++ b/materia/migrations/0027_auto_20160404_1409.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9 on 2016-04-04 17:09 +from __future__ import unicode_literals + +from django.db import migrations, models +import materia.models +import sapl.utils + + +class Migration(migrations.Migration): + + dependencies = [ + ('materia', '0026_auto_20160322_1514'), + ] + + operations = [ + migrations.AlterField( + model_name='materialegislativa', + name='texto_original', + field=models.FileField(blank=True, null=True, upload_to=materia.models.texto_upload_path, validators=[sapl.utils.restringe_tipos_de_arquivo_txt], verbose_name='Texto Original (PDF)'), + ), + migrations.AlterField( + model_name='proposicao', + name='texto_original', + field=models.FileField(blank=True, null=True, upload_to=materia.models.texto_upload_path, validators=[sapl.utils.restringe_tipos_de_arquivo_txt], verbose_name='Texto Original (PDF)'), + ), + ] diff --git a/parlamentares/migrations/0016_auto_20160404_1409.py b/parlamentares/migrations/0016_auto_20160404_1409.py new file mode 100644 index 000000000..c467f6c82 --- /dev/null +++ b/parlamentares/migrations/0016_auto_20160404_1409.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9 on 2016-04-04 17:09 +from __future__ import unicode_literals + +from django.db import migrations, models +import parlamentares.models +import sapl.utils + + +class Migration(migrations.Migration): + + dependencies = [ + ('parlamentares', '0015_auto_20160322_1401'), + ] + + operations = [ + migrations.AlterField( + model_name='parlamentar', + name='fotografia', + field=models.ImageField(blank=True, null=True, upload_to=parlamentares.models.foto_upload_path, validators=[sapl.utils.restringe_tipos_de_arquivo_img], verbose_name='Fotografia'), + ), + ] diff --git a/sapl/utils.py b/sapl/utils.py index 71f640578..6f7004c67 100644 --- a/sapl/utils.py +++ b/sapl/utils.py @@ -94,35 +94,35 @@ def listify(function): return f UF = [ - ('AC', 'Acre'), - ('AL', 'Alagoas'), - ('AP', 'Amapá'), - ('AM', 'Amazonas'), - ('BA', 'Bahia'), - ('CE', 'Ceará'), - ('DF', 'Distrito Federal'), - ('ES', 'Espírito Santo'), - ('GO', 'Goiás'), - ('MA', 'Maranhão'), - ('MT', 'Mato Grosso'), - ('MS', 'Mato Grosso do Sul'), - ('MG', 'Minas Gerais'), - ('PR', 'Paraná'), - ('PB', 'Paraíba'), - ('PA', 'Pará'), - ('PE', 'Pernambuco'), - ('PI', 'Piauí'), - ('RJ', 'Rio de Janeiro'), - ('RN', 'Rio Grande do Norte'), - ('RS', 'Rio Grande do Sul'), - ('RO', 'Rondônia'), - ('RR', 'Roraima'), - ('SC', 'Santa Catarina'), - ('SE', 'Sergipe'), - ('SP', 'São Paulo'), - ('TO', 'Tocantins'), - ('EX', 'Exterior'), - ] + ('AC', 'Acre'), + ('AL', 'Alagoas'), + ('AP', 'Amapá'), + ('AM', 'Amazonas'), + ('BA', 'Bahia'), + ('CE', 'Ceará'), + ('DF', 'Distrito Federal'), + ('ES', 'Espírito Santo'), + ('GO', 'Goiás'), + ('MA', 'Maranhão'), + ('MT', 'Mato Grosso'), + ('MS', 'Mato Grosso do Sul'), + ('MG', 'Minas Gerais'), + ('PR', 'Paraná'), + ('PB', 'Paraíba'), + ('PA', 'Pará'), + ('PE', 'Pernambuco'), + ('PI', 'Piauí'), + ('RJ', 'Rio de Janeiro'), + ('RN', 'Rio Grande do Norte'), + ('RS', 'Rio Grande do Sul'), + ('RO', 'Rondônia'), + ('RR', 'Roraima'), + ('SC', 'Santa Catarina'), + ('SE', 'Sergipe'), + ('SP', 'São Paulo'), + ('TO', 'Tocantins'), + ('EX', 'Exterior'), +] RANGE_ANOS = [(year, year) for year in range(date.today().year, 1889, -1)] @@ -146,7 +146,7 @@ TIPOS_TEXTO_PERMITIDOS = ( 'application/xml', 'text/xml', 'text/html', - ) +) TIPOS_IMG_PERMITIDOS = ( 'image/jpeg', @@ -169,16 +169,18 @@ TIPOS_IMG_PERMITIDOS = ( ) -def fabrica_validador_de_tipos_de_arquivo(lista): +def fabrica_validador_de_tipos_de_arquivo(lista, nome): def restringe_tipos_de_arquivo(value): mime = magic.from_buffer(value.read(), mime=True) mime = mime.decode() if mime not in lista: raise ValidationError(_('Tipo de arquivo não suportado')) + # o nome é importante para as migrations + restringe_tipos_de_arquivo.__name__ = nome return restringe_tipos_de_arquivo restringe_tipos_de_arquivo_txt = fabrica_validador_de_tipos_de_arquivo( - TIPOS_TEXTO_PERMITIDOS) + TIPOS_TEXTO_PERMITIDOS, 'restringe_tipos_de_arquivo_txt') restringe_tipos_de_arquivo_img = fabrica_validador_de_tipos_de_arquivo( - TIPOS_IMG_PERMITIDOS) + TIPOS_IMG_PERMITIDOS, 'restringe_tipos_de_arquivo_img') diff --git a/sessao/migrations/0016_auto_20160404_1409.py b/sessao/migrations/0016_auto_20160404_1409.py new file mode 100644 index 000000000..b436d098f --- /dev/null +++ b/sessao/migrations/0016_auto_20160404_1409.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9 on 2016-04-04 17:09 +from __future__ import unicode_literals + +from django.db import migrations, models +import sapl.utils +import sessao.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('sessao', '0015_auto_20160307_0918'), + ] + + operations = [ + migrations.AlterField( + model_name='sessaoplenaria', + name='upload_ata', + field=models.FileField(blank=True, null=True, upload_to=sessao.models.ata_upload_path, validators=[sapl.utils.restringe_tipos_de_arquivo_txt], verbose_name='Ata da Sessão'), + ), + migrations.AlterField( + model_name='sessaoplenaria', + name='upload_pauta', + field=models.FileField(blank=True, null=True, upload_to=sessao.models.pauta_upload_path, validators=[sapl.utils.restringe_tipos_de_arquivo_txt], verbose_name='Pauta da Sessão'), + ), + ]