From a2199b1a6ae717ecf3db13b846226c7d2599e241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Cantu=C3=A1ria?= Date: Wed, 3 Apr 2019 14:45:06 -0300 Subject: [PATCH] =?UTF-8?q?Simplifica=C3=A7=C3=A3o=20do=20dicion=C3=A1rio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/remove_multiplos_parlamentares.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/remove_multiplos_parlamentares.py b/scripts/remove_multiplos_parlamentares.py index 3d7450295..d99bef743 100644 --- a/scripts/remove_multiplos_parlamentares.py +++ b/scripts/remove_multiplos_parlamentares.py @@ -15,19 +15,18 @@ def get_multiple(): for model in models: model_name = re.findall(r'\w+', str(model))[-1] main_models[model_name] = { - 'model': model, 'kwargs': {}, 'pks': [] } - objs = main_models[model_name]['model'].objects.all() + objs = model.objects.all() for obj in objs: if model_name == 'Autor': main_models[model_name]['kwargs']['nome'] = obj.nome elif model_name == 'Parlamentar': main_models[model_name]['kwargs']['nome_parlamentar'] = obj.nome_parlamentar - pesquisa_obj = main_models[model_name]['model'].objects.filter(**main_models[model_name]['kwargs']) + pesquisa_obj = model.objects.filter(**main_models[model_name]['kwargs']) if pesquisa_obj.count() > 1: multiplos_objs = [o.pk for o in pesquisa_obj] multiplos_objs.sort() @@ -35,6 +34,8 @@ def get_multiple(): if multiplos_objs not in main_models[model_name]['pks']: main_models[model_name]['pks'].append(multiplos_objs) + main_models[model_name].pop('kwargs') + return main_models