Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Copy from svn repo.

  • Loading branch information...
commit 088c6984d28321781316ae0afad8b0c5af2b326d 0 parents
Usware Technologies authored
Showing with 1,683 additions and 0 deletions.
  1. 0  LICENSE
  2. +3 −0  README
  3. 0  __init__.py
  4. +28 −0 localsettings.py
  5. +11 −0 manage.py
  6. 0  pollngo/__init__.py
  7. +6 −0 pollngo/admin.py
  8. +52 −0 pollngo/models.py
  9. +29 −0 pollngo/pforms.py
  10. +714 −0 pollngo/pygooglechart.py
  11. +129 −0 pollngo/templates/pollngo/base.html
  12. +23 −0 pollngo/templates/pollngo/create.html
  13. +21 −0 pollngo/templates/pollngo/help.html
  14. +15 −0 pollngo/templates/pollngo/index.html
  15. +42 −0 pollngo/templates/pollngo/question.html
  16. +44 −0 pollngo/templates/pollngo/results.html
  17. +12 −0 pollngo/urls.py
  18. +99 −0 pollngo/views.py
  19. +58 −0 settings.py
  20. +352 −0 site_media/pollngo/default.css
  21. BIN  site_media/pollngo/images/a1.gif
  22. BIN  site_media/pollngo/images/a10.jpg
  23. BIN  site_media/pollngo/images/a16.gif
  24. BIN  site_media/pollngo/images/a18.gif
  25. BIN  site_media/pollngo/images/a22.gif
  26. BIN  site_media/pollngo/images/a26.gif
  27. BIN  site_media/pollngo/images/a33.gif
  28. BIN  site_media/pollngo/images/a36.gif
  29. BIN  site_media/pollngo/images/a38.gif
  30. BIN  site_media/pollngo/images/a41.gif
  31. BIN  site_media/pollngo/images/a47.gif
  32. BIN  site_media/pollngo/images/a50.gif
  33. BIN  site_media/pollngo/images/a8.gif
  34. BIN  site_media/pollngo/images/abg.gif
  35. BIN  site_media/pollngo/images/pic1.jpg
  36. BIN  site_media/pollngo/images/pic2.jpg
  37. BIN  site_media/pollngo/images/spacer.gif
  38. BIN  site_media/pollngo/images/upbg.gif
  39. +13 −0 templates/404.html
  40. +13 −0 templates/500.html
  41. +19 −0 urls.py
