django-manolo Documentation

Transcripción

django-manolo Documentation
django-manolo Documentation
Release 2.3.2
aniversarioperu
January 27, 2015
Contents
1
Django-manolo
3
2
Manolo, buscador de lobistas
5
3
Motivación
7
4
Crea tu propio buscador de lobistas
9
5
Documentación
11
6
Fork from Gihub
13
7
Install
15
8
Troubleshooting
17
9
Configure
19
10 Instalación
21
11 Configuración
11.1 Agregar django-manolo a INSTALLED_APPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.2 Modifica tu archivo settings.py . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.3 Configurar los views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23
23
23
24
12 Uso
12.1 Ejecutar el scraper para jalar los registros de la institución Estatal . . . . . . . . . . . . . . . . . . .
25
25
13 Contributing
13.1 Types of Contributions .
13.2 Get Started! . . . . . . .
13.3 Pull Request Guidelines
13.4 Tips . . . . . . . . . . .
.
.
.
.
27
27
28
28
29
14 Credits
14.1 Development Lead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14.2 Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
31
31
31
15 History
15.1 2.3.2 (2015-01-27) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
33
33
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
i
15.2
15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
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
33
33
33
33
33
34
34
34
34
34
16 License
35
17 manolo
17.1 manolo package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
37
37
Python Module Index
39
ii
django-manolo Documentation, Release 2.3.2
Contenido:
Contents
1
django-manolo Documentation, Release 2.3.2
2
Contents
CHAPTER 1
Django-manolo
3
django-manolo Documentation, Release 2.3.2
4
Chapter 1. Django-manolo
CHAPTER 2
Manolo, buscador de lobistas
Presento un buscador de personas que ingresan las oficinas de entidades del Estado peruano. http://manolo.rocks
5
django-manolo Documentation, Release 2.3.2
6
Chapter 2. Manolo, buscador de lobistas
CHAPTER 3
Motivación
Todo aquel que visita el Organismo de Contrataciones debe registrarse dejando su nombre,
documento de identidad, motivo de visita, empleado público que lo recibe, hora de ingreso, salida y fecha.
Toda esta información está disponible en la Internet en esta dirección:
http://visitas.osce.gob.pe/controlVisitas/index.php?r=consultas/visitaConsulta/index
El problema es que la interfaz no es muy amigable y sólo se pueden buscar visitantes a la institución por día. Seleccionas cualquier día del menú y veras todos los visitantes que de esa fecha. Si quieres saber cuántas veces ha visitado
el lugar una determinada persona, debes buscar día por día, página por página, revisar línea por línea en búsqueda de
la persona de interés.
Obviamente este tipo de búsqueda es muy tedioso, aburrido, inexacto (se presta a errores de conteo) además que toma
demasiado tiempo hacer una simple búsqueda.
Por eso decidí construir un simple buscador de personas que visitan dicha institución estatal. La función de este
buscador simple: Tipeas un nombre y aparecerán en pantalla todas las veces que la persona tenga ingresos
registrados al Organismo de Contrataciones.
A partir de Manolo versión 2.0.0, la versión online (en http://manolo.rocks) contiene una base de datos unificada
conteniendo registro de visitas de 7 entidades del Estado peruano.
7
django-manolo Documentation, Release 2.3.2
8
Chapter 3. Motivación
CHAPTER 4
Crea tu propio buscador de lobistas
Ahora “Manolo” es un plugin para Django. Puedes crear rápidamente un buscador de lobistas para tu institución
estatal favorita. Para eso necesitas conseguir el link donde esté alojado el registro de visitas de la institución. Se lo das
a Manolo y él hará lo suyo.
Más información en un post en el blog Útero de Marita:
http://aniversarioperu.utero.pe/2014/03/08/manolo-buscador-de-lobistas/
Esta es la dirección web de Manolo, buscador de personas: http://manolo.rocks
9
django-manolo Documentation, Release 2.3.2
10
Chapter 4. Crea tu propio buscador de lobistas
CHAPTER 5
Documentación
“Manolo” es un paquete o app para Django y puede ser agregado fácilmente a algún proyecto de Django a manera de
plugin.
La documentación completa está en este enlace: https://django-manolo.readthedocs.org.
11
django-manolo Documentation, Release 2.3.2
12
Chapter 5. Documentación
CHAPTER 6
Fork from Gihub
Aquí puedes seguir el desarrollo de Manolo https://github.com/aniversarioperu/django-manolo
13
django-manolo Documentation, Release 2.3.2
14
Chapter 6. Fork from Gihub
CHAPTER 7
Install
• python3.4
15
django-manolo Documentation, Release 2.3.2
16
Chapter 7. Install
CHAPTER 8
Troubleshooting
If error in pickle version appears. Remove contents of whoosh index folder and rebuild the index:
python manage.py rebuild_index
--settings=manolo.settings.local
17
django-manolo Documentation, Release 2.3.2
18
Chapter 8. Troubleshooting
CHAPTER 9
Configure
Create a config.json file to keep private credentials to use by settings files:
{
"SECRET_KEY": "hola",
"DB_USER": "postgres",
"DB_PASS": "password",
"DB_NAME": "manolo",
"DB_PORT": "5432",
"DB_HOST": "localhost"
}
19
django-manolo Documentation, Release 2.3.2
20
Chapter 9. Configure
CHAPTER 10
Instalación
Lo más fácil es copiar el folder django-manolo/manolo dentro de tu proyecto Django, como si fuera una app adicional:
- django_project
- manage.py
- django_project
- manolo
- otra_app
También puedes usar un ambiente virtual:
$ mkvirtualenv django-manolo
$ pip install django-manolo
21
django-manolo Documentation, Release 2.3.2
22
Chapter 10. Instalación
CHAPTER 11
Configuración
11.1 Agregar django-manolo a INSTALLED_APPS
Al igual que la mayoría de apps para Django, es necesario que agregues a manolo en la lista de INSTALLED_APPS
dentro de tu archivo settings.py.
Ejemplo:
INSTALLED_APPS = [
’django.contrib.admin’,
’django.contrib.auth’,
’django.contrib.contenttypes’,
’django.contrib.sessions’,
’django.contrib.sites’,
# Agregado
’manolo’,
# Luego tu apps usuales...
’blog’,
]
11.2 Modifica tu archivo settings.py
En el archivo settings.py es necesario que agregues la información de la base de datos a utilizar. Manolo ha
sido desarrollado con la base de datos relacional Postgresql.
Es necesario instalar Postgresql en tu computadora y crear una base de datos llamada manolo. Luego debes
agregar los datos necesarios en la sección de DATABASES del archivo settings.py:
Ejemplo:
DATABASES = {
’default’: {
’ENGINE’: ’django.db.backends.postgresql_psycopg2’,
’NAME’: ’manolo’,
’USER’: ’INGRESAR EL NOMBRE DE USUARIO PARA POSTGRESQL’,
’PASSWORD’: u’PONER LA CONTRASEÑA PARA POSTGRESQL’,
’HOST’: ’localhost’,
’PORT’: ’’,
23
django-manolo Documentation, Release 2.3.2
}
}
11.3 Configurar los views
En tu URLconf debes agregar la siguiente línea:
(r’^manolo/’, include(’manolo.urls’, namespace=’manolo’)),
Esta configuración hará que “Manolo” funcione en el URL http://TUDOMINIO.com/manolo y funcione el
buscador en la dirección http://TUDOMINIO.com/manolo/search.
24
Chapter 11. Configuración
CHAPTER 12
Uso
12.1 Ejecutar el scraper para jalar los registros de la institución Estatal
“Manolo” tiene un scraper que se encarga de jalar las visitas registradas en la web de la institución estatal. Para esto es
necesario utilizar la línea de comandos de un terminal y además se necesita especificar la dirección URL del registro
de visitas en línea.
Ejemplo para scrappear el registro de visitas de la OSCE:
python manage.py scraper --url http://visitas.osce.gob.pe/controlVisitas/index.php?r=consultas/visita
Puedes hacer que este script funcione una vez al día, todos los días si usas un cronjob django-manolo
Luego de realizar la descarga de información (demorará un buen rato) encontrarás el motor de búsqueda de Manolo
en la siguiente dirección:
http://TU-DOMINIO.com/manolo
25
django-manolo Documentation, Release 2.3.2
26
Chapter 12. Uso
CHAPTER 13
Contributing
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
13.1 Types of Contributions
13.1.1 Report Bugs
Report bugs at https://github.com/aniversarioperu/django-manolo/issues.
If you are reporting a bug, please include:
• Your operating system name and version.
• Any details about your local setup that might be helpful in troubleshooting.
• Detailed steps to reproduce the bug.
13.1.2 Fix Bugs
Look through the GitHub issues for bugs. Anything tagged with “bug” is open to whoever wants to implement it.
13.1.3 Implement Features
Look through the GitHub issues for features. Anything tagged with “feature” is open to whoever wants to implement
it.
13.1.4 Write Documentation
django-manolo could always use more documentation, whether as part of the official django-manolo docs, in docstrings, or even on the web in blog posts, articles, and such.
13.1.5 Submit Feedback
The best way to send feedback is to file an issue at https://github.com/aniversarioperu/django-manolo/issues.
If you are proposing a feature:
27
django-manolo Documentation, Release 2.3.2
• Explain in detail how it would work.
• Keep the scope as narrow as possible, to make it easier to implement.
• Remember that this is a volunteer-driven project, and that contributions are welcome :)
13.2 Get Started!
Ready to contribute? Here’s how to set up django-manolo for local development.
1. Fork the django-manolo repo on GitHub.
2. Clone your fork locally:
$ git clone [email protected]:your_name_here/django-manolo.git
3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up
your fork for local development:
$ mkvirtualenv django-manolo
$ cd django-manolo/
$ python setup.py develop
4. Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
5. When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python
versions with tox:
$ flake8 manolo tests
$ python setup.py test
$ tox
To get flake8 and tox, just pip install them into your virtualenv.
6. Commit your changes and push your branch to GitHub:
$ git add .
$ git commit -m "Your detailed description of your changes."
$ git push origin name-of-your-bugfix-or-feature
7. Submit a pull request through the GitHub website.
13.3 Pull Request Guidelines
Before you submit a pull request, check that it meets these guidelines:
1. The pull request should include tests.
2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function
with a docstring, and add the feature to the list in README.rst.
3. The pull request should work for Python 2.6, 2.7, and 3.3, and for PyPy.
Check https://travisci.org/aniversarioperu/django-manolo/pull_requests and make sure that the tests pass for all supported Python
versions.
28
Chapter 13. Contributing
django-manolo Documentation, Release 2.3.2
13.4 Tips
To run a subset of tests:
$ python -m unittest tests.test_manolo
13.4. Tips
29
django-manolo Documentation, Release 2.3.2
30
Chapter 13. Contributing
CHAPTER 14
Credits
14.1 Development Lead
• AniversarioPeru <[email protected]>
14.2 Contributors
None yet. Why not be the first?
31
django-manolo Documentation, Release 2.3.2
32
Chapter 14. Credits
CHAPTER 15
History
15.1 2.3.2 (2015-01-27)
• Corregir bug en template, search_result.html
15.2 2.3.1 (2015-01-27)
• Corregir páginas 404 y 500.
15.3 2.3.0 (2015-01-27)
• Posibilidad de retornar resultados al hacer click sobre fechas.
15.4 2.2.0 (2015-01-27)
• Agregado el Minem a la lista de entidades estatales.
• Conteo de resultados con coma.
15.5 2.1.0 (2015-01-27)
• Ahora usando elasticseach para indexar la base de datos.
• Es más rápido que whoosh.
15.6 2.0.0 (2015-01-25)
• Gran reorganización de models.
• Manolo unificado, usando base de datos indexada via whoosh.
33
django-manolo Documentation, Release 2.3.2
15.7 1.1.0 (2014-11-19)
• Ahora con paginación de la búsqueda de resultados.
15.8 1.0.3 (2014-09-04)
• Documentación.
15.9 1.0.2 (2014-09-04)
• Agregando logo.
15.10 1.0.1 (2014-09-02)
• Actualizando dependencia requests
15.11 1.0.0 (2014-08-31)
• Empaquetado como app para Django.
34
Chapter 15. History
CHAPTER 16
License
Copyright (c) 2015, AniversarioPeru All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
following conditions are met:
• Redistributions of source code must retain the above copyright notice, this list of conditions and the following
disclaimer.
• Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
• Neither the name of django-manolo nor the names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
django-manolo Documentation, Release 2.3.2
36
Chapter 16. License
CHAPTER 17
manolo
17.1 manolo package
17.1.1 Subpackages
manolo.apps package
Subpackages
manolo.apps.visitors package
Subpackages
manolo.apps.visitors.migrations package
Submodules
manolo.apps.visitors.migrations.0001_initial module
class manolo.apps.visitors.migrations.0001_initial.Migration(name, app_label)
Bases: django.db.migrations.migration.Migration
dependencies = []
operations = [<CreateModel fields=[(u’id’, <django.db.models.fields.AutoField>), (u’sha1’, <django.db.models.fields.C
manolo.apps.visitors.migrations.0002_auto_20150123_1322 module
class manolo.apps.visitors.migrations.0002_auto_20150123_1322.Migration(name,
app_label)
Bases: django.db.migrations.migration.Migration
dependencies = [(u’visitors’, u‘0001_initial’)]
operations = [<AlterField field=<django.db.models.fields.CharField>, preserve_default=True, name=u’id_number’, mo
Module contents
37
django-manolo Documentation, Release 2.3.2
Submodules
manolo.apps.visitors.admin module
manolo.apps.visitors.models module
manolo.apps.visitors.search_indexes module
manolo.apps.visitors.tests module
manolo.apps.visitors.urls module
manolo.apps.visitors.views module
manolo.apps.visitors.views.do_pagination(request, all_items)
Parameters
• request – contains the current page requested by user
• all_items –
Returns dict containing paginated items and pagination bar
manolo.apps.visitors.views.index(request)
manolo.apps.visitors.views.search_date(request)
Module contents
Module contents
17.1.2 Submodules
17.1.3 manolo.urls module
17.1.4 manolo.wsgi module
WSGI config for project.
This module contains the WSGI application used by Django’s development server and any production WSGI deployments. It should expose a module-level variable named application. Django’s runserver and runfcgi
commands discover this application via the WSGI_APPLICATION setting.
Usually you will have the standard Django WSGI application here, but it also might make sense to replace the whole
Django WSGI application with a custom one that later delegates to the Django one. For example, you could introduce
WSGI middleware here, or combine a Django application with an application of another framework.
17.1.5 Module contents
38
Chapter 17. manolo
Python Module Index
m
manolo, 38
manolo.apps, 38
manolo.apps.visitors, 38
manolo.apps.visitors.migrations, 37
manolo.apps.visitors.migrations.0001_initial,
37
manolo.apps.visitors.migrations.0002_auto_20150123_1322,
37
manolo.apps.visitors.tests, 38
manolo.apps.visitors.urls, 38
manolo.apps.visitors.views, 38
manolo.wsgi, 38
39
django-manolo Documentation, Release 2.3.2
40
Python Module Index
Index
D
dependencies (manolo.apps.visitors.migrations.0001_initial.Migration
attribute), 37
dependencies (manolo.apps.visitors.migrations.0002_auto_20150123_1322.Migration
attribute), 37
do_pagination() (in module manolo.apps.visitors.views),
38
I
index() (in module manolo.apps.visitors.views), 38
M
manolo (module), 38
manolo.apps (module), 38
manolo.apps.visitors (module), 38
manolo.apps.visitors.migrations (module), 37
manolo.apps.visitors.migrations.0001_initial (module),
37
manolo.apps.visitors.migrations.0002_auto_20150123_1322
(module), 37
manolo.apps.visitors.tests (module), 38
manolo.apps.visitors.urls (module), 38
manolo.apps.visitors.views (module), 38
manolo.wsgi (module), 38
Migration (class in manolo.apps.visitors.migrations.0001_initial),
37
Migration (class in manolo.apps.visitors.migrations.0002_auto_20150123_1322),
37
O
operations (manolo.apps.visitors.migrations.0001_initial.Migration
attribute), 37
operations (manolo.apps.visitors.migrations.0002_auto_20150123_1322.Migration
attribute), 37
S
search_date() (in module manolo.apps.visitors.views), 38
41

Documentos relacionados