Skip to content

Commit

Permalink
Added very rough outline of an html view (citizen app).
Browse files Browse the repository at this point in the history
  • Loading branch information
onyxfish committed Aug 22, 2009
1 parent 99948de commit 986305d
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 16 deletions.
3 changes: 0 additions & 3 deletions api/models.py

This file was deleted.

5 changes: 5 additions & 0 deletions api/urls.py
@@ -0,0 +1,5 @@
from django.conf.urls.defaults import *

urlpatterns = patterns('',
url(r'^all', 'votersdaily_web.api.views.all', name='api_all'),
)
1 change: 1 addition & 0 deletions api/views.py
Expand Up @@ -27,6 +27,7 @@ def all(request):

result = json.dumps(document)


return HttpResponse(result, mimetype='application/json')
else:
raise NotImplementedError()
Expand Down
Empty file added citizen/__init__.py
Empty file.
27 changes: 27 additions & 0 deletions citizen/templates/all.html
@@ -0,0 +1,27 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>votersdaily_web.citizen.views.all</title>
</head>
<body>
<table>
<tbody>
{% for document in documents %}
<tr>
<td>{{ document.datetime }}</td>
<td>{{ document.title }}</td>
<td>{{ document.description }}</td>
<td>{{ document.end_datetime }}</td>
<td>{{ document.branch }}</td>
<td>{{ document.entity }}</td>
<td>{{ document.source_url }}</td>
<td>{{ document.source_text }}</td>
<td>{{ document.access_datetime }}</td>
<td>{{ document.parser_name }}</td>
<td>{{ document.parser_version }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</body>
</html>
40 changes: 40 additions & 0 deletions citizen/views.py
@@ -0,0 +1,40 @@
import json

import couchdb
from couchdb.schema import *
from django.http import HttpResponse, HttpResponseRedirect, Http404
from django.shortcuts import render_to_response

from votersdaily_web import settings

def get_event_db():
"""
Setup CouchDB. Encapsulated for clarity.
"""
server = couchdb.Server(settings.COUCHDB_SERVER_URI)
event_db = server[settings.COUCHDB_EVENTDB_NAME]

return event_db

def all(request):
event_db = get_event_db()

# JSON
#if request.accepts('application/json'):
# GET
if request.method == 'GET':
#doc_id = '2008-10-06T00:00:00Z - Judicial - Supreme Court - Order List'
#document = event_db[doc_id]

documents = []

for doc_id in event_db:
documents.append(event_db[doc_id])

return render_to_response('all.html', { 'documents': documents })
else:
raise NotImplementedError()
# HTML
#else:
# raise NotImplementedError()

1 change: 1 addition & 0 deletions settings.py
Expand Up @@ -64,6 +64,7 @@
ROOT_URLCONF = 'votersdaily_web.urls'

TEMPLATE_DIRS = (
'/home/sk/src/votersdaily_web/citizen/templates',
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
Expand Down
18 changes: 5 additions & 13 deletions urls.py
@@ -1,17 +1,9 @@
from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
# Example:
url(r'^all', 'api.views.all', name='all'),

# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
# (r'^admin/(.*)', admin.site.root),
# API
(r'^api/', include('votersdaily_web.api.urls')),

# Citizen
url(r'^all', 'votersdaily_web.citizen.views.all', name='all'),
)

0 comments on commit 986305d

Please sign in to comment.