Commits

Rafael A committed ae23410

Bug fix: #1

  • Participants
  • Parent commits 25d05d7

Comments (0)

Files changed (6)

 
 ----
 
-Now installation is complete. After all, you have some data out of the box. And it's time to show the poll on your site. Add {% load polls_tags %} at the top of your page and insert {% poll_queue 'Public' %} to the place you want to see it. Of course the script of JQuery library must be included (<script type="text/javascript" src="your/path/to/jquery.js"></script>) before you call "poll_queue".
+Now installation is completed. After all, you have some data out of the box. And it's time to show the poll on your site. Add lines below:
+
+{% load polls_tags %}
+<link rel="stylesheet" href="{{ STATIC_URL }}polls/css/polls.css" />
+
+at the top of your page and insert {% poll_queue 'Public' %} to the place you want to see the django-poll-system component. Of course the script of JQuery library must be included (<script type="text/javascript" src="your/path/to/jquery.js"></script>) before you call "poll_queue".
 
 That's all. Try an example: http://polltest.pythonism.ru

File poll/locale/ru/LC_MESSAGES/django.mo

Binary file modified.

File poll/locale/ru/LC_MESSAGES/django.po

 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-11-18 09:51+0400\n"
+"POT-Creation-Date: 2012-01-05 12:10+0400\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
-"Language: \n"
-"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%"
-"10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"
+"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
+"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"
 
-#: .\admin.py:19
+#: admin.py:19
 msgid "Options"
 msgstr "Опции"
 
-#: .\models.py:8
+#: models.py:8
 msgid "Type title"
 msgstr "Введите заголовок"
 
-#: .\models.py:8
+#: models.py:8
 msgid "It will be used as header of the poll"
 msgstr "Будет использован как заголовок опроса"
 
-#: .\models.py:9
+#: models.py:9
 msgid "Index"
 msgstr "Индекс"
 
-#: .\models.py:9 .\models.py:27
+#: models.py:9 models.py:27
 msgid "Must be unique"
 msgstr "Должен быть уникальным"
 
-#: .\models.py:16
+#: models.py:16
 msgid "PollType"
 msgstr "Тип опроса"
 
-#: .\models.py:17
+#: models.py:17
 msgid "PollTypes"
 msgstr "Типы опроса"
 
-#: .\models.py:24
+#: models.py:24
 msgid "Title"
 msgstr "Заголовок"
 
-#: .\models.py:24
+#: models.py:24
 msgid "The parameter is used as question to user"
 msgstr "Параметр используется как заголовок вопроса к пользователю"
 
-#: .\models.py:25 .\models.py:76
+#: models.py:25 models.py:76
 msgid "Queue"
 msgstr "Очередь"
 
-#: .\models.py:25
+#: models.py:25
 msgid ""
 "Do you want to use the poll as a stand alone poll or insert it into the "
 "queue?"
 "Вы хотите использовать опрос как отдельностоящий опрос или вставить его в "
 "очередь?"
 
-#: .\models.py:26
+#: models.py:26
 msgid "Poll type"
 msgstr "Тип опроса"
 
-#: .\models.py:26
+#: models.py:26
 msgid "Choose the poll type"
 msgstr "Выберете тип опроса"
 
-#: .\models.py:27
+#: models.py:27
 msgid "Start date"
 msgstr "Дата старта"
 
-#: .\models.py:28
+#: models.py:28
 msgid "Publish"
 msgstr "Публиковать"
 
-#: .\models.py:29 .\models.py:105
+#: models.py:29 models.py:105
 msgid "Votes"
 msgstr "Голоса"
 
-#: .\models.py:29
+#: models.py:29
 msgid "Choose variants of answers"
 msgstr "Выберете варианты ответов"
 
-#: .\models.py:36
+#: models.py:36
 msgid "\"Start dates\" of polls in the same queue must be different"
 msgstr ""
 "Параметры \"Start dates\" у разных опросов в одной очереди должны быть "
 "отличны"
 
-#: .\models.py:58 .\models.py:92 .\templates\polls.html.py:25
+#: models.py:58 models.py:92 templates/polls.html:133
 msgid "Poll"
 msgstr "Опрос"
 
-#: .\models.py:59
+#: models.py:59
 msgid "Polls"
 msgstr "Опросы"
 
-#: .\models.py:60
+#: models.py:60
 msgid "User can vote"
 msgstr "Пользователь может голосовать"
 
-#: .\models.py:63
+#: models.py:63
 msgid "Queue name"
 msgstr "Название очереди"
 
-#: .\models.py:63
+#: models.py:63
 msgid "It must be unique"
 msgstr "Должен быть уникальным"
 
