Django Cal-Access Lobbying Activity¶
django-calacces-lobbying-activity is a simple Django app to lobbying activity data from the cal access database. It is reliant on django-calaccess-parser.
Detailed documentation is in the “docs” directory. (coming soon)
Requirements¶
- Django 1.6
- django.contrib.humanize
- MySQL 5.5
- django-calaccess-parser
- Patience
Installation¶
Install django-calaccess-browser with pip
$ pip install django-calaccess-lobbying-activity
Add lobbying to your INSTALLED_APPS setting like this:
INSTALLED_APPS = ( ... 'lobbying', )
In your project urls.py:
... urlpatterns = patterns('', url(r'^browser/', include('lobbying.urls')), )
Next, sync the database, create a Django admin user, and run the management command to extract campaign finance data from from the raw calaccess data dump.
$ python manage.py syncdb $ python manage.py build_lobbying
warning: This’ll take a while. Go grab some coffee or do something else productive with your life.
Building¶
The JavaScript and CSS for the project is managed with Grunt and Bower. Currently, the JavaScript and SCSS dependencies are not included so you’ll need to build them yourself;
- Install Node.js (this will also include NPM)
- Install Grunt and bower globally with npm install -g bower grunt-cli
- Go to the static directory and install the required dependencies with npm install && bower install
- Generate the main.css file and watch for HTML, CSS and JavaScript changes by executing grunt
Explore data¶
Start the development server and visit http://127.0.0.1:8000/browser/ to inspect the Cal-access data.
API¶
django-calaccess-browser uses django-tastypie to expose the data as an API. Add tastypie to the project INSTALLED_APPS and make sure you included lobbying.urls in your project’s urls.py.
From there visit 127.0.0.1:8000/browser/api/v1/filer/?format=json to explore the JSON representation of the data.
Export¶
You can also export the data into easily queryable flat files.
$ python manage.py export_lobbying
Update the data¶
When you are ready to get new data, just blow away both the parser and the campaign finance browser app. Then reload them.
You can do something like this, making sure you fill in your database and user names correctly. bash $ python manage.py sqlclear calaccess | mysql -u user_name -p database_name $ python manage.py sqlclear lobbying | mysql -u user_name -p database_name $ pytnon manage.py syncdb $ python manage.py downloadcalaccess && python manage.py build_lobbying