Skip to content

Commit

Permalink
1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aniversarioperu committed Sep 24, 2014
1 parent 01a43aa commit 8b31fb0
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 15 deletions.
5 changes: 3 additions & 2 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
History
=======

* Scrapping more metadata from seguimiento_page. Killed bug to get PDF url
when the filename includes funny characters.
* v1.2.0 (2014-09-24) Scrapping more metadata from seguimiento_page. Killed
bug to get PDF url when the filename includes funny characters. Custom
command to update `seguimiento` events for each project in our database.
* v1.1.1 (2014-09-22) Favicon. Don't show navigation bar if there are no
results.
* v1.1.0 (2014-09-21) Pagination for search results (40 items per page).
Expand Down
14 changes: 8 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ del folder que contiene el proyecto de Django::
$ python yourapp/manage.py runserver --settings=yourapp.settings.local


Ejecutar el scrapper
--------------------
* El comando ``python manage.py scrape`` se encarga de cosechar la
Comandos de mantenimiento
-------------------------
* El comando **``python manage.py scrape``** se encarga de cosechar la
información del servidor del congreso y almacernarla en una base de datos
local.
* Toda la información cosechada se almancena en una base de datos SQLite3.
Django se encarga de servir las páginas y motor de búsqueda.
local. Toda la información cosechada se almancena en una base de datos
SQLite3. Django se encarga de servir las páginas y motor de búsqueda.
* El comando **``python manage.py update_seguimientos``** trata de actualizar
nuevos eventos para cada uno de los proyectos almacenados en la base de
datos. Ejecutar este comando una vez a la semana.

Plantilla HTML
--------------
Expand Down
20 changes: 14 additions & 6 deletions proyectos_de_ley/pdl/management/commands/update_seguimientos.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
"""Custom command to run weekly. It goes through all `proyectos` in our
database and looks of new events in the `seguimiento_page`. It tries to
update our database with new `seguimiento` events for each `proyecto`."""
from optparse import make_option

from django.core.management.base import BaseCommand, CommandError
from pdl.management.commands.scraper import Command as ScraperCommand
from django.core.management.base import BaseCommand

from pdl.management.commands.scraper import Command as ScraperCommand
from pdl.models import Proyecto


class Command(ScraperCommand):
"""Inherits some methods from our scraper class."""
"""Need some inherited methods from our scraper class."""
option_list = BaseCommand.option_list + (
make_option('--test',
action='store_true',
dest='test',
default=False,
help='Use when running tests to stop after one iteration.',
),
)
def handle(self, *args, **options):
self.tor = False

Expand All @@ -20,7 +29,6 @@ def handle(self, *args, **options):
events = self.get_seguimientos(soup)

self.save_seguimientos(events, codigo)
for j in events:
print(j)
break

if options['test'] is True:
break
42 changes: 42 additions & 0 deletions proyectos_de_ley/pdl/tests/test_update_seguimientos_cmd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# -*- encoding: utf-8 -*-
from datetime import date

from django.test import TestCase

from pdl.management.commands.update_seguimientos import Command
from pdl.models import Proyecto
from pdl.models import Seguimientos


class USeguimientosTest(TestCase):
def setUp(self):
self.cmd = Command()
self.maxDiff = None

def test_handle(self):
args = ()
options = {
'settings': 'proyectos_de_ley.settings.local',
'no_color': False, 'full_scrapping': False, 'verbosity': '1',
'traceback': None, 'tor': False, 'debug': True, 'test': True,
'pythonpath': None
}

# save an item to our test database
item = {
'codigo': '03774',
'seguimiento_page': 'http://www2.congreso.gob.pe/Sicr/TraDocEst'
'Proc/CLProLey2011.nsf/Sicr/TraDocEstProc/C'
'LProLey2011.nsf/PAporNumeroInverso/9609130'
'B9871582F05257D4A00752301?opendocument',
'fecha_presentacion': date.today(),
}
b = Proyecto(**item)
b.save()

seguimientos = Seguimientos.objects.all()
self.assertEqual(len(seguimientos), 0)

self.cmd.handle(self, *args, **options)
seguimientos = Seguimientos.objects.all()
self.assertGreater(len(seguimientos), 1)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from distutils.core import setup

import proyectos_de_ley
version = '1.1.1'
version = '1.2.0'

setup(
name='proyectos_de_ley',
Expand Down

0 comments on commit 8b31fb0

Please sign in to comment.