-#: .\models.py:64
+#: models.py:64
 msgid "Need auth?"
 msgstr "Нужна аутентификация?"
 
-#: .\models.py:64
+#: models.py:64
 msgid ""
 "Do the poll queue is for authenticated users only or not? (If yes, users "
 "must have \"can_vote\" permission to vote)"
 "Очередь опросов только для аутентифицированных пользователей или нет? (Иначе "
 "у пользователя должен быть доступ \"can_vote\")"
 
-#: .\models.py:68
+#: models.py:68
 msgid "With auth"
 msgstr "С авторизацией"
 
-#: .\models.py:70
+#: models.py:70
 msgid "Without auth"
 msgstr "Без авторизации"
 
-#: .\models.py:77
+#: models.py:77
 msgid "Queues"
 msgstr "Очереди"
 
-#: .\models.py:81
+#: models.py:81
 msgid "Its userbox?"
 msgstr "Это пользовательский ввод?"
 
-#: .\models.py:81
+#: models.py:81
 msgid "Set it, if you want user to type its own answer. (show as textbox)"
 msgstr ""
 "Выберете это, если вы хотите что бы пользователь сам напечатал свой ответ "
 "(вывод textbox)"
 
-#: .\models.py:82
+#: models.py:82
 msgid "Value"
 msgstr "Значение"
 
-#: .\models.py:82
+#: models.py:82
 msgid "Its a title of item"
 msgstr "Заголовок item"
 
-#: .\models.py:83
+#: models.py:83
 msgid "Position"
 msgstr "Позиция"
 
-#: .\models.py:83
+#: models.py:83
 msgid "Its for positioning only"
 msgstr "Только для позиционирования"
 
-#: .\models.py:93
+#: models.py:93
 msgid "User's IP"
 msgstr "IP пользователя"
 
-#: .\models.py:94 .\templates\polls.html.py:28
+#: models.py:94 templates/polls.html:136
 msgid "User"
 msgstr "Пользователь"
 
-#: .\models.py:96
+#: models.py:96
 msgid "Voited items"
 msgstr "Голосовавшие items"
 
-#: .\models.py:104 .\templates\polls.html.py:37
+#: models.py:104 templates/polls.html:145
 msgid "Vote"
 msgstr "Голос"
 
-#: .\templates\polls.html.py:12
+#: templates/polls.html:59
 msgid "Total Voters"
 msgstr "Всего"
 
-#: .\templates\polls.html.py:13
+#: templates/polls.html:109
 msgid "Please, choose anything to vote"
 msgstr "Пожалуйста выберете что-нибудь чтобы проголосовать"
 
-#: .\templates\polls.html.py:20
+#: templates/polls.html:128
 msgid ""
-"WARNING: A JavaScript is disabled in your browser. Please, turn it on to "
-"vote."
+"WARNING: JavaScript is disabled in your browser. Please, turn it on to vote."
 msgstr ""
 "JavaScript отключен в вашем браузере. Вы должны включить его, чтобы "
 "проголосовать."
 
-#: .\templates\polls.html.py:33
+#: templates/polls.html:141
 msgid "You already voted"
 msgstr "Вы уже проголосовали"
 
-#: .\templates\polls.html.py:34
+#: templates/polls.html:142
 msgid "Show results"
 msgstr "Показать результаты"
 
-#: .\templates\polls.html.py:43
+#: templates/polls.html:151
 msgid ""
 "WARNING: Cookies are disabled in your browser. Please, turn it on to vote."
 msgstr ""

File poll/static/polls/js/common.js

