mirror of https://github.com/interlegis/sigi.git
Sesostris Vieira
3 years ago
6 changed files with 86 additions and 74 deletions
@ -1,43 +0,0 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# |
|||
# sigi.apps.casas.management.commands.importa_gerentes |
|||
# |
|||
# Copyright (c) 2015 by Interlegis |
|||
# |
|||
# GNU General Public License (GPL) |
|||
# |
|||
# 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.core.management.base import BaseCommand, CommandError |
|||
from sigi.apps.convenios.models import Projeto, Convenio |
|||
|
|||
class Command(BaseCommand): |
|||
help = u"""Define a duração de todos os ACT para 60 meses. |
|||
* A sigla do Projeto precisa ser ACT; |
|||
* O campo duracao precisa estar em branco. |
|||
""" |
|||
|
|||
def handle(self, *args, **options): |
|||
self.stdout.write(u"Atualizando ACTs... ") |
|||
act = Projeto.objects.get(sigla='ACT') |
|||
for conv in Convenio.objects.filter(projeto=act, duracao=None): |
|||
conv.duracao = 60 |
|||
conv.save() |
|||
self.stdout.write(u"\tACT {sigad} da Casa {casa} atualizado".format( |
|||
sigad=conv.num_processo_sf, casa=conv.casa_legislativa.nome |
|||
)) |
|||
self.stdout.write(u"Pronto!") |
@ -0,0 +1,20 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import models, migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('convenios', '0010_auto_20210819_0833'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AddField( |
|||
model_name='convenio', |
|||
name='data_termino_vigencia', |
|||
field=models.DateField(help_text='T\xe9rmino da vig\xeancia do conv\xeanio.', null=True, verbose_name='Data t\xe9rmino vig\xeancia', blank=True), |
|||
preserve_default=True, |
|||
), |
|||
] |
@ -0,0 +1,38 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from __future__ import unicode_literals |
|||
from datetime import date |
|||
from django.db import models, migrations |
|||
|
|||
def migra_data_termino_vigencia(apps, schema_editor): |
|||
Convenio = apps.get_model('convenios', 'Convenio') |
|||
|
|||
for c in Convenio.objects.all(): |
|||
if (c.data_retorno_assinatura is None or c.duracao is None): |
|||
continue |
|||
|
|||
ano = c.data_retorno_assinatura.year + int(c.duracao / 12) |
|||
mes = int(c.data_retorno_assinatura.month + int(c.duracao % 12)) |
|||
if mes > 12: |
|||
ano = ano + 1 |
|||
mes = mes - 12 |
|||
dia = c.data_retorno_assinatura.day |
|||
|
|||
while True: |
|||
try: |
|||
data_fim = date(year=ano, month=mes,day=dia) |
|||
break |
|||
except: |
|||
dia = dia - 1 |
|||
|
|||
c.data_termino_vigencia = data_fim |
|||
c.save() |
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('convenios', '0011_convenio_data_termino_vigencia'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.RunPython(migra_data_termino_vigencia), |
|||
] |
@ -0,0 +1,18 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import models, migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('convenios', '0012_auto_20210831_0844'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.RemoveField( |
|||
model_name='convenio', |
|||
name='duracao', |
|||
), |
|||
] |
Loading…
Reference in new issue