Skip to content

Commit

Permalink
question numbering in survey response display
Browse files Browse the repository at this point in the history
  • Loading branch information
jessykate committed Dec 9, 2012
1 parent 09cc0c4 commit e88b600
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
8 changes: 8 additions & 0 deletions media/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,11 @@ label {
height: 50px;
}

ol.survey-questions {
margin-left: 0px;
}

.q-item {
margin-left: 60px;
}

Empty file added survey/templatetags/__init__.py
Empty file.
16 changes: 16 additions & 0 deletions survey/templatetags/survey_extras.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from django import template

register = template.Library()

class CounterNode(template.Node):

def __init__(self):
self.count = 0

def render(self, context):
self.count += 1
return self.count

@register.tag
def counter(parser, token):
return CounterNode()
5 changes: 5 additions & 0 deletions templates/survey.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% extends 'base.html' %}
{% load survey_extras %}

{% block body %}

Expand Down Expand Up @@ -50,11 +51,13 @@ <h3 class="collapsible" id="response_metadata">Response Metadata<span></span></h
</div>
</div>

<ol class="survey-questions">
{% for category in categories %}
<h3 class="collapsible">{{category|title}} Questions<span></span></h3>
<div class="category-container">
{% for field in response_form %}
{% if field.field.widget.attrs.category == category %}
<li class="q-item" value="{% counter %}">
{% if field.field.required %}
<div class="field-wrapper question-required">
{{ field.errors }}
Expand All @@ -69,10 +72,12 @@ <h3 class="collapsible">{{category|title}} Questions<span></span></h3>
{{ field }}
</div>
</div>
</li>
{% endif %}
{% endfor %}
</div>
{% endfor %}
</ol>

<div class="submit-button"><input type="submit" value="I'm done!"></div>
</form>
Expand Down

0 comments on commit e88b600

Please sign in to comment.