ConocimientoAbierto / policrowd

A website for crowd-sourcing structured politician data
https://beta.policrowd.org
GNU Affero General Public License v3.0
5 stars 0 forks source link

Add municipal areas #8

Closed martinszy closed 8 years ago

martinszy commented 8 years ago

We should add localities for the whole country.

This involves finding the shapefiles and importing them to mapit. Or using the OSM ones.

Context here: https://github.com/mysociety/yournextrepresentative/issues/532

martinszy commented 8 years ago

Comment from original issue: Here's the list of areas: http://www.ign.gob.ar/NuestasActividades/sigign#descarga Also here you can get a list of municipalities from a different source: https://github.com/jazzido/muniscraper

martinszy commented 8 years ago

Esto no está funcionando.

$ ./manage.py candidates_import_areas
Inserting Areas...

Traceback (most recent call last):
  File "./manage.py", line 45, in <module>
    execute_from_command_line(sys.argv)
  File "/home/poli/.virtualenvs/poli/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/home/poli/.virtualenvs/poli/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/poli/.virtualenvs/poli/local/lib/python2.7/site-packages/django/core/management/base.py", line 393, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/poli/.virtualenvs/poli/local/lib/python2.7/site-packages/django/core/management/base.py", line 444, in execute
    output = self.handle(*args, **options)
  File "/home/poli/yournextrepresentative/candidates/management/commands/candidates_import_areas.py", line 101, in handle
    self.fetchAllAreas()
  File "/home/poli/yournextrepresentative/candidates/management/commands/candidates_import_areas.py", line 72, in fetchAllAreas
    areaTypeId = self.areaTypesCache['MUN']
KeyError: 'MUN'
godiard commented 8 years ago

Aca hay que agregar un tipo de area "MUN"

martinszy commented 8 years ago

Esto lo tendrían que hacer las migraciones o quizás el mismo script de management. Lo voy a revisar.

martinszy commented 8 years ago

Modificaciones: Linea 49 argentinaId = Area.objects.get_or_create(name='Argentina')[0].id

Linea 58: munArea = AreaType.objects.get_or_create(name="MUN")

Nuevo error:

$ ./manage.py candidates_import_areas
Inserting Areas...

Traceback (most recent call last):
  File "./manage.py", line 45, in <module>
    execute_from_command_line(sys.argv)
  File "/home/poli/.virtualenvs/poli/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/home/poli/.virtualenvs/poli/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/poli/.virtualenvs/poli/local/lib/python2.7/site-packages/django/core/management/base.py", line 393, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/poli/.virtualenvs/poli/local/lib/python2.7/site-packages/django/core/management/base.py", line 444, in execute
    output = self.handle(*args, **options)
  File "/home/poli/yournextrepresentative/candidates/management/commands/candidates_import_areas.py", line 102, in handle
    self.fetchAllAreas()
  File "/home/poli/yournextrepresentative/candidates/management/commands/candidates_import_areas.py", line 81, in fetchAllAreas
    parentId = self.provincesAreasCache[self.areaDifferencesMap[parentAreaName]]
KeyError: 'BUENOS AIRES'
cesuarez commented 8 years ago

Acabo de hacer los cambios q hiciste vos con algunas modificaciones para que ya esté subido.

El script te está tirando ese error porque asume que las provincias ya están creadas en la Base de Datos. Si queres que el script también las agregue si no existen avisame

martinszy commented 8 years ago

Si, por favor, que tome el listado de un archivo externo y las cree. Por un lado para poder replicar el entorno de servidor en caso de reinstalación. Y además porque todo esto tiene que poder ser instalable sin tocar la db, con la esperanza de que un día nos dejen mergear.

El jue., 14 de abr. de 2016 a la(s) 14:47, cesuarez < notifications@github.com> escribió:

Acabo de hacer los cambios q hiciste vos con algunas modificaciones para que ya esté subido.

El script te está tirando ese error porque asume que las provincias ya están creadas en la Base de Datos. Si queres que el script también las agregue si no existen avisame

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/ConocimientoAbierto/yournextrepresentative/issues/8#issuecomment-210073203

martinszy commented 8 years ago

Funciona!