Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Árni St. Sigurðsson committed Jul 8, 2016
0 parents commit d6c0b48
Show file tree
Hide file tree
Showing 56 changed files with 1,293 additions and 0 deletions.
Binary file added db.sqlite3
Binary file not shown.
Binary file added headshotbig.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "vaa.settings")

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)
20 changes: 20 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Django==1.9.7
Pillow==3.3.0
argparse==1.2.1
backports.shutil-get-terminal-size==1.0.0
crc16==0.1.1
decorator==4.0.10
django-crispy-forms==1.6.0
ipython==4.2.1
ipython-genutils==0.1.0
pathlib2==2.1.0
pexpect==4.2.0
pickleshare==0.7.2
psycopg2==2.6.1
ptyprocess==0.5.1
python-redis==0.0.7
simplegeneric==0.8.1
six==1.10.0
traitlets==4.2.2
wsgiref==0.1.2
git+https://github.com/timmyomahony/django-charsleft-widget.git
17 changes: 17 additions & 0 deletions static/charsleft-widget/css/charsleft.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.charsleft{
height: 23px;
}
.charsleft > span{
vertical-align: middle;
margin-left: 0.5em;
color: #ccc;
line-height: 23px;
}
.charsleft span .count{
color: #333;
}
.charsleft .maxlength{
display: none;
}
.charsleft span .orange{color:#EA1300 !important;}
.charsleft span .red{color: #D56F24 !important;}
45 changes: 45 additions & 0 deletions static/charsleft-widget/js/charsleft.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
(function($){

$.fn.charsLeft = function(options){

var defaults = {
'source':'input',
'dest':'.count',
}
var options = $.extend(defaults, options);

var calculate = function(source, dest, maxlength){
var remaining = maxlength - source.val().length;
dest.html(remaining);
/* Over 50%, change colour to orange */
p=(100*remaining)/maxlength;
console.log(p)
if(p<25){
dest.addClass('orange');
}else if(p<50){
dest.addClass('red');
}else{
dest.removeClass('orange red');
}
};

this.each(function(i, el) {
var maxlength = $(this).find('.maxlength').html();
var dest = $(this).find(options.dest);
var source = $(this).find(options.source);
source.keyup(function(){
calculate(source, dest, maxlength)
});
source.change(function(){
calculate(source, dest, maxlength)
});
});
};
$(function() { // Added page ready wrapper
$(".charsleft-input").charsLeft({
'source':'input',
'dest':".count",
});
});
})(jQuery);

45 changes: 45 additions & 0 deletions static/charsleft-widget/js/charsleft.js~
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
(function($){

$.fn.charsLeft = function(options){

var defaults = {
'source':'input',
'dest':'.count',
}
var options = $.extend(defaults, options);

var calculate = function(source, dest, maxlength){
var remaining = maxlength - source.val().length;
dest.html(remaining);
/* Over 50%, change colour to orange */
p=(100*remaining)/maxlength;
console.log(p)
if(p<25){
dest.addClass('orange');
}else if(p<50){
dest.addClass('red');
}else{
dest.removeClass('orange red');
}
};

this.each(function(i, el) {
var maxlength = $(this).find('.maxlength').html();
var dest = $(this).find(options.dest);
var source = $(this).find(options.source);
source.keyup(function(){
calculate(source, dest, maxlength)
});
source.change(function(){
calculate(source, dest, maxlength)
});
});
};
$(function() { // Added page ready wrapper
$(".charsleft-input").charsLeft({
'source':'input',
'dest':".count",
});
});
})(django.jQuery);

12 changes: 12 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<html>
<head>
<title>{% block title %}{% endblock title %}</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
{% block extrahead %}
{% endblock extrahead %}
</head>
<body>
{% block content %}
{% endblock content %}
</body>
8 changes: 8 additions & 0 deletions templates/base.html~
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<html>
<head>
<title>{% block title %}{% endblock title %}</title>
</head>
<body>
{% block content %}
{% endblock content %}
</body>
7 changes: 7 additions & 0 deletions templates/candanswers.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% extends "base.html" %}
{% load crispy_forms_tags %}
{% block content %}
{% crispy answerform %}
{{ answerform.media }}
{% endblock content %}

2 changes: 2 additions & 0 deletions templates/candanswers.html~
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% extends "base.html" %}
{% crispy answerform %}
13 changes: 13 additions & 0 deletions templates/comparison.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends "base.html" %}
{% block content %}
<table>
<thead>
<tr><td>Frambjóðandi</td><td>Hversu sammála</td></tr>
</thead>
<tbody>
{% for cand, percent in data %}
<tr><td>{{ cand.name }}</td><td>{{ percent }}</td>
{% endfor %}
</tbody>
</table>
{% endblock content %}
4 changes: 4 additions & 0 deletions templates/comparison.html~
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% extends "base.html" %}
{% block content %}

{% endblock content %}
7 changes: 7 additions & 0 deletions templates/userpage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% extends "base.html" %}
{% load crispy_forms_tags %}
{% block content %}
<form action="/userupdate/" method="POST">
{% crispy userpageform %}
</form>
{% endblock content %}
4 changes: 4 additions & 0 deletions templates/userpage.html~
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% extends "base.html" %}
{% block content %}
{{ userform.as_p }}
{% endblock content %}
5 changes: 5 additions & 0 deletions templates/voter_form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% extends "base.html" %}
{% load crispy_forms_tags %}
{% block content %}
{% crispy voterform %}
{% endblock content %}
Empty file added vaa/__init__.py
Empty file.
Binary file added vaa/__init__.pyc
Binary file not shown.
Empty file added vaa/questions/__init__.py
Empty file.
Binary file added vaa/questions/__init__.pyc
Binary file not shown.
Empty file added vaa/questions/__init__.py~
Empty file.
32 changes: 32 additions & 0 deletions vaa/questions/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from django.contrib import admin

from .models import Candidate, Question, QuestionText, AnswerSheet, AnswerText


class QuestionTextInline(admin.TabularInline):
model = QuestionText


class AnswerSheetInline(admin.TabularInline):
model = AnswerSheet


class CandidateAdmin(admin.ModelAdmin):
inlines = [AnswerSheetInline,]


class QuestionAdmin(admin.ModelAdmin):
inlines = [QuestionTextInline,]


class AnswerSheetAdmin(admin.ModelAdmin):
pass


class AnswerTextAdmin(admin.ModelAdmin):
pass

admin.site.register(Candidate, CandidateAdmin)
admin.site.register(Question, QuestionAdmin)
admin.site.register(AnswerSheet, AnswerSheetAdmin)
admin.site.register(AnswerText, AnswerTextAdmin)
Binary file added vaa/questions/admin.pyc
Binary file not shown.
28 changes: 28 additions & 0 deletions vaa/questions/admin.py~
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from django.contrib import admin

from .models import Candidate, Question, QuestionText, AnswerSheet


class QuestionTextInline(admin.TabularInline):
model = QuestionText


class AnswerSheetInline(admin.TabularInline):
model = AnswerSheet


class CandidateAdmin(admin.ModelAdmin):
inlines = [AnswerSheetInline,]


class QuestionAdmin(admin.ModelAdmin):
inlines = [QuestionTextInline,]


class AnswerSheetAdmin(admin.ModelAdmin):
pass


admin.site.register(Candidate, CandidateAdmin)
admin.site.register(Question, QuestionAdmin)
admin.site.register(AnswerSheet, AnswerSheetAdmin)
Loading

0 comments on commit d6c0b48

Please sign in to comment.