mirror of https://github.com/interlegis/sapl.git
Browse Source
Co-authored-by: Cesar Carvalho <cesaraugc@gmail.com> Co-authored-by: ulyssesBML <ulysses3353@gmail.com> Aprimorando historico partido para armanzenar varias alterações Corrigindo migrations e adaptando historico na lista de parlamentares Adicionando data de alteração a update de partido para o uso de historico Arrumando erros de grupos e de histoico nulo Adicionando apagar historico e corrigindo erros mudando estrutura de historico Mudando nomes de partidos de acordo com a data no escopo de filiação de paramentares Resolvendo bug da tabela de historico e arrumando htmls com partido atual Removendo campo proximo não utilizado em historico do partidopull/2608/head
committed by
ulyssesBML
16 changed files with 473 additions and 72 deletions
@ -1,39 +1,15 @@ |
|||||
# -*- coding: utf-8 -*- |
# -*- coding: utf-8 -*- |
||||
|
# Generated by Django 1.11.20 on 2019-03-13 17:48 |
||||
from __future__ import unicode_literals |
from __future__ import unicode_literals |
||||
from django.db import migrations |
|
||||
import json |
|
||||
import os |
|
||||
|
|
||||
|
|
||||
from django.core.management import call_command |
|
||||
|
|
||||
|
from django.db import migrations |
||||
|
|
||||
def gera_partidos_tse(apps, schema_editor): |
|
||||
Partido = apps.get_model("parlamentares", "Partido") |
|
||||
db_alias = schema_editor.connection.alias |
|
||||
partidos = Partido.objects.all().exists() |
|
||||
|
|
||||
if partidos: |
|
||||
# Caso haja algum partido cadastrado na base de dados, |
|
||||
# a migração não deve ser carregada para evitar duplicações de dados. |
|
||||
print("Carga de Partido não efetuada. Já Existem partidos cadastrados...") |
|
||||
else: |
|
||||
fixture_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../fixtures')) |
|
||||
# pega partidos listados em fixtures/pre_popula_partidos.json |
|
||||
fixture_filename = 'pre_popula_partidos.json' |
|
||||
fixture_file = os.path.join(fixture_dir, fixture_filename) |
|
||||
call_command('loaddata', fixture_file, ignorenonexistent=True) |
|
||||
|
|
||||
class Migration(migrations.Migration): |
class Migration(migrations.Migration): |
||||
|
|
||||
dependencies = [ |
dependencies = [ |
||||
# A dependencia real desse script é o arquivo 0001_initial.py, mas |
|
||||
# isso gera um erro (Conflicting migrations detected; multiple leaf |
|
||||
# nodes in the migration graph). para não ocasionar problemas de migração, |
|
||||
# vamos manter a ordem padrão do django. |
|
||||
('parlamentares', '0022_partido_observacao'), |
('parlamentares', '0022_partido_observacao'), |
||||
] |
] |
||||
|
|
||||
operations = [ |
operations = [ |
||||
migrations.RunPython(gera_partidos_tse), |
|
||||
] |
] |
||||
|
|||||
@ -0,0 +1,15 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Generated by Django 1.11.20 on 2019-03-13 13:21 |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('parlamentares', '0025_auto_20180924_1724'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
] |
||||
@ -0,0 +1,39 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
from __future__ import unicode_literals |
||||
|
from django.db import migrations |
||||
|
import json |
||||
|
import os |
||||
|
|
||||
|
|
||||
|
from django.core.management import call_command |
||||
|
|
||||
|
|
||||
|
def gera_partidos_tse(apps, schema_editor): |
||||
|
Partido = apps.get_model("parlamentares", "Partido") |
||||
|
db_alias = schema_editor.connection.alias |
||||
|
partidos = Partido.objects.all().exists() |
||||
|
|
||||
|
if partidos: |
||||
|
# Caso haja algum partido cadastrado na base de dados, |
||||
|
# a migração não deve ser carregada para evitar duplicações de dados. |
||||
|
print("Carga de Partido não efetuada. Já Existem partidos cadastrados...") |
||||
|
else: |
||||
|
fixture_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../fixtures')) |
||||
|
# pega partidos listados em fixtures/pre_popula_partidos.json |
||||
|
fixture_filename = 'pre_popula_partidos.json' |
||||
|
fixture_file = os.path.join(fixture_dir, fixture_filename) |
||||
|
call_command('loaddata', fixture_file, ignorenonexistent=True) |
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
# A dependencia real desse script é o arquivo 0001_initial.py, mas |
||||
|
# isso gera um erro (Conflicting migrations detected; multiple leaf |
||||
|
# nodes in the migration graph). para não ocasionar problemas de migração, |
||||
|
# vamos manter a ordem padrão do django. |
||||
|
('parlamentares', '0026_partido_historico'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.RunPython(gera_partidos_tse), |
||||
|
] |
||||
@ -0,0 +1,31 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Generated by Django 1.11.20 on 2019-04-03 11:03 |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
import django.db.models.deletion |
||||
|
import django.utils.timezone |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('parlamentares', '0027_auto_20190313_1448'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.CreateModel( |
||||
|
name='HistoricoPartido', |
||||
|
fields=[ |
||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
||||
|
('sigla', models.CharField(max_length=9, verbose_name='Sigla')), |
||||
|
('nome', models.CharField(max_length=50, verbose_name='Nome')), |
||||
|
('data_alteracao', models.DateField(default=django.utils.timezone.now, verbose_name='Data Alteração')), |
||||
|
], |
||||
|
), |
||||
|
migrations.AddField( |
||||
|
model_name='historicopartido', |
||||
|
name='partido', |
||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='parlamentares.Partido'), |
||||
|
), |
||||
|
] |
||||
@ -0,0 +1,21 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Generated by Django 1.11.20 on 2019-04-09 11:23 |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
import django.db.models.deletion |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('parlamentares', '0028_auto_20190403_0803'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AddField( |
||||
|
model_name='historicopartido', |
||||
|
name='proximo', |
||||
|
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='parlamentares.HistoricoPartido'), |
||||
|
), |
||||
|
] |
||||
@ -0,0 +1,33 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Generated by Django 1.11.20 on 2019-04-09 13:30 |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
import django.utils.timezone |
||||
|
import sapl.parlamentares.models |
||||
|
import sapl.utils |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('parlamentares', '0029_historicopartido_proximo'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.RenameField( |
||||
|
model_name='historicopartido', |
||||
|
old_name='data_alteracao', |
||||
|
new_name='fim_historico', |
||||
|
), |
||||
|
migrations.AddField( |
||||
|
model_name='historicopartido', |
||||
|
name='inicio_historico', |
||||
|
field=models.DateField(default=django.utils.timezone.now, verbose_name='Data Alteração'), |
||||
|
), |
||||
|
migrations.AddField( |
||||
|
model_name='historicopartido', |
||||
|
name='logo_partido', |
||||
|
field=models.ImageField(blank=True, null=True, upload_to=sapl.parlamentares.models.logo_upload_path, validators=[sapl.utils.restringe_tipos_de_arquivo_img], verbose_name='Logo Partido'), |
||||
|
), |
||||
|
] |
||||
@ -0,0 +1,25 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Generated by Django 1.11.20 on 2019-04-11 12:19 |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
import django.db.models.deletion |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('parlamentares', '0030_auto_20190409_1030'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.RemoveField( |
||||
|
model_name='historicopartido', |
||||
|
name='proximo', |
||||
|
), |
||||
|
migrations.AlterField( |
||||
|
model_name='composicaocoligacao', |
||||
|
name='partido', |
||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='parlamentares.Partido', verbose_name='Partidos da Coligação'), |
||||
|
), |
||||
|
] |
||||
@ -0,0 +1,40 @@ |
|||||
|
{% extends "crud/form.html" %} |
||||
|
{% load i18n %} |
||||
|
{% load crispy_forms_tags cropping %} |
||||
|
|
||||
|
|
||||
|
{% block extra_js %} |
||||
|
<script language="Javascript"> |
||||
|
var sigla_inicial = "" |
||||
|
var nome_inicial = "" |
||||
|
|
||||
|
$(document).ready(function() { |
||||
|
|
||||
|
$("#id_data_modificacao").attr("disabled", true); |
||||
|
|
||||
|
check_change = () => { |
||||
|
if($("#id_historico").val() == 'nao'){ |
||||
|
$("#div_id_data_criacao").find("label").text("Data Criação") |
||||
|
$("#div_id_data_extincao").find("label").text("Data Extinção") |
||||
|
$( "#id_observacao" ).prop( "disabled", false ); |
||||
|
|
||||
|
} |
||||
|
else { |
||||
|
$("#div_id_data_criacao").find("label").text("Inicio do Histórico") |
||||
|
$("#div_id_data_extincao").find("label").text("Final do Histórico") |
||||
|
$( "#id_observacao" ).prop( "disabled", true ); |
||||
|
$( "#id_observacao" ).val(""); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
document.getElementById("id_historico").onchange = check_change |
||||
|
|
||||
|
}); |
||||
|
|
||||
|
function abilita_alteracao(){ |
||||
|
$("#id_data_modificacao").attr("disabled", false ); |
||||
|
} |
||||
|
|
||||
|
</script> |
||||
|
|
||||
|
{% endblock extra_js %} |
||||
Loading…
Reference in new issue