0  LICENSE
No changes.
3  README
@@ -0,0 +1,3 @@
+A pooling application built with Django.
+
+
0  __init__.py
No changes.
28 localsettings.py
@@ -0,0 +1,28 @@
+
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+
+
+DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
+DATABASE_NAME = 'data.db' # Or path to database file if using sqlite3.
+DATABASE_USER = '' # Not used with sqlite3.
+DATABASE_PASSWORD = '' # Not used with sqlite3.
+DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
+DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
+
+ROOT_URLCONF = 'polls.urls'
+
+TEMPLATE_DIRS = (
+ # 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.
+)
+
+# Absolute path to the directory that holds media.
+# Example: "/home/media/media.lawrence.com/"
+MEDIA_ROOT = '/home/shabda/uswaretech_svn/7days7apps/trunk/polls/site_media'
+
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
+# trailing slash if there is a path component (optional in other cases).
+# Examples: "http://media.lawrence.com", "http://example.com/media/"
+MEDIA_URL = '/site_media/'
11 manage.py
@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+from django.core.management import execute_manager
+try:
+ import settings # Assumed to be in the same directory.
+except ImportError:
+ import sys
+ sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
+ sys.exit(1)
+
+if __name__ == "__main__":
+ execute_manager(settings)
0  pollngo/__init__.py
No changes.
6 pollngo/admin.py
@@ -0,0 +1,6 @@
+from django.contrib import admin
+
+from pollngo.models import Question, Choice
+
+admin.site.register(Question)
+admin.site.register(Choice)
52 pollngo/models.py
@@ -0,0 +1,52 @@
+from django.db import models
+from django.contrib.auth.models import User
+
+class Question(models.Model):
+ """This class represents a question. It can have 2 or more options."""
+ created_on = models.DateTimeField(auto_now_add = 1)
+ title = models.SlugField(max_length = 200)
+ slug = models.SlugField(unique = True, max_length = 200)
+ text = models.TextField()
+ allow_multiple = models.BooleanField(default = False)
+
+ def save(self):
+ title = self.title.replace('?', '')
+ title = title.replace('.', '')
+ slug = '-'.join(title.split())
+ count = Question.objects.filter(slug__icontains = slug).count()
+ print count
+ if count:
+ slug = slug + str(count+1)
+ self.slug = slug
+ super(Question, self).save()
+
+ def __str__(self):
+ return self.title
+
+ @models.permalink
+ def get_absolute_url(self):
+ return ('pollngo.views.question', [self.slug])
+
+ @models.permalink
+ def get_results_url(self):
+ return ('pollngo.views.results', [self.slug])
+
+ class Admin:
+ pass
+
+ class Meta:
+ ordering = ('-created_on', )
+
+
+class Choice(models.Model):
+ """This represents an answer to the Question, and has a foreignkey to it"""
+ question = models.ForeignKey(Question)
+ text = models.TextField()
+ total_votes = models.IntegerField(default = 0)
+
+ def __str__(self):
+ return '%s - %s' % (self.question.title, self.text)
+
+ class Admin:
+ pass
+
29 pollngo/pforms.py
@@ -0,0 +1,29 @@
+from django import forms
+import models
+
+class CreatePoll(forms.Form):
+ question_title = forms.CharField(widget = forms.TextInput(attrs = {'class':'required', 'size':50}), help_text = 'Title for your poll. This is required.')
+ question_text = forms.CharField(widget = forms.Textarea, help_text = 'Some description. This is required.')
+ choice_1 = forms.CharField(widget = forms.TextInput(attrs = {'class':'required', 'size':50}), help_text = 'Allowed choices for the poll. At least two are required.')
+ choice_2 = forms.CharField(widget = forms.TextInput(attrs = {'class':'required', 'size':50}))
+ choice_3 = forms.CharField(required = False, widget = forms.TextInput(attrs = {'size':50}))
+ choice_4 = forms.CharField(required = False, widget = forms.TextInput(attrs = {'size':50}))
+ choice_5 = forms.CharField(required = False, widget = forms.TextInput(attrs = {'size':50}))
+ choice_6 = forms.CharField(required = False, widget = forms.TextInput(attrs = {'size':50}))
+ choice_7 = forms.CharField(required = False, widget = forms.TextInput(attrs = {'size':50}))
+ choice_8 = forms.CharField(required = False, widget = forms.TextInput(attrs = {'size':50}))
+
+ def __init__(self, request, *args, **kwargs):
+ self.request = request
+ super(forms.Form, self).__init__(*args, **kwargs)
+
+ def save(self):
+ question = models.Question(title = self.cleaned_data['question_title'], text = self.cleaned_data['question_text'])
+ question.save()
+ for field in self.fields:
+ if field in ['question_title','question_text']:
+ continue
+ if self.cleaned_data[field]:
+ choice = models.Choice(question = question, text = self.cleaned_data[field])
+ choice.save()
+ return question
714 pollngo/pygooglechart.py
@@ -0,0 +1,714 @@
+"""
+PyGoogleChart - A complete Python wrapper for the Google Chart API
+
+http://pygooglechart.slowchop.com/
+
+Copyright 2007 Gerald Kaszuba
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+
+import os
+import urllib
+import urllib2
+import math
+import random
+import re
+
+# Helper variables and functions
+# -----------------------------------------------------------------------------
+
+__version__ = '0.1.2'
+
+reo_colour = re.compile('^([A-Fa-f0-9]{2,2}){3,4}$')
+
+
+def _check_colour(colour):
+ if not reo_colour.match(colour):
+ raise InvalidParametersException('Colours need to be in ' \
+ 'RRGGBB or RRGGBBAA format. One of your colours has %s' % \
+ colour)
+
+# Exception Classes
+# -----------------------------------------------------------------------------
+
+
+class PyGoogleChartException(Exception):
+ pass
+
+
+class DataOutOfRangeException(PyGoogleChartException):
+ pass
+
+
+class UnknownDataTypeException(PyGoogleChartException):
+ pass
+
+
+class NoDataGivenException(PyGoogleChartException):
+ pass
+
+
+class InvalidParametersException(PyGoogleChartException):
+ pass
+
+
+class BadContentTypeException(PyGoogleChartException):
+ pass
+
+
+# Data Classes
+# -----------------------------------------------------------------------------
+
+
+class Data(object):
+
+ def __init__(self, data):
+ assert(type(self) != Data) # This is an abstract class
+ self.data = data
+
+
+class SimpleData(Data):
+ enc_map = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
+
+ def __repr__(self):
+ encoded_data = []
+ for data in self.data:
+ sub_data = []
+ for value in data:
+ if value is None:
+ sub_data.append('_')
+ elif value >= 0 and value <= SimpleData.max_value:
+ sub_data.append(SimpleData.enc_map[value])
+ else:
+ raise DataOutOfRangeException()
+ encoded_data.append(''.join(sub_data))
+ return 'chd=s:' + ','.join(encoded_data)
+
+ @staticmethod
+ def max_value():
+ return 61
+
+
+class TextData(Data):
+
+ def __repr__(self):
+ encoded_data = []
+ for data in self.data:
+ sub_data = []
+ for value in data:
+ if value is None:
+ sub_data.append(-1)
+ elif value >= 0 and value <= TextData.max_value:
+ sub_data.append(str(float(value)))
+ else:
+ raise DataOutOfRangeException()
+ encoded_data.append(','.join(sub_data))
+ return 'chd=t:' + '|'.join(encoded_data)
+
+ @staticmethod
+ def max_value():
+ return 100
+
+
+class ExtendedData(Data):
+ enc_map = \
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.'
+
+ def __repr__(self):
+ encoded_data = []
+ enc_size = len(ExtendedData.enc_map)
+ for data in self.data:
+ sub_data = []
+ for value in data:
+ if value is None:
+ sub_data.append('__')
+ elif value >= 0 and value <= ExtendedData.max_value:
+ first, second = divmod(int(value), enc_size)
+ sub_data.append('%s%s' % (
+ ExtendedData.enc_map[first],
+ ExtendedData.enc_map[second]))
+ else:
+ raise DataOutOfRangeException( \
+ 'Item #%i "%s" is out of range' % (data.index(value), \
+ value))
+ encoded_data.append(''.join(sub_data))
+ return 'chd=e:' + ','.join(encoded_data)
+
+ @staticmethod
+ def max_value():
+ return 4095
+
+# Axis Classes
+# -----------------------------------------------------------------------------
+
+
+class Axis(object):
+ BOTTOM = 'x'
+ TOP = 't'
+ LEFT = 'y'
+ RIGHT = 'r'
+ TYPES = (BOTTOM, TOP, LEFT, RIGHT)
+
+ def __init__(self, axis_index, axis_type, **kw):
+ assert(axis_type in Axis.TYPES)
+ self.has_style = False
+ self.axis_index = axis_index
+ self.axis_type = axis_type
+ self.positions = None
+
+ def set_index(self, axis_index):
+ self.axis_index = axis_index
+
+ def set_positions(self, positions):
+ self.positions = positions
+
+ def set_style(self, colour, font_size=None, alignment=None):
+ _check_colour(colour)
+ self.colour = colour
+ self.font_size = font_size
+ self.alignment = alignment
+ self.has_style = True
+
+ def style_to_url(self):
+ bits = []
+ bits.append(str(self.axis_index))
+ bits.append(self.colour)
+ if self.font_size is not None:
+ bits.append(str(self.font_size))
+ if self.alignment is not None:
+ bits.append(str(self.alignment))
+ return ','.join(bits)
+
+ def positions_to_url(self):
+ bits = []
+ bits.append(str(self.axis_index))
+ bits += [str(a) for a in self.positions]
+ return ','.join(bits)
+
+
+class LabelAxis(Axis):
+
+ def __init__(self, axis_index, axis_type, values, **kwargs):
+ Axis.__init__(self, axis_index, axis_type, **kwargs)
+ self.values = [str(a) for a in values]
+
+ def __repr__(self):
+ return '%i:|%s' % (self.axis_index, '|'.join(self.values))
+
+
+class RangeAxis(Axis):
+
+ def __init__(self, axis_index, axis_type, low, high, **kwargs):
+ Axis.__init__(self, axis_index, axis_type, **kwargs)
+ self.low = low
+ self.high = high
+
+ def __repr__(self):
+ return '%i,%s,%s' % (self.axis_index, self.low, self.high)
+
+# Chart Classes
+# -----------------------------------------------------------------------------
+
+
+class Chart(object):
+ """Abstract class for all chart types.
+
+ width are height specify the dimensions of the image. title sets the title
+ of the chart. legend requires a list that corresponds to datasets.
+ """
+
+ BASE_URL = 'http://chart.apis.google.com/chart?'
+ BACKGROUND = 'bg'
+ CHART = 'c'
+ SOLID = 's'
+ LINEAR_GRADIENT = 'lg'
+ LINEAR_STRIPES = 'ls'
+
+ def __init__(self, width, height, title=None, legend=None, colours=None):
+ assert(type(self) != Chart) # This is an abstract class
+ assert(isinstance(width, int))
+ assert(isinstance(height, int))
+ self.width = width
+ self.height = height
+ self.data = []
+ self.set_title(title)
+ self.set_legend(legend)
+ self.set_colours(colours)
+ self.fill_types = {
+ Chart.BACKGROUND: None,
+ Chart.CHART: None,
+ }
+ self.fill_area = {
+ Chart.BACKGROUND: None,
+ Chart.CHART: None,
+ }
+# self.axis = {
+# Axis.TOP: None,
+# Axis.BOTTOM: None,
+# Axis.LEFT: None,
+# Axis.RIGHT: None,
+# }
+ self.axis = []
+ self.markers = []
+
+ # URL generation
+ # -------------------------------------------------------------------------
+
+ def get_url(self):
+ url_bits = self.get_url_bits()
+ return self.BASE_URL + '&'.join(url_bits)
+
+ def get_url_bits(self):
+ url_bits = []
+ # required arguments
+ url_bits.append(self.type_to_url())
+ url_bits.append('chs=%ix%i' % (self.width, self.height))
+ url_bits.append(self.data_to_url())
+ # optional arguments
+ if self.title:
+ url_bits.append('chtt=%s' % self.title)
+ if self.legend:
+ url_bits.append('chdl=%s' % '|'.join(self.legend))
+ if self.colours:
+ url_bits.append('chco=%s' % ','.join(self.colours))
+ ret = self.fill_to_url()
+ if ret:
+ url_bits.append(ret)
+ ret = self.axis_to_url()
+ if ret:
+ url_bits.append(ret)
+ if self.markers:
+ url_bits.append(self.markers_to_url())
+ return url_bits
+
+ # Downloading
+ # -------------------------------------------------------------------------
+
+ def download(self, file_name):
+ opener = urllib2.urlopen(self.get_url())
+
+ if opener.headers['content-type'] != 'image/png':
+ raise BadContentTypeException('Server responded with a ' \
+ 'content-type of %s' % opener.headers['content-type'])
+
+ open(file_name, 'wb').write(urllib.urlopen(self.get_url()).read())
+
+ # Simple settings
+ # -------------------------------------------------------------------------
+
+ def set_title(self, title):
+ if title:
+ self.title = urllib.quote(title)
+ else:
+ self.title = None
+
+ def set_legend(self, legend):
+ # legend needs to be a list, tuple or None
+ assert(isinstance(legend, list) or isinstance(legend, tuple) or
+ legend is None)
+ if legend:
+ self.legend = [urllib.quote(a) for a in legend]
+ else:
+ self.legend = None
+
+ # Chart colours
+ # -------------------------------------------------------------------------
+
+ def set_colours(self, colours):
+ # colours needs to be a list, tuple or None
+ assert(isinstance(colours, list) or isinstance(colours, tuple) or
+ colours is None)
+ # make sure the colours are in the right format
+ if colours:
+ for col in colours:
+ _check_colour(col)
+ self.colours = colours
+
+ # Background/Chart colours
+ # -------------------------------------------------------------------------
+
+ def fill_solid(self, area, colour):
+ assert(area in (Chart.BACKGROUND, Chart.CHART))
+ _check_colour(colour)
+ self.fill_area[area] = colour
+ self.fill_types[area] = Chart.SOLID
+
+ def _check_fill_linear(self, angle, *args):
+ assert(isinstance(args, list) or isinstance(args, tuple))
+ assert(angle >= 0 and angle <= 90)
+ assert(len(args) % 2 == 0)
+ args = list(args) # args is probably a tuple and we need to mutate
+ for a in xrange(len(args) / 2):
+ col = args[a * 2]
+ offset = args[a * 2 + 1]
+ _check_colour(col)
+ assert(offset >= 0 and offset <= 1)
+ args[a * 2 + 1] = str(args[a * 2 + 1])
+ return args
+
+ def fill_linear_gradient(self, area, angle, *args):
+ assert(area in (Chart.BACKGROUND, Chart.CHART))
+ args = self._check_fill_linear(angle, *args)
+ self.fill_types[area] = Chart.LINEAR_GRADIENT
+ self.fill_area[area] = ','.join([str(angle)] + args)
+
+ def fill_linear_stripes(self, area, angle, *args):
+ assert(area in (Chart.BACKGROUND, Chart.CHART))
+ args = self._check_fill_linear(angle, *args)
+ self.fill_types[area] = Chart.LINEAR_STRIPES
+ self.fill_area[area] = ','.join([str(angle)] + args)
+
+ def fill_to_url(self):
+ areas = []
+ for area in (Chart.BACKGROUND, Chart.CHART):
+ if self.fill_types[area]:
+ areas.append('%s,%s,%s' % (area, self.fill_types[area], \
+ self.fill_area[area]))
+ if areas:
+ return 'chf=' + '|'.join(areas)
+
+ # Data
+ # -------------------------------------------------------------------------
+
+ def data_class_detection(self, data):
+ """
+ Detects and returns the data type required based on the range of the
+ data given. The data given must be lists of numbers within a list.
+ """
+ assert(isinstance(data, list) or isinstance(data, tuple))
+ max_value = None
+ for a in data:
+ assert(isinstance(a, list) or isinstance(a, tuple))
+ if max_value is None or max(a) > max_value:
+ max_value = max(a)
+ for data_class in (SimpleData, TextData, ExtendedData):
+ if max_value <= data_class.max_value():
+ return data_class
+ raise DataOutOfRangeException()
+
+ def add_data(self, data):
+ self.data.append(data)
+ return len(self.data) - 1 # return the "index" of the data set
+
+ def data_to_url(self, data_class=None):
+ if not data_class:
+ data_class = self.data_class_detection(self.data)
+ if not issubclass(data_class, Data):
+ raise UnknownDataTypeException()
+ return repr(data_class(self.data))
+
+ # Axis Labels
+ # -------------------------------------------------------------------------
+
+ def set_axis_labels(self, axis_type, values):
+ assert(axis_type in Axis.TYPES)
+ values = [ urllib.quote(a) for a in values ]
+ axis_index = len(self.axis)
+ axis = LabelAxis(axis_index, axis_type, values)
+ self.axis.append(axis)
+ return axis_index
+
+ def set_axis_range(self, axis_type, low, high):
+ assert(axis_type in Axis.TYPES)
+ axis_index = len(self.axis)
+ axis = RangeAxis(axis_index, axis_type, low, high)
+ self.axis.append(axis)
+ return axis_index
+
+ def set_axis_positions(self, axis_index, positions):
+ try:
+ self.axis[axis_index].set_positions(positions)
+ except IndexError:
+ raise InvalidParametersException('Axis index %i has not been ' \
+ 'created' % axis)
+
+ def set_axis_style(self, axis_index, colour, font_size=None, \
+ alignment=None):
+ try:
+ self.axis[axis_index].set_style(colour, font_size, alignment)
+ except IndexError:
+ raise InvalidParametersException('Axis index %i has not been ' \
+ 'created' % axis)
+
+ def axis_to_url(self):
+ available_axis = []
+ label_axis = []
+ range_axis = []
+ positions = []
+ styles = []
+ index = -1
+ for axis in self.axis:
+ available_axis.append(axis.axis_type)
+ if isinstance(axis, RangeAxis):
+ range_axis.append(repr(axis))
+ if isinstance(axis, LabelAxis):
+ label_axis.append(repr(axis))
+ if axis.positions:
+ positions.append(axis.positions_to_url())
+ if axis.has_style:
+ styles.append(axis.style_to_url())
+ if not available_axis:
+ return
+ url_bits = []
+ url_bits.append('chxt=%s' % ','.join(available_axis))
+ if label_axis:
+ url_bits.append('chxl=%s' % '|'.join(label_axis))
+ if range_axis:
+ url_bits.append('chxr=%s' % '|'.join(range_axis))
+ if positions:
+ url_bits.append('chxp=%s' % '|'.join(positions))
+ if styles:
+ url_bits.append('chxs=%s' % '|'.join(styles))
+ return '&'.join(url_bits)
+
+ # Markers, Ranges and Fill area (chm)
+ # -------------------------------------------------------------------------
+
+ def markers_to_url(self):
+ return 'chm=%s' % '|'.join([','.join(a) for a in self.markers])
+
+ def add_marker(self, index, point, marker_type, colour, size):
+ self.markers.append((marker_type, colour, str(index), str(point), \
+ str(size)))
+
+ def add_horizontal_range(self, colour, start, stop):
+ self.markers.append(('r', colour, '1', str(start), str(stop)))
+
+ def add_vertical_range(self, colour, start, stop):
+ self.markers.append(('R', colour, '1', str(start), str(stop)))
+
+ def add_fill_range(self, colour, index_start, index_end):
+ self.markers.append(('b', colour, str(index_start), str(index_end), \
+ '1'))
+
+ def add_fill_simple(self, colour):
+ self.markers.append(('B', colour, '1', '1', '1'))
+
+
+class ScatterChart(Chart):
+
+ def __init__(self, *args, **kwargs):
+ Chart.__init__(self, *args, **kwargs)
+
+ def type_to_url(self):
+ return 'cht=s'
+
+
+class LineChart(Chart):
+
+ def __init__(self, *args, **kwargs):
+ assert(type(self) != LineChart) # This is an abstract class
+ Chart.__init__(self, *args, **kwargs)
+ self.line_styles = {}
+ self.grid = None
+
+ def set_line_style(self, index, thickness=1, line_segment=None, \
+ blank_segment=None):
+ value = []
+ value.append(str(thickness))
+ if line_segment:
+ value.append(str(line_segment))
+ value.append(str(blank_segment))
+ self.line_styles[index] = value
+
+ def set_grid(self, x_step, y_step, line_segment=1, \
+ blank_segment=0):
+ self.grid = '%s,%s,%s,%s' % (x_step, y_step, line_segment, \
+ blank_segment)
+
+ def get_url_bits(self):
+ url_bits = Chart.get_url_bits(self)
+ if self.line_styles:
+ style = []
+ # for index, values in self.line_style.items():
+ for index in xrange(max(self.line_styles) + 1):
+ if index in self.line_styles:
+ values = self.line_styles[index]
+ else:
+ values = ('1', )
+ style.append(','.join(values))
+ url_bits.append('chls=%s' % '|'.join(style))
+ if self.grid:
+ url_bits.append('chg=%s' % self.grid)
+ return url_bits
+
+
+class SimpleLineChart(LineChart):
+
+ def type_to_url(self):
+ return 'cht=lc'
+
+
+class XYLineChart(LineChart):
+
+ def type_to_url(self):
+ return 'cht=lxy'
+
+
+class BarChart(Chart):
+
+ def __init__(self, *args, **kwargs):
+ assert(type(self) != BarChart) # This is an abstract class
+ Chart.__init__(self, *args, **kwargs)
+ self.bar_width = None
+
+ def set_bar_width(self, bar_width):
+ self.bar_width = bar_width
+
+ def get_url_bits(self):
+ url_bits = Chart.get_url_bits(self)
+ url_bits.append('chbh=%i' % self.bar_width)
+ return url_bits
+
+
+class StackedHorizontalBarChart(BarChart):
+
+ def type_to_url(self):
+ return 'cht=bhs'
+
+
+class StackedVerticalBarChart(BarChart):
+
+ def type_to_url(self):
+ return 'cht=bvs'
+
+
+class GroupedBarChart(BarChart):
+
+ def __init__(self, *args, **kwargs):
+ assert(type(self) != GroupedBarChart) # This is an abstract class
+ BarChart.__init__(self, *args, **kwargs)
+ self.bar_spacing = None
+
+ def set_bar_spacing(self, spacing):
+ self.bar_spacing = spacing
+
+ def get_url_bits(self):
+ # Skip 'BarChart.get_url_bits' and call Chart directly so the parent
+ # doesn't add "chbh" before we do.
+ url_bits = Chart.get_url_bits(self)
+ if self.bar_spacing is not None:
+ if self.bar_width is None:
+ raise InvalidParametersException('Bar width is required to ' \
+ 'be set when setting spacing')
+ url_bits.append('chbh=%i,%i' % (self.bar_width, self.bar_spacing))
+ else:
+ url_bits.append('chbh=%i' % self.bar_width)
+ return url_bits
+
+
+class GroupedHorizontalBarChart(GroupedBarChart):
+
+ def type_to_url(self):
+ return 'cht=bhg'
+
+
+class GroupedVerticalBarChart(GroupedBarChart):
+
+ def type_to_url(self):
+ return 'cht=bvg'
+
+
+class PieChart(Chart):
+
+ def __init__(self, *args, **kwargs):
+ assert(type(self) != PieChart) # This is an abstract class
+ Chart.__init__(self, *args, **kwargs)
+ self.pie_labels = []
+
+ def set_pie_labels(self, labels):
+ self.pie_labels = [urllib.quote(a) for a in labels]
+
+ def get_url_bits(self):
+ url_bits = Chart.get_url_bits(self)
+ if self.pie_labels:
+ url_bits.append('chl=%s' % '|'.join(self.pie_labels))
+ return url_bits
+
+
+class PieChart2D(PieChart):
+
+ def type_to_url(self):
+ return 'cht=p'
+
+
+class PieChart3D(PieChart):
+
+ def type_to_url(self):
+ return 'cht=p3'
+
+
+class VennChart(Chart):
+
+ def type_to_url(self):
+ return 'cht=v'
+
+
+def test():
+ chart = GroupedVerticalBarChart(320, 200)
+ chart = PieChart2D(320, 200)
+ chart = ScatterChart(320, 200)
+ chart = SimpleLineChart(320, 200)
+ sine_data = [math.sin(float(a) / 10) * 2000 + 2000 for a in xrange(100)]
+ random_data = [a * random.random() * 30 for a in xrange(40)]
+ random_data2 = [random.random() * 4000 for a in xrange(10)]
+# chart.set_bar_width(50)
+# chart.set_bar_spacing(0)
+ chart.add_data(sine_data)
+ chart.add_data(random_data)
+ chart.add_data(random_data2)
+# chart.set_line_style(1, thickness=2)
+# chart.set_line_style(2, line_segment=10, blank_segment=5)
+# chart.set_title('heloooo')
+# chart.set_legend(('sine wave', 'random * x'))
+# chart.set_colours(('ee2000', 'DDDDAA', 'fF03f2'))
+# chart.fill_solid(Chart.BACKGROUND, '123456')
+# chart.fill_linear_gradient(Chart.CHART, 20, '004070', 1, '300040', 0,
+# 'aabbcc00', 0.5)
+# chart.fill_linear_stripes(Chart.CHART, 20, '204070', .2, '300040', .2,
+# 'aabbcc00', 0.2)
+ axis_left_index = chart.set_axis_range(Axis.LEFT, 0, 10)
+ axis_left_index = chart.set_axis_range(Axis.LEFT, 0, 10)
+ axis_left_index = chart.set_axis_range(Axis.LEFT, 0, 10)
+ axis_right_index = chart.set_axis_range(Axis.RIGHT, 5, 30)
+ axis_bottom_index = chart.set_axis_labels(Axis.BOTTOM, [1, 25, 95])
+ chart.set_axis_positions(axis_bottom_index, [1, 25, 95])
+ chart.set_axis_style(axis_bottom_index, '003050', 15)
+
+# chart.set_pie_labels(('apples', 'oranges', 'bananas'))
+
+# chart.set_grid(10, 10)
+
+# for a in xrange(0, 100, 10):
+# chart.add_marker(1, a, 'a', 'AACA20', 10)
+
+ chart.add_horizontal_range('00A020', .2, .5)
+ chart.add_vertical_range('00c030', .2, .4)
+
+ chart.add_fill_simple('303030A0')
+
+ chart.download('test.png')
+
+ url = chart.get_url()
+ print url
+ if 0:
+ data = urllib.urlopen(chart.get_url()).read()
+ open('meh.png', 'wb').write(data)
+ os.system('start meh.png')
+
+
+if __name__ == '__main__':
+ test()
129 pollngo/templates/pollngo/base.html
@@ -0,0 +1,129 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
+<title>
+ {% block title %}
+ Pollngo - Wat's your opinion?
+ {% endblock %}
+</title>
+<meta name="keywords" content="" />
+<meta name="description" content="" />
+<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}pollngo/default.css" />
+</head>
+<body>
+
+<div id="outer">
+
+ <div id="upbg"></div>
+
+ <div id="inner">
+
+ <div id="header">
+ {% block header %}
+ <h1><span>Poll</span>ngo</h1>
+ <h2>Wat's your opinion?</h2>
+ {% endblock %}
+
+ </div>
+
+ <div id="splash"></div>
+
+
+ <div id="menu">
+ {% block menu %}
+ <ul>
+
+ <li><a href="{% url pollngo_index %}">Home</a></li>
+ <li><a href="{% url pollngo_create %}">Create</a></li>
+ <li><a href="{% url pollngo_help %}">About</a></li>
+
+ </ul>
+ {% endblock %}
+
+ </div>
+
+
+ <div id="primarycontent">
+
+ <!-- primary content start -->
+ {% block content %}
+ <div class="post">
+ <div class="header">
+ <h3>TerraFirma<sup>1.0</sup> by NodeThirtyThree</h3>
+
+ <div class="date">August 1, 2006</div>
+ <div class="extrainfo">August 1, 2006</div>
+ </div>
+ <div class="content">
+ <img src="images/pic1.jpg" class="picA floatleft" alt="" />
+ <p><strong>TerraFirma</strong><sup>1.0</sup> is a free, lightweight, tableless, W3C-compliant website design by <a href="http://www.nodethirtythree.com/">NodeThirtyThree Design</a>. You're free to dissect, manipulate and use it to your heart's content. We only ask that you link back to our site in some way. If you find this design useful, feel free to let us know :)</p>
+
+ <p>You can find more of our free work at this site or <a href="http://www.nodethirtythree.com/">our site</a>, or some of our commercial work on <a href="http://www.4templates.com/?aff=n33">4Templates.com</a>, a commercial website template site.</p>
+ </div>
+ <div class="footer">
+ <ul>
+ <li class="printerfriendly"><a href="#">Printer Friendly</a></li>
+ <li class="comments"><a href="#">Comments (18)</a></li>
+
+ <li class="readmore"><a href="#">Read more</a></li>
+ </ul>
+ </div>
+ </div>
+ {% endblock %}
+
+
+
+ <!-- primary content end -->
+
+ </div>
+
+ <div id="secondarycontent">
+
+ <!-- secondary content start -->
+ {% block sitewidenav %}
+ <h3>About Pollngo</h3>
+ <div class="content">
+
+
+ <p><strong>Pollngo</strong> allows you to create polls and check results for them. No registration is necessary to either create or vote on the results. You just Poll n go. It is built with Django and is part of the <a href="http://www.7days7apps.com">7 days 7 apps project</a></p>
+ </div>
+ {% endblock %}
+
+ {% block contextnav %}
+ <h3>Recent polls</h3>
+ <div class="content">
+ <ul class="linklist">
+ {% for poll in recent_polls %}
+ <li class="first"><a href="{{poll.get_absolute_url}}">{{poll.title}}</a></li>
+ {% endfor %}
+
+ </ul>
+ </div>
+ <h3>Your Polls</h3>
+ <div class="content">
+ <ul class="linklist">
+ {% for poll in your_polls %}
+ <li class="first"><a href="{{poll.get_absolute_url}}">{{poll.title}}</a></li>
+ {% endfor %}
+
+ </ul>
+ </div>
+ {% endblock %}
+ <!-- secondary content end -->
+
+ </div>
+
+ <div id="footer">
+ {% block footer %}
+ <a href="/help/">About</a> | <a href="http://www.7days7apps.com/">7days7apps.com</a> | Design by <a href="http://www.nodethirtythree.com/">NodeThirtyThree</a>.
+ {% endblock %}
+
+ </div>
+
+ </div>
+
+</div>
+
+</body>
+</html>
23 pollngo/templates/pollngo/create.html
@@ -0,0 +1,23 @@
+{% extends 'pollngo/base.html' %}
+
+{% block title %}
+{{block.super}} - Create
+{% endblock %}
+
+
+{% block content %}
+ <div class="post">
+ <div class="header">
+ <h3>Create</h3>
+
+ </div>
+ <div class="content">
+ <form action="." method="post">
+ <table>
+ {{form}}
+ </table>
+ <input type="submit" value="Create Poll" name="submit">
+ </form>
+ </div>
+ </div>
+{% endblock %}
21 pollngo/templates/pollngo/help.html
@@ -0,0 +1,21 @@
+{% extends 'pollngo/base.html' %}
+
+{% block content %}
+ <div class="post">
+ <div class="header">
+ <h3>Pollngo</h3>
+ </div>
+ <p>
+ Pollngo is a simple polling application for Django. It was built for <a href="http://www.7days7apps.com">7days7apps.com</a>I know, I know, they teach building a polling ap in django tutorial. It is saturday here people! Cut me some slack!
+ </p>
+ <p>
+ Special features
+ <ul>
+ <li> Web 2.0 name. Dkango-Pollango, poll n go. See.</li>
+ <li> Chart, created using Google chart API</li>
+ <li> Did I tell you about our web 2.0 name</li>
+ </ul>
+ </p>
+
+ </div>
+{% endblock %}
15 pollngo/templates/pollngo/index.html
@@ -0,0 +1,15 @@
+{% extends 'pollngo/base.html' %}
+
+{% block content %}
+ <div class="post">
+ <div class="header">
+ <h3>Pollngo</h3>
+ </div>
+ <p>
+ Pollngo is a super simple polliing system. You create a poll and can link to that poll from any place. Anyone can reply to your polls. <em>No registartion necessary</em>
+ </p>
+ <p>
+ So we call it Poll n go! What are you waiting for? <a href="{% url pollngo_create %}">Create a poll.</a>
+ </p>
+ </div>
+{% endblock %}
42 pollngo/templates/pollngo/question.html
@@ -0,0 +1,42 @@
+{% extends 'pollngo/base.html' %}
+
+{% block title %}
+{{block.super}} - {{question.title}}
+{% endblock %}
+
+{% block content %}
+ <div class="post">
+ <div class="header">
+ <h3>{{question.title}}</h3>
+ <h4>{{question.text}}</h4>
+
+ <div class="date">Asked on {{question.created_on|date}}</div>
+ </div>
+ <div class="content">
+ {% if last_choice %}
+ <p>Your last choice was <strong>{{last_choice.text}}</strong>.<br />
+ Would you like to modify it?
+ </p>
+ {% endif %}
+ <p>
+ <form action="." method="post">
+ <ul>
+ {% for choice in choices %}
+ <li>
+ <h4>{{choice.text}}</h4>
+ <input type="RADIO" name="choices" value="{{choice.id}}" />
+
+ </li>
+ {% endfor %}
+ <input type="submit" value="Answer Poll" name="submit" />
+ </form>
+
+
+ </ul>
+ </p>
+ <p>
+ <a href="{{ question.get_results_url }}">See results.</a>
+ </p>
+ </div>
+ </div>
+{% endblock %}
44 pollngo/templates/pollngo/results.html
@@ -0,0 +1,44 @@
+{% extends 'pollngo/base.html' %}
+
+{% block title %}
+{{block.super}} - {{question.title}} - results
+{% endblock %}
+
+
+{% block content %}
+ <div class="post">
+ <div class="header">
+ <h3>{{question.title}}</h3>
+ <h4>{{question.text}}</h4>
+
+ <div class="date">Asked on {{question.created_on|date}}</div>
+ </div>
+ <div class="content">
+ <p>
+ Total votes cast: {{total_votes}}
+ </p>
+ <p>
+ <h4>Choices</h4>
+ <ul>
+ {% for choice in question.choice_set.all %}
+ <li>
+ <h4>{{choice.text}}</h4>
+ {{choice.total_votes}}
+
+ </li>
+ {% endfor %}
+
+
+ </ul>
+ </p>
+ {% if total_votes %}
+ <p>
+ <img src={{chart_url}} />
+ </p>
+ {% endif %}
+ <p>
+ <a href="{{ question.get_absolute_url }}">Back to the poll.</a>
+ </p>
+ </div>
+ </div>
+{% endblock %}
12 pollngo/urls.py
@@ -0,0 +1,12 @@
+from django.conf.urls.defaults import *
+from django.views.generic.simple import direct_to_template
+
+
+
+urlpatterns = patterns('pollngo.views',
+ url(r'^$', 'index', name='pollngo_index'),
+ url(r'^poll/(?P<slug>[^\.^/]+)/$', 'question', name='pollngo_question'),
+ url(r'^create/$', 'create', name='pollngo_create'),
+ url(r'^help/$', 'help', name='pollngo_help'),
+ url(r'^results/(?P<slug>[^\.^/]+)/$', 'results', name='pollngo_results'),
+ )
99 pollngo/views.py
@@ -0,0 +1,99 @@
+from django.shortcuts import render_to_response
+from django.http import HttpResponse, HttpResponseRedirect
+from django.template import RequestContext
+from django.http import Http404
+from django.core.exceptions import ObjectDoesNotExist
+
+from models import *
+import pforms
+from pygooglechart import PieChart2D
+
+def index(request):
+ return render('pollngo/index.html', {}, request)
+
+def question(request, slug):
+ try:
+ question = Question.objects.get(slug = slug)
+ except ObjectDoesNotExist, e:
+ raise Http404
+ if request.method == 'POST':
+ try:
+ last_choice_id = request.session[question.id]
+ last_choice = Choice.objects.get(id = last_choice_id)
+ last_choice.total_votes -= 1
+ last_choice.save()
+ except KeyError, e:
+ pass
+ choice_id = int(request.POST['choices'])
+ choice = Choice.objects.get(id = choice_id)
+ choice.total_votes += 1
+ choice.save()
+ request.session[question.id] = choice.id
+ return HttpResponseRedirect(question.get_results_url())
+ if request.method == 'GET':
+ try:
+ last_choice_id = request.session[question.id]
+ last_choice = Choice.objects.get(id = last_choice_id)
+ except KeyError, e:
+ last_choice = 0
+ choices = Choice.objects.filter(question = question)
+ payload = {'question':question, 'choices':choices, 'last_choice':last_choice}
+
+ return render('pollngo/question.html', payload, request)
+
+def results(request, slug):
+ try:
+ question = Question.objects.get(slug = slug)
+ except ObjectDoesNotExist, e:
+ raise Http404
+ total_votes = 0
+ choice_name = []
+ choice_val = []
+ for choice in question.choice_set.all():
+ total_votes += choice.total_votes
+ choice_name.append(choice.text)
+ choice_val.append(choice.total_votes)
+ chart = PieChart2D(400, 200)
+ chart.add_data(choice_val)
+ choice_name = [choice_obj.encode('utf8') for choice_obj in choice_name]
+ chart.set_pie_labels(choice_name)
+ chart_url = chart.get_url()
+ payload = {'question':question, 'total_votes':total_votes, 'chart_url':chart_url}
+ return render('pollngo/results.html', payload, request)
+
+
+
+def create(request):
+ if request.method == 'POST':
+ form = pforms.CreatePoll(request, request.POST)
+ if form.is_valid():
+ question = form.save()
+ try:
+ questions = request.session['questions']
+ except KeyError, e:
+ questions = []
+ questions.append(question.id)
+ request.session['questions'] = questions
+ return HttpResponseRedirect(question.get_absolute_url())
+ elif request.method == 'GET':
+ form = pforms.CreatePoll(request)
+ payload = {'form':form}
+ return render('pollngo/create.html', payload, request)
+
+def help(request):
+ payload = {}
+ return render('pollngo/help.html', payload, request)
+
+#Helper methods.
+def render(template_name, payload, request):
+ recent_polls = Question.objects.all()[:8]
+ try:
+ questions = request.session['questions']
+ except KeyError, e:
+ questions = []
+ your_polls = Question.objects.filter(id__in = questions)
+ payload.update({'recent_polls':recent_polls, 'your_polls':your_polls})
+ return render_to_response(template_name, payload, RequestContext(request))
+
+
+
58 settings.py
@@ -0,0 +1,58 @@
+from localsettings import *
+
+ADMINS = (
+ # ('Your Name', 'your_email@domain.com'),
+)
+
+MANAGERS = ADMINS
+
+# Local time zone for this installation. Choices can be found here:
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+# although not all choices may be avilable on all operating systems.
+# If running in a Windows environment this must be set to the same as your
+# system time zone.
+TIME_ZONE = 'America/Chicago'
+
+# Language code for this installation. All choices can be found here:
+# http://www.i18nguy.com/unicode/language-identifiers.html
+LANGUAGE_CODE = 'en-us'
+
+SITE_ID = 1
+
+# If you set this to False, Django will make some optimizations so as not
+# to load the internationalization machinery.
+USE_I18N = True
+
+# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
+# trailing slash.
+# Examples: "http://foo.com/media/", "/media/".
+ADMIN_MEDIA_PREFIX = '/media/'
+
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = '8iu-qrn)p9z&s&)*7ms9q%hadakh2lu8-v()i6&f@-8eksyj38'
+
+# List of callables that know how to import templates from various sources.
+TEMPLATE_LOADERS = (
+ 'django.template.loaders.filesystem.load_template_source',
+ 'django.template.loaders.app_directories.load_template_source',
+# 'django.template.loaders.eggs.load_template_source',
+)
+
+MIDDLEWARE_CLASSES = (
+ 'django.middleware.common.CommonMiddleware',
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'django.middleware.doc.XViewMiddleware',
+)
+
+
+
+INSTALLED_APPS = (
+ 'pollngo',
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.sites',
+ 'django.contrib.admin',
+
+)
352 site_media/pollngo/default.css
@@ -0,0 +1,352 @@
+/*
+
+ terrafirma1.0 by nodethirtythree design
+ http://www.nodethirtythree.com
+
+*/
+
+*
+{
+padding: 0px;
+margin: 0px;
+}
+
+body
+{
+background: #F9F9F7 url('images/a1.gif') repeat-x;
+font-size: 11px;
+font-family: "trebuchet ms", helvetica, sans-serif;
+color: #8C8C73;
+line-height: 18px;
+}
+
+a
+{
+color: #FF7800;
+text-decoration: underline;
+}
+
+a:hover
+{
+text-decoration: none;
+}
+
+sup
+{
+font-size: 0.5em;
+}
+
+
+p
+{
+margin-bottom: 14px;
+text-align: justify;
+}
+
+img.picA
+{
+position: relative;
+top: -2px;
+background: url('images/a47.gif') no-repeat;
+width: 76px;
+height: 74px;
+padding: 8px;
+}
+
+img.picB
+{
+position: relative;
+top: -2px;
+background: url('images/a26.gif') no-repeat;
+width: 146px;
+height: 75px;
+padding: 7px;
+}
+
+img.floatleft
+{
+float: left;
+margin: 0px 14px 3px 0px;
+}
+
+
+ul.linklist
+{
+list-style: none;
+}
+
+ul.linklist li
+{
+border-top: solid 1px #EEEEEE;
+padding-top: 5px;
+margin: 5px 0px 0px 0px;
+}
+
+ul.linklist li.first
+{
+border-top: 0px;
+margin-top: 0px;
+padding-top: 0px;
+}
+
+#upbg
+{
+position: absolute;
+top: 0px;
+left: 0px;
+background: #fff url('images/upbg.gif') no-repeat;
+width: 747px;
+height: 264px;
+z-index: 1;
+}
+
+#outer
+{
+position: relative;
+width: 747px;
+margin: 0 auto;
+background: #fff url('images/abg.gif') repeat-y;
+}
+
+#inner
+{
+position: relative;
+padding: 13px 30px 13px 30px;
+z-index: 2;
+}
+
+#header
+{
+position: absolute;
+background: #FF7800 url('images/a8.gif') repeat-x;
+width: 202px;
+height: 92px;
+color: #fff;
+padding-left: 20px;
+}
+
+#header span
+{
+font-weight: normal;
+}
+
+#header h1
+{
+position: absolute;
+font-size: 23px;
+letter-spacing: -1px;
+top: 30px;
+height: 92px;
+}
+
+#header h2
+{
+position: absolute;
+font-size: 10px;
+font-weight: normal;
+color: #FCE2CA;
+top: 51px;
+}
+
+#header sup
+{
+color: #FCE2CA;
+}
+
+#splash
+{
+position: absolute;
+right: 30px;
+background: #EAEAE2 url('images/a10.jpg') no-repeat;
+width: 458px;
+height: 92px;
+}
+
+#menu
+{
+position: relative;
+background: #46461F url('images/a16.gif') repeat-x;
+height: 67px;
+padding: 0px 20px 0px 5px;
+margin: 98px 0px 20px 0px;
+}
+
+#menu ul
+{
+}
+
+#menu ul li
+{
+display: inline;
+line-height: 52px;
+padding-left: 3px;
+}
+
+#menu ul li.first
+{
+border-left: 0px;
+}
+
+#menu ul li a
+{
+background-color: transparent;
+background-repeat: repeat-x;
+padding: 8px 12px 8px 12px;
+font-size: 12px;
+color: #fff;
+font-weight: bold;
+}
+
+#menu ul li a:hover
+{
+background: #fff url('images/a18.gif') repeat-x top;
+color: #4A4A24;
+text-decoration: none;
+}
+
+#date
+{
+position: absolute;
+top: 0px;
+line-height: 52px;
+color: #BDBDA2;
+right: 30px;
+font-weight: bold;
+font-size: 12px;
+letter-spacing: -1px;
+}
+
+#secondarycontent
+{
+position: relative;
+width: 180px;
+float: right;
+}
+
+#secondarycontent h3
+{
+position: relative;
+top: 4px;
+font-size: 16px;
+line-height: 25px;
+color: #656551;
+letter-spacing: -1px;
+background: url('images/a22.gif') bottom repeat-x;
+padding: 0px 0px 10px 10px;
+margin-bottom: 20px;
+}
+
+#secondarycontent .content
+{
+padding: 0px 10px 0px 10px;
+margin-bottom: 20px;
+}
+
+#primarycontent
+{
+position: relative;
+width: 480px;
+float: left;
+}
+
+#primarycontent h3
+{
+position: relative;
+top: 4px;
+font-size: 18px;
+line-height: 25px;
+color: #656551;
+letter-spacing: -1px;
+background: url('images/a22.gif') bottom repeat-x;
+padding: 0px 0px 10px 15px;
+margin-bottom: 20px;
+}
+
+#primarycontent .content
+{
+padding: 0px 15px 0px 15px;
+margin-bottom: 20px;
+}
+
+#primarycontent .post
+{
+margin-bottom: 30px;
+}
+
+#primarycontent .post .header
+{
+position: relative;
+}
+
+#primarycontent .post .user
+{
+position: absolute;
+right: 15px;
+top: 0px;
+line-height: 35px;
+color: #AFAFA4;
+font-weight: bold;
+}
+
+#primarycontent .post .content
+{
+margin-bottom: 0px;
+}
+
+#primarycontent .post .footer
+{
+position: relative;
+top: -10px;
+background: url('images/a33.gif') repeat-x;
+height: 64px;
+}
+
+#primarycontent .post .footer ul
+{
+list-style: none;
+position: absolute;
+right: 15px;
+bottom: 15px;
+}
+
+#primarycontent .post .footer ul li
+{
+display: inline;
+line-height: 14px;
+padding-left: 17px;
+margin-left: 25px;
+background-repeat: no-repeat;
+background-position: 0px 2px;
+}
+
+#primarycontent .post .footer ul li.printerfriendly
+{
+background-image: url('images/a41.gif');
+}
+
+#primarycontent .post .footer ul li.comments
+{
+background-image: url('images/a36.gif');
+}
+
+#primarycontent .post .footer ul li.readmore
+{
+background-image: url('images/a38.gif');
+}
+
+#footer
+{
+position: relative;
+clear: both;
+height: 66px;
+text-align: center;
+line-height: 66px;
+background-image: url('images/a50.gif');
+color: #A8A88D;
+}
+
+#footer a
+{
+color: #8C8C73;
+}
+
BIN  site_media/pollngo/images/a1.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  site_media/pollngo/images/a10.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  site_media/pollngo/images/a16.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  site_media/pollngo/images/a18.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  site_media/pollngo/images/a22.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  site_media/pollngo/images/a26.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  site_media/pollngo/images/a33.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  site_media/pollngo/images/a36.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  site_media/pollngo/images/a38.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  site_media/pollngo/images/a41.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  site_media/pollngo/images/a47.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  site_media/pollngo/images/a50.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  site_media/pollngo/images/a8.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  site_media/pollngo/images/abg.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  site_media/pollngo/images/pic1.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  site_media/pollngo/images/pic2.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  site_media/pollngo/images/spacer.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  site_media/pollngo/images/upbg.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 templates/404.html
@@ -0,0 +1,13 @@
+{% extends 'pollngo/base.html' %}
+
+{% block content %}
+ <div class="post">
+ <div class="header">
+ <h3>404 - Not found</h3>
+ </div>
+ <p>
+ Resource not found. The server wanna kill itself now.
+ </p>
+
+ </div>
+{% endblock %}
13 templates/500.html
@@ -0,0 +1,13 @@
+{% extends 'pollngo/base.html' %}
+
+{% block content %}
+ <div class="post">
+ <div class="header">
+ <h3>500 - Not found</h3>
+ </div>
+ <p>
+ Server Error! How is that even possible?
+ </p>
+
+ </div>
+{% endblock %}
19 urls.py
@@ -0,0 +1,19 @@
+from django.conf.urls.defaults import *
+from django.conf import settings
+from django.contrib import admin
+
+admin.autodiscover()
+
+urlpatterns = patterns('',
+ (r'^polls/', include('pollngo.urls')),
+ )
+
+urlpatterns += patterns('',
+ (r'^admin/(.*)', admin.site.root),
+ )
+
+if settings.DEBUG:
+ media_dir = settings.MEDIA_ROOT
+ urlpatterns += patterns('',
+ url(r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': media_dir}),
+ )
Please sign in to comment.
Something went wrong with that request. Please try again.