Commits

Guillaume Piot  committed dbfe7d1

Read me file

  • Participants
  • Parent commits 663d115

Comments (0)

Files changed (1)

+Requirements
+============
+
+Works on Django 1.3, not tested on previous version but is very likely to work.
+
+jQuery, including AJAX functions
+
+
+Models
+======
+
+Poll
+-----
+
+Create the poll item, including question and answers.
+
+
+Poll submission
+---------------------
+
+Record a poll submission containing the answer id and text. Each record belongs to a poll (using a ForeignKey)
+
+
+
+Backend
+=======
+
+A function to download a CSV file containing the poll result has been written.
+
+The view that create this CSV is in views.py (called: export_answers).
+
+
+Template tags
+=============
+
+In templatetags/poll_tags.py, a function called get_polls renders all the active polls. An argument called limit controls the number of poll returned, by default, it is set to 2.
+
+The form is rendered using the polls.html template.
+
+This template containg the JQuery call to make the AJAX request which submit the result.
+
+* Please note that JQuery must be pre-included in your page template.
+
+
+AJAX view
+=========
+
+The submission is controlled by the submit button, which triggers an AJAX call.
+
+The URL of the call is: /poll/submit/(poll_id)/(answer_id)
+
+This URL will submit the answer and return an HTML view which is re-loaded by JQUERY in to the poll form area.
+
+Bar graph
+=========
+
+A simple bar graph is generated from the answer results. It is a pro-rata of the highest value by the width of the box containing the graph.
+
+In models.py, poll model enter the relevant size:
+
+#Enter the div of the width containing the bar graph
+div_width = 200
+
+Installation
+============  
+
+First of all, you must create a new Django project if you don't have one already and run through the conventional installation procedure (settings, db, etc...), then:
+
+1. Download the django-ajax-poll app
+2. Add it to your app list in settings.py:
+	INSTALLED_APPS = (
+	    'django.contrib.auth',
+	    'django.contrib.contenttypes',
+	    'django.contrib.sessions',
+	    'django.contrib.sites',
+	    'django.contrib.messages',
+	    'django.contrib.staticfiles',
+	 
+		'myproject.django-ajax-poll'
+
+	)
+	
+3. Add poll urls.py to the main urls.py:
+	urlpatterns = patterns('',
+	    url(r'^poll/', include('myproject.poll.urls')),
+	) 
+	
+* Please note: I have called my Django project gpoll in various area of the app, so may have to change this reference for your Django project. 
+
+4. Browse to localhost:8000/poll (if you're on local obviously, otherwise use your root domain)
+
+
+HTML tags
+=========
+
+The list of polls need to be implementd as follow:
+
+{% load poll_tags %}
+<div id="poll">{% get_polls %}</div>    
+
+Which will render the template polls.html
+
+The AJAX submission will save the result and render the template poll_answer_ajax.html
+
+default.html is an example page rendering the polls all together.
+
+
+Possible errors
+===============
+
+"CSRF token missing or incorrect"
+
+
+