Commits

Rafael A  committed fddc4a7

Now poll's static files are deployable by 'collectstatic'

  • Participants
  • Parent commits d516c9d

Comments (0)

Files changed (5)

 
 Requirements
 
+Django 1.3
 JQuery (http://jquery.com/)
 Django Internationalization (optionally)
 
 
 Installation
 
-Download or clone repository and unpack it into your project folder. Now you have two folders of files:
-
--- poll - it's the application 
--- static - and static files for it (css, js)
-
-The folders you unpacked are already in a right place. Now you should config your site to use the poll application. Follow instructions below:
+Download or clone repository and unpack it into your project folder. Now you should config your site to use the poll application. Follow instructions below:
 
 
 1. Add the name of the application at the end of your INSTALLED_APPS (in settings.py), like this:
 urlpatterns += staticfiles_urlpatterns()
 
 
-3. Now we need to do "syncdb".
+3. Run 'collectstatic' to deploy poll's static files (see https://docs.djangoproject.com/en/1.3/howto/static-files/#deploying-static-files-in-a-nutshell)
+   >> python manage.py collectstatic
 
+
+4. Eventually we need to do "syncdb".
    >> python manage.py syncdb
 
 ATTENTION: Don't forget this step. It's very important, because django-poll-system have a fixture that needs to be installed to DB.

File poll/static/polls/css/polls.css

+#poll_content {background-color: #0B9D0B; padding: 3px;}
+#poll_content h1 {font-variant: small-caps;}
+#poll_content #poll_userspace {float: left; width: 100%; text-align: right;}
+#poll_content #poll {color: #b10000; font-variant: small-caps; text-decoration: underline;}
+
+#poll_item_dl {clear: both; width: 100%;} 
+
+#poll_body {background-color: #00BC00; padding: 10px 10% 3px 20px; clear: both; border-bottom: 3px solid #006600; border-left: 1px solid #005500;}
+#poll_body #showresults {font-variant: small-caps;}
+#poll_body #sendvote {padding: 5px;}
+
+#poll_body #bar {display: block; padding: 5px; border-bottom: 2px solid #444; border-left: 1px solid #222;}
+#poll_body #bar.max_bar {background-color: red;}
+#poll_body #bar.normal_bar {background-color: white;}
+
+#poll_body #voters_count {text-align: right; border-top: 2px solid #333; margin: 25px; padding-top: 4px;}
+#poll_body #total {font-size: 1.5em;}

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 static/polls/css/polls.css

-#poll_content {background-color: #0B9D0B; padding: 3px;}
-#poll_content h1 {font-variant: small-caps;}
-#poll_content #poll_userspace {float: left; width: 100%; text-align: right;}
-#poll_content #poll {color: #b10000; font-variant: small-caps; text-decoration: underline;}
-
-#poll_item_dl {clear: both; width: 100%;} 
-
-#poll_body {background-color: #00BC00; padding: 10px 10% 3px 20px; clear: both; border-bottom: 3px solid #006600; border-left: 1px solid #005500;}
-#poll_body #showresults {font-variant: small-caps;}
-#poll_body #sendvote {padding: 5px;}
-
-#poll_body #bar {display: block; padding: 5px; border-bottom: 2px solid #444; border-left: 1px solid #222;}
-#poll_body #bar.max_bar {background-color: red;}
-#poll_body #bar.normal_bar {background-color: white;}
-
-#poll_body #voters_count {text-align: right; border-top: 2px solid #333; margin: 25px; padding-top: 4px;}
-#poll_body #total {font-size: 1.5em;}

File 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();
-	});
-});