Skip to content

Commit

Permalink
added simple question view, to see answers
Browse files Browse the repository at this point in the history
  • Loading branch information
adammck committed May 30, 2009
1 parent 9061fea commit ecdc7ed
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 14 deletions.
1 change: 1 addition & 0 deletions apps/questions/templates/questions/base.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends "layout.html" %}

{% block stylesheets %}<link type="text/css" rel="stylesheet" href="/static/questions/stylesheets/questions.css" />{% endblock %}
{% block title %}Questions{% endblock %}

{% block page_tabs %}
Expand Down
37 changes: 37 additions & 0 deletions apps/questions/templates/questions/question.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{% extends "questions/base.html" %}
{% load reporters %}

{% block title %}Questions{% endblock %}

{% block content %}
<div class="module">
<h2>Answers Received to {{ question }}</h2>
<table>
<thead>
<tr>
<th>Raw Answer</th>
<th>Normalized Answer</th>
<th>Reporter</th>
<th>Location</th>
<th>Date/time</th>
</tr>
</thead>
<tbody>{% for answer in answers %}
<tr>
<td>{{ answer.raw_text }}</td>
<td>{{ answer.normalized }}</td>{% if answer.submission.reporter %}
<td><a href="/reporters/{{ answer.submission.reporter.pk }}"{% if answer.submission.reporter.full_name %}>{{ answer.submission.reporter.full_name }}{% else %} class="unknown">Unknown{% endif %}</a></td>{% else %}
<td><span class="connection">{{ answer.submission.connection }}</span></td>{% endif %}
<td>{{ answer.submission.location }}</td>
<td>{{ answer.submission.submitted|last_seen }}</td>
</tr>{% endfor %}
</tbody>
<tfoot>
<td colspan="6">
<a href="/questions/{{ question.pk }}/export/xls">Export to Excel</a>
<span>{{ answers|length }} Answers</span>
</td>
</tfoot>
</table>
</div>
{% endblock %}
5 changes: 1 addition & 4 deletions apps/questions/templates/questions/section.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{% extends "questions/base.html" %}
{% load reporters %}

{% block stylesheets %}<link type="text/css" rel="stylesheet" href="/static/questions/stylesheets/questions.css" />{% endblock %}
{% block javascripts %}<script type="text/javascript" src="/static/webui/javascripts/jquery.flot.js"></script>{% endblock %}

{% block title %}Questions{% endblock %}

{% block content %}{% if questions %}
Expand All @@ -30,7 +27,7 @@ <h2>All Questions in the <strong>{{ section.title }}</strong> Section</h2>
<tbody>{% for question in questions %}
<tr>
<td>{{ question.number }}</td>
<td class="question"><a href="/questions/{{ question.pk }}">{{ question.text }}</a></td>
<td class="question"><a href="{% url view-question section_pk=question.section.pk question_pk=question.pk %}">{{ question.text }}</a></td>
<td>{{ question.num_answers }}</td>
<td>{{ question.answer_percentage }}%</td>{% if question.last_answer %}
<td>
Expand Down
4 changes: 2 additions & 2 deletions apps/questions/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

# view all questions and recent activity
# within a section
url(r'^sections/(?P<pk>\d+)$',
url(r'^sections/(?P<section_pk>\d+)$',
views.section, name="view-section"),

# to view all of the submissions and answers
# linked to a question, with lightweight graphs
url(r'^sections/(?P<section_pk>\d?)/questions/(?P<question_pk>\d+)/view$',
url(r'^sections/(?P<section_pk>\d?)/questions/(?P<question_pk>\d+)$',
views.question, name="view-question")
)
24 changes: 16 additions & 8 deletions apps/questions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,29 @@ def dashboard(req):


@require_GET
def section(req, pk):
sect = get_object_or_404(Section, pk=pk)
def section(req, section_pk):
sect = get_object_or_404(
Section, pk=section_pk)

return render_to_response(req,
"questions/section.html", {
"active_section_tab": sect.pk,

"questions": sect.questions.all(),
"section": sect })
"active_section_tab": sect.pk,
"questions": sect.questions.all(),
"section": sect })


@require_GET
def question(req):
def question(req, section_pk, question_pk):
sect = get_object_or_404(Section, pk=section_pk)
ques = get_object_or_404(Question, pk=question_pk)

return render_to_response(req,
"questions/question.html")
"questions/question.html", {
"active_section_tab": sect.pk,
"answers": ques.answers.all(),
"question": ques,
"section": sect })



Expand Down

0 comments on commit ecdc7ed

Please sign in to comment.