Skip to content

Commit

Permalink
feat(vote): Included year arg to django command
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiomario committed Oct 10, 2024
1 parent cc7d3fc commit bcae407
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ def add_arguments(self, parser):
type=str,
help="Tipo de eleição: 'vereador' ou 'prefeito'."
)

parser.add_argument(
'ano',
type=int,
help="Ano da eleição."
)

def map_situacao_to_status(self, situacao, eleicao):
"""
Expand All @@ -40,6 +46,7 @@ def map_situacao_to_status(self, situacao, eleicao):

def handle(self, *args, **kwargs):
eleicao = kwargs['eleicao']
ano = kwargs['ano']

# Define o caminho correto para o CSV com base no tipo de eleição
if eleicao == 'vereador':
Expand Down Expand Up @@ -68,7 +75,7 @@ def handle(self, *args, **kwargs):
csv_data[chave_composta] = row

# Carrega todas as candidaturas da base de dados
candidatures = Candidature.objects.all()
candidatures = Candidature.objects.filter(election_year=ano)

# Itera pelas candidaturas e busca os resultados no CSV
for candidature in candidatures:
Expand Down

0 comments on commit bcae407

Please sign in to comment.