Skip to content

Commit

Permalink
Introduced an example app with some bootstrapping Make commands as an…
Browse files Browse the repository at this point in the history
… effort to get moving on palewire#27
  • Loading branch information
palewire committed Aug 6, 2014
1 parent 34e05bc commit 8c50072
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ data
docs/_build
.coverage
.tox
cover
example/data
example/settings_local.py
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.PHONY: db example runserver test

db:
mysqladmin -h localhost -u root -pmysql drop calaccess
mysqladmin -h localhost -u root -pmysql create calaccess

example:
python example/manage.py syncdb

runserver:
python example/manage.py runserver

test:
coverage run setup.py test
coverage report -m
3 changes: 2 additions & 1 deletion calaccess/management/commands/downloadcalaccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,12 @@ def set_options(self, *args, **kwargs):
data_dir = getattr(
settings,
'CALACCESS_DOWNLOAD_DIR',
os.path.join(settings.ROOT_DIR, 'data')
os.path.join(settings.BASE_DIR, 'data')
)

self.url = 'http://campaignfinance.cdn.sos.ca.gov/dbwebexport.zip'
self.data_dir = data_dir
os.path.exists(self.data_dir) or os.mkdir(self.data_dir)
self.zip_path = os.path.join(self.data_dir, 'calaccess.zip')
self.tsv_dir = os.path.join(self.data_dir, "tsv/")
self.csv_dir = os.path.join(self.data_dir, "csv/")
Expand Down
9 changes: 9 additions & 0 deletions example/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
Empty file added example/project/__init__.py
Empty file.
54 changes: 54 additions & 0 deletions example/project/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
SECRET_KEY = 'w11nbg_3n4+e@qk^b55qgo5qygesn^3=&s1kwtlbpkai$(1jv3'
DEBUG = False
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = []

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'calaccess',
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'project.urls'
WSGI_APPLICATION = 'project.wsgi.application'

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'calaccess',
'USER': 'root',
'PASSWORD': 'mysql',
'HOST': 'localhost',
'PORT': '3306',
'OPTIONS': {
'local_infile': 1,
}
}
}

LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'

try:
from settings_local import *
except ImportError:
pass
12 changes: 12 additions & 0 deletions example/project/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
# Examples:
# url(r'^$', 'example.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),

url(r'^admin/', include(admin.site.urls)),
)
14 changes: 14 additions & 0 deletions example/project/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
WSGI config for example project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/
"""

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
2 changes: 2 additions & 0 deletions requirements.txt → requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Django==1.6.5
Jinja2==2.7.3
MarkupSafe==0.23
PyYAML==3.10
Expand All @@ -21,3 +22,4 @@ tornado==3.1.1
tox==1.7.2
virtualenv==1.11.6
watchdog==0.6.0
wsgiref==0.1.2
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def run(self):
],
include_package_data=True,
license='MIT',
description='A simple Django app to download, extract and load the CAL-ACCESS campaign finance and lobbying activity database.',
description='A simple Django app to download, extract and load the \
CAL-ACCESS campaign finance and lobbying activity database.',
url='https://github.com/california-civic-data-coalition',
author='California Civic Data Coalition',
author_email='[email protected]',
Expand Down

0 comments on commit 8c50072

Please sign in to comment.