-$(document).ready(function() {
-	var path_to_items = '#poll_content #poll_body input[name="poll_' + poll_pk + '"]';
-	var body = $('#poll_body');
-	
-	function showResults(data) {
-		var all_points = 0, total = 0, biggest = 0;
-		
-		body.hide('slow', complete=function() {
-			body.empty();
-			$.each(data, function(index, value) {
-				if(index != 'total') {
-					if(data[index]['count'] > biggest) {
-						biggest = data[index]['count'];
-					}
-					all_points += data[index]['count'];
-				}
-			});
-			
-			$.each(data, function(index, value) {
-				if(index == 'total') {
-					total = value;
-				} else {
-					var percentage = (data[index]['count'] * 100) / all_points;
-					var bar_class = 'normal_bar';
-					
-					if(data[index]['count'] == biggest) {
-						bar_class = 'max_bar';
-					}
-					
-					var points_txt = '';
-					if(show_points) {
-						points_txt = '<sup>(' + data[index]['count'] + ')</sup>'; 
-					}
-					
-					body.append('<dl id="poll_item_dl">');
-					body.append('<dt>' + data[index]['title'] + ': <strong>' + (Math.round(percentage*100)/100) + '%</strong>' + points_txt + '</dt>');
-					body.append('<dd><div id="bar" class="' + bar_class + '" style="width: ' + percentage + '%;"></div></dd>');
-					body.append('</dl>');
-				}
-			});
-			
-			var total_points_txt = '';
-			if(show_points) {
-				total_points_txt = '<sup>(' + all_points + ')</sup>'; 
-			}
-			
-			body.append('<div id="voters_count">' + trans_total_voters + ': <span id="total">' + total + '</span> ' + total_points_txt + '</div>');
-		}).show('slow');
-	}
-	
-	function RecognizeAndPrepare() {
-		var result = '';
-		
-		$(path_to_items).map(function() {
-			if((this.type == 'checkbox' || this.type == 'radio') && this.checked) {
-				result += '"' + this.id + '": ' + '"' + this.type + '",';
-			}
-			if(this.type == 'text' && this.value != '') {
-				result += '"' + this.id + '": ' + '"' + this.value + '",';
-			}
-		})
-		
-		if(result.length > 0)
-			if(result[result.length - 1] == ',')
-				result = result.substring(0, result.length - 1);
-		
-		return '{' + result + '}';
-	}
-	
-	$(path_to_items).bind('focusin click', function() {
-		if(poll_type == 'single') {
-			var selected = this;
-			
-			$(path_to_items).map(function() {
-				if(this != selected) {
-					if((this.type == 'checkbox' || this.type == 'radio') && this.checked) {
-						this.checked = false;
-					}
-					if(this.type == 'text' && this.value != '') {
-						this.value = '';
-					}
-				} 
-			});
-		}
-	});
-	
-	function doResults() {
-		$.get(result_url, function(data) {
-			showResults($.parseJSON(data));
-		});
-	}
-	
-	$("#sendvote").click(function() {
-		var result = RecognizeAndPrepare();
-		
-		if(result == '{}') {
-			alert(trans_select_something);
-		} else {
-			body.hide('slow', complete=function() {
-				$.get(vote_url, {'chosen_items': result}, function() {
-					doResults();
-				});
-			});
-		}
-	});
-	
-	$("#showresults").click(function() {
-		doResults();
-	});
-});

File poll/templates/polls.html

 {% load polls_tags %}
 
 {% if poll %}
-<link rel="stylesheet" href="{{ STATIC_URL }}polls/css/polls.css" />
 <script type="text/javascript">
-	vote_url = '{% url poll_ajax_vote poll.pk %}';
-	result_url = '{% url poll_ajax_result poll.pk %}';
-	poll_pk = '{{ poll.pk }}';
-	poll_type = {% if poll.polltype.index == 0 %}'single'{% else %}'multiple'{% endif %};
 	show_points = false;
-	trans_total_voters = '{% trans "Total Voters" %}';
-	trans_select_something = '{% trans "Please, choose anything to vote" %}';
+
+	$(document).ready(function() {
+		var vote_url = '{% url poll_ajax_vote poll.pk %}';
+		var result_url = '{% url poll_ajax_result poll.pk %}';
+		var poll_pk = '{{ poll.pk }}';
+		var poll_type = {% if poll.polltype.index == 0 %}'single'{% else %}'multiple'{% endif %};
+		
+		var path_to_items = '#poll_content_' + poll_pk + ' #poll_body input[name="poll_' + poll_pk + '"]';
+		var body = $('#poll_content_' + poll_pk + ' #poll_body');
+		
+		function showResults(data) {
+			var all_points = 0, total = 0, biggest = 0;
+			
+			body.hide('slow', complete=function() {
+				body.empty();
+				$.each(data, function(index, value) {
+					if(index != 'total') {
+						if(data[index]['count'] > biggest) {
+							biggest = data[index]['count'];
+						}
+						all_points += data[index]['count'];
+					}
+				});
+				
+				$.each(data, function(index, value) {
+					if(index == 'total') {
+						total = value;
+					} else {
+						var percentage = (data[index]['count'] * 100) / all_points;
+						var bar_class = 'normal_bar';
+						
+						if(data[index]['count'] == biggest) {
+							bar_class = 'max_bar';
+						}
+						
+						var points_txt = '';
+						if(show_points) {
+							points_txt = '<sup>(' + data[index]['count'] + ')</sup>'; 
+						}
+						
+						body.append('<dl id="poll_item_dl">');
+						body.append('<dt>' + data[index]['title'] + ': <strong>' + (Math.round(percentage*100)/100) + '%</strong>' + points_txt + '</dt>');
+						body.append('<dd><div id="bar" class="' + bar_class + '" style="width: ' + percentage + '%;"></div></dd>');
+						body.append('</dl>');
+					}
+				});
+				
+				var total_points_txt = '';
+				if(show_points) {
+					total_points_txt = '<sup>(' + all_points + ')</sup>'; 
+				}
+				
+				body.append('<div id="voters_count">' + '{% trans "Total Voters" %}' + ': <span id="total">' + total + '</span> ' + total_points_txt + '</div>');
+			}).show('slow');
+		}
+		
+		function RecognizeAndPrepare() {
+			var result = '';
+			
+			$(path_to_items).map(function() {
+				if((this.type == 'checkbox' || this.type == 'radio') && this.checked) {
+					result += '"' + this.id + '": ' + '"' + this.type + '",';
+				}
+				if(this.type == 'text' && this.value != '') {
+					result += '"' + this.id + '": ' + '"' + this.value + '",';
+				}
+			})
+			
+			if(result.length > 0)
+				if(result[result.length - 1] == ',')
+					result = result.substring(0, result.length - 1);
+			
+			return '{' + result + '}';
+		}
+		
+		$(path_to_items).bind('focusin click', function() {
+			if(poll_type == 'single') {
+				var selected = this;
+				
+				$(path_to_items).map(function() {
+					if(this != selected) {
+						if((this.type == 'checkbox' || this.type == 'radio') && this.checked) {
+							this.checked = false;
+						}
+						if(this.type == 'text' && this.value != '') {
+							this.value = '';
+						}
+					} 
+				});
+			}
+		});
+		
+		function doResults() {
+			$.get(result_url, function(data) {
+				showResults($.parseJSON(data));
+			});
+		}
+		
+		$("#sendvote_" + poll_pk).click(function() {
+			var result = RecognizeAndPrepare();
+			
+			if(result == '{}') {
+				alert('{% trans "Please, choose anything to vote" %}');
+			} else {
+				body.hide('slow', complete=function() {
+					$.get(vote_url, {'chosen_items': result}, function() {
+						doResults();
+					});
+				});
+			}
+		});
+		
+		$("#showresults_" + poll_pk).click(function() {
+			doResults();
+		});
+	});
 </script>
-<script type="text/javascript" src="{{ STATIC_URL }}polls/js/common.js"></script>
 
-<div id="poll_content">
+<div id="poll_content_{{ poll.pk }}">
 	<p id="warning">
 		<noscript>		
-			{% trans "WARNING: A JavaScript is disabled in your browser. Please, turn it on to vote." %}
+			{% trans "WARNING: JavaScript is disabled in your browser. Please, turn it on to vote." %}
 		</noscript>
 	</p>
 	<form method="post">
 		<div id="poll_body">
 			{% if poll.get_cookie_name in request.COOKIES %}
 				<p>{% trans "You already voted" %}.</p>
-				<p><a id="showresults" href="javascript:void(0);">{% trans "Show results" %}</a></p>
+				<p><a id="showresults_{{ poll.pk }}" href="javascript:void(0);">{% trans "Show results" %}</a></p>
 			{% else %}
 				{% render_items poll items %}
-				<p><input id="sendvote" type="button" value="{% trans "Vote" %}" /></p>
+				<p><input id="sendvote_{{ poll.pk }}" type="button" value="{% trans "Vote" %}" /></p>
 			{% endif %}
 		</div>
 	</form>
 	<script type="text/javascript">
 		if(!navigator.cookieEnabled) {
-			$('#poll_content #warning').append('{% trans "WARNING: Cookies are disabled in your browser. Please, turn it on to vote." %}');
-			$('#sendvote').attr('disabled', '');
+			$('#poll_content_{{ poll.pk }} #warning').append('{% trans "WARNING: Cookies are disabled in your browser. Please, turn it on to vote." %}');
+			$('#sendvote_{{ poll.pk }}').attr('disabled', '');
 		}
 	</script>
 </div>
       url='http://polltest.pythonism.ru',
       download_url='https://bitbucket.org/RafRaf/django-poll-system',
       packages=['poll', 'poll.templatetags'],
-      package_data={'poll': ['fixtures/initial_data.json', 'static/polls/css/*', 'static/polls/js/*', 'locale/ru/LC_MESSAGES/*', 'templates/*']},
+      package_data={'poll': ['fixtures/initial_data.json', 'static/polls/css/*', 'locale/ru/LC_MESSAGES/*', 'templates/*']},
      )