Commit 71da78ad authored by Arnaud Fabre's avatar Arnaud Fabre

adds a command to update country

parent a7e24e13
......@@ -3,39 +3,11 @@ from __future__ import absolute_import
from django.db import transaction
from django.core.management.base import BaseCommand
import pyprind
import representatives.models
import legislature.models
from legislature.models import MemopolRepresentative
class Command(BaseCommand):
@transaction.atomic
def handle(self, *args, **options):
bar = pyprind.ProgBar(representatives.models.Representative.objects.all().count())
for i, representative in enumerate(representatives.models.Representative.objects.all()):
try:
memopol_representative = legislature.models.MemopolRepresentative.objects.get(
representative_remote_id = representative.remote_id
)
except legislature.models.MemopolRepresentative.DoesNotExist:
memopol_representative = legislature.models.MemopolRepresentative(
representative_remote_id = representative.remote_id
)
memopol_representative.representative_ptr_id = representative.pk
memopol_representative.__dict__.update(representative.__dict__)
memopol_representative.save()
memopol_representative.update_country()
bar.update()
for i, group_item in enumerate(representatives.models.Group.objects.all()):
memopol_group, _ = legislature.models.MemopolGroup.objects.get_or_create(
group = group_item
)
memopol_group.__dict__.update(group_item.__dict__)
memopol_group.update_active()
memopol_group.save()
for representative in MemopolRepresentative.objects.all():
representative.update_score()
- extends "base.html"
- extends 'base.html'
- block content
......
......@@ -15,7 +15,6 @@ def representatives_index(request):
active=True
)
)
return _render_list(request, representative_list)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment