From 05145d0d6e93ad5e860f13f5289592c5b4ece6e8 Mon Sep 17 00:00:00 2001 From: Victor Fabre Date: Mon, 7 May 2018 14:28:59 -0300 Subject: [PATCH 1/6] Fix #1874 removendo acento (#1923) * Fix #1874 removendo acento * Fix #1874 sem remover acentos --- sapl/sessao/views.py | 10 ++++++---- sapl/templates/sessao/mesa.html | 2 +- sapl/utils.py | 3 +-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/sapl/sessao/views.py b/sapl/sessao/views.py index 746bbfec1..db3875677 100644 --- a/sapl/sessao/views.py +++ b/sapl/sessao/views.py @@ -4,7 +4,7 @@ from operator import itemgetter from django.contrib import messages from django.contrib.auth.decorators import permission_required from django.contrib.auth.mixins import PermissionRequiredMixin -from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist +from django.core.exceptions import ObjectDoesNotExist from django.core.urlresolvers import reverse from django.db.models import Max, Q from django.forms.utils import ErrorList @@ -990,8 +990,8 @@ class MesaView(FormMixin, DetailView): set( [p.parlamentar for p in parlamentares]) - set( parlamentares_ocupados)) - - org_parlamentares_vagos = sorted(parlamentares_vagos, key=lambda x: x.nome_parlamentar) + org_parlamentares_vagos = parlamentares_vagos + org_parlamentares_vagos.sort(key=lambda x: remover_acentos(x.nome_parlamentar)) org_parlamentares_vagos = [p for p in org_parlamentares_vagos if p.ativo] # Se todos os cargos estiverem ocupados, a listagem de parlamentares # deve ser renderizada vazia @@ -1046,8 +1046,10 @@ def atualizar_mesa(request): lista_composicao = [(c.id, c.parlamentar.__str__(), c.cargo.__str__()) for c in composicao_mesa] lista_parlamentares = [( - p.id, p.__str__()) for p in parlamentares_vagos] + p.id, p.nome_parlamentar) + for p in parlamentares_vagos if p.ativo] lista_cargos = [(c.id, c.__str__()) for c in cargos_vagos] + lista_parlamentares.sort(key=lambda x: remover_acentos(x[1])) return JsonResponse( {'lista_composicao': lista_composicao, diff --git a/sapl/templates/sessao/mesa.html b/sapl/templates/sessao/mesa.html index 02f313656..56e7f9989 100644 --- a/sapl/templates/sessao/mesa.html +++ b/sapl/templates/sessao/mesa.html @@ -38,7 +38,7 @@
diff --git a/sapl/utils.py b/sapl/utils.py index 8045f0e0b..69ea53dfc 100644 --- a/sapl/utils.py +++ b/sapl/utils.py @@ -735,5 +735,4 @@ def RemoveTag(texto): return textoSaida def remover_acentos(string): - return ''.join([c for c in unicodedata.normalize('NFD', string) - if unicodedata.category(c) != 'Mn']) \ No newline at end of file + return unicodedata.normalize('NFKD', string).encode('ASCII', 'ignore').decode() \ No newline at end of file From 5c03a9f74fb4df6db9577d51bd0ab51636b66483 Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Mon, 7 May 2018 14:34:03 -0300 Subject: [PATCH 2/6] =?UTF-8?q?Adiciona=20op=C3=A7=C3=A3o=20de=20n=C3=A3o?= =?UTF-8?q?=20enviar=20ao=20github?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- release.sh | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/release.sh b/release.sh index 78fee9187..437355e57 100755 --- a/release.sh +++ b/release.sh @@ -6,14 +6,40 @@ MAIN_REV=`echo $VERSION | cut -f 1,2 -d '.'` NEXT_NUMBER=$(($LAST_DIGIT + 1)) NEXT_VERSION=$MAIN_REV'.'$NEXT_NUMBER -sed -e s/$VERSION/$NEXT_VERSION/g docker-compose.yml > tmp1 -mv tmp1 docker-compose.yml -sed -e s/$VERSION/$NEXT_VERSION/g setup.py > tmp2 -mv tmp2 setup.py +function bump_version { + sed -e s/$VERSION/$NEXT_VERSION/g docker-compose.yml > tmp1 + mv tmp1 docker-compose.yml + + sed -e s/$VERSION/$NEXT_VERSION/g setup.py > tmp2 + mv tmp2 setup.py +} + +function commit_and_push { + echo "committing..." + git add docker-compose.yml setup.py + git commit -m "Release: $NEXT_VERSION" + git tag $NEXT_VERSION + + echo "sending to github..." + git push origin $NEXT_VERSION + git push origin + + echo "done." +} + +case "$1" in + --dryrun) + echo "Dry run" + bump_version + echo "done." + echo "Run git checkout -- docker-compose.yml setup.py to undo the files" + + exit 0 + ;; + --a) + echo "generating release" + bump_version + commit_and_push +esac -git add docker-compose.yml setup.py -git commit -m "Release: $NEXT_VERSION" -git tag $NEXT_VERSION -git push origin $NEXT_VERSION -git push origin From 69f9aa48e71df839357e29b1ef0430cf5a89de31 Mon Sep 17 00:00:00 2001 From: VictorFabreF Date: Mon, 7 May 2018 14:37:10 -0300 Subject: [PATCH 3/6] Release: 3.1.77 --- docker-compose.yml | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index f721b66f0..55a6b2359 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,7 @@ sapldb: ports: - "5432:5432" sapl: - image: interlegis/sapl:3.1.76 + image: interlegis/sapl:3.1.77 restart: always environment: ADMIN_PASSWORD: interlegis diff --git a/setup.py b/setup.py index da929d87c..af5b2c7d2 100644 --- a/setup.py +++ b/setup.py @@ -49,7 +49,7 @@ install_requires = [ ] setup( name='interlegis-sapl', - version='3.1.76', + version='3.1.77', packages=find_packages(), include_package_data=True, license='GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007', From f3102a787da6ee2b48a539df0ca559aa3a0de3e1 Mon Sep 17 00:00:00 2001 From: VictorFabreF Date: Tue, 8 May 2018 08:53:55 -0300 Subject: [PATCH 4/6] HOT-FIX: fix #1918 --- sapl/templates/norma/subnav.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapl/templates/norma/subnav.yaml b/sapl/templates/norma/subnav.yaml index d050a469f..a89326fd7 100644 --- a/sapl/templates/norma/subnav.yaml +++ b/sapl/templates/norma/subnav.yaml @@ -4,7 +4,7 @@ url: normajuridica_detail - title: {% trans 'Alterações em Outras Normas' %} url: normarelacionada_list - check_permission: norma.normarelacionada_list + check_permission: norma.list_normarelacionada # Opção adicionada para chamar o TextoArticulado da norma. # para integração foram necessárias apenas criar a url norma_ta em urls.py From 80e91fc8cb2b956b81a1aaa92df8e8265bc011f2 Mon Sep 17 00:00:00 2001 From: Talitha Pumar Date: Tue, 8 May 2018 17:01:55 -0100 Subject: [PATCH 5/6] Fix #1922 (#1927) * Fix #1922 * Update forms.py --- sapl/materia/forms.py | 30 +++++++++++++++++++++++++----- sapl/protocoloadm/forms.py | 16 ++++++++++++++++ 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py index e083e7fec..e5ff928d7 100644 --- a/sapl/materia/forms.py +++ b/sapl/materia/forms.py @@ -36,7 +36,7 @@ from sapl.materia.models import (AssuntoMateria, Autoria, MateriaAssunto, from sapl.norma.models import (LegislacaoCitada, NormaJuridica, TipoNormaJuridica) from sapl.parlamentares.models import Legislatura -from sapl.protocoloadm.models import Protocolo +from sapl.protocoloadm.models import Protocolo, DocumentoAdministrativo from sapl.settings import MAX_DOC_UPLOAD_SIZE from sapl.utils import (RANGE_ANOS, YES_NO_CHOICES, ChoiceWithoutValidationField, @@ -182,19 +182,39 @@ class MateriaLegislativaForm(ModelForm): data_apresentacao = cleaned_data['data_apresentacao'] ano = cleaned_data['ano'] + protocolo = cleaned_data['numero_protocolo'] + protocolo_antigo = self.instance.numero_protocolo + + if protocolo: + if not Protocolo.objects.filter(numero=protocolo,ano=ano).exists(): + raise ValidationError(_('Protocolo %s/%s não' + ' existe' % (protocolo, ano))) + + if protocolo_antigo != protocolo: + exist_materia = MateriaLegislativa.objects.filter( + numero_protocolo=protocolo, + ano=ano).exists() + + exist_doc = DocumentoAdministrativo.objects.filter( + protocolo_id=protocolo, + ano=ano).exists() + if exist_materia or exist_doc: + raise ValidationError(_('Protocolo %s/%s ja possui' + ' documento vinculado' + % (protocolo, ano))) if data_apresentacao.year != ano: - raise ValidationError("O ano da matéria não pode ser " - "diferente do ano na data de apresentação") + raise ValidationError(_("O ano da matéria não pode ser " + "diferente do ano na data de apresentação")) ano_origem_externa = cleaned_data['ano_origem_externa'] data_origem_externa = cleaned_data['data_origem_externa'] if ano_origem_externa and data_origem_externa and \ ano_origem_externa != data_origem_externa.year: - raise ValidationError("O ano de origem externa da matéria não " + raise ValidationError(_("O ano de origem externa da matéria não " "pode ser diferente do ano na data de " - "origem externa") + "origem externa")) return cleaned_data diff --git a/sapl/protocoloadm/forms.py b/sapl/protocoloadm/forms.py index 06a2f7854..e85e9ecf2 100644 --- a/sapl/protocoloadm/forms.py +++ b/sapl/protocoloadm/forms.py @@ -698,6 +698,22 @@ class DocumentoAdministrativoForm(ModelForm): numero_protocolo, ano_protocolo)) raise ValidationError(msg) + inst = self.instance.protocolo + protocolo_antigo = inst.numero if inst else None + + if str(protocolo_antigo) != numero_protocolo: + exist_materia = MateriaLegislativa.objects.filter( + numero_protocolo=numero_protocolo, + ano=ano_protocolo).exists() + + exist_doc = DocumentoAdministrativo.objects.filter( + protocolo_id=numero_protocolo, + ano=ano_protocolo).exists() + if exist_materia or exist_doc: + raise ValidationError(_('Protocolo %s/%s ja possui' + ' documento vinculado' + % (numero_protocolo, ano_protocolo))) + return self.cleaned_data def save(self, commit=True): From 7e2341ac78da87b58d9e56f95a8a4235b99fe907 Mon Sep 17 00:00:00 2001 From: Edward Date: Wed, 9 May 2018 18:18:49 -0300 Subject: [PATCH 6/6] Fixes #1931 (#1932) --- sapl/materia/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sapl/materia/views.py b/sapl/materia/views.py index a23932b42..74f2bd6b6 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -937,7 +937,8 @@ class RelatoriaCrud(MasterDetailCrud): except ObjectDoesNotExist: pass else: - composicao = comissao.composicao_set.last() + composicao = comissao.composicao_set.order_by( + '-periodo__data_inicio').first() participacao = Participacao.objects.filter( composicao=composicao)