Commit bfeda3cc authored by Jean Michel Rouly's avatar Jean Michel Rouly
Browse files

Added my_questions review page.

parent 904a45fe
......@@ -14,6 +14,7 @@ urlpatterns = patterns('website.views',
url(r'^feedback$', 'feedback', name='feedback'),
url(r'^$', 'index', name='homepage'),
url(r'^question/(?P<slug>[^\.]+)$', 'view_question', name='view_question'),
url(r'^me$', 'my_questions', name='my_questions'),
#### ADMIN PAGES ####
url(r'^admin/', include(admin.site.urls)),
......
......@@ -11,9 +11,8 @@
</div>
<div class="navbar-collapse collapse" id="navbar-main">
<ul class="nav navbar-nav">
<li>
<a href="/submit">Submit Question</a>
</li>
<li><a href="/submit">Submit Question</a></li>
<li><a href="/me">My Questions</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
......
{% extends 'layouts/base.html' %}
{% block title %}
HNRS 110 &bull; My Questions
{% endblock %}
{% block content %}
<div class="page-header" id="banner">
<div class="row">
<div class="col-lg-10 col-lg-offset-1">
<h1>My Questions</h1>
<p class="lead">Review your submitted questions.</p>
</div>
</div>
</div>
{% if questions %}
{% for question in questions %}
<div class="row">
<div class="col-lg-10 col-lg-offset-1">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
{{question.anonymized}}
<span class="pull-right">
<em>Asked on {{question.date.date}}</em>
</span>
</h3>
</div>
<div class="panel-body">
<p>{{ question.text }}</p>
<a href="{{ question.get_absolute_url }}">
Comments ({{ question.get_comments|length }})
</a>
</div>
</div>
</div>
</div>
{% endfor %}
{% else %}
<div class="row">
<div class="col-lg-10 col-lg-offset-1">
<div class="well well-sm text-center">
No questions have yet been submitted. Why don't you try
<a href="/submit">submitting</a> one yourself!
</div>
</div>
</div>
{% endif %}
<div class="row">
<div class="col-lg-12">
<!--
<div class="text-center">
<ul class="pagination">
{% if questions.has_previous %}
<li>
<a href="?page={{ questions.previous_page_number }}">&laquo;</a>
</li>
{% else %}
<li class="disabled">
<a>&laquo;</a>
</li>
{% endif %}
{% for page in page_range %}
<li{%if page == questions.number%} class="active"{%endif%}>
<a href="?page={{page}}">{{page}}</a>
</li>
{% endfor %}
{% if questions.has_next %}
<li>
<a href="?page={{ questions.next_page_number }}">&raquo;</a>
</li>
{% else %}
<li class="disabled">
<a>&raquo;</a>
</li>
{% endif %}
</ul>
</div>
-->
<ul class="pager">
{% if questions.has_previous %}
<li>
<a href="?page={{ questions.previous_page_number }}">&larr; Previous</a>
</li>
{% else %}
<li class="disabled">
<a>&larr; Previous</a>
</li>
{% endif %}
<li class="pager-middle">
Page {{ questions.number }} of {{ questions.paginator.num_pages }}
</li>
{% if questions.has_next %}
<li>
<a href="?page={{ questions.next_page_number }}">Next &rarr;</a>
</li>
{% else %}
<li class="disabled">
<a>Next &rarr;</a>
</li>
{% endif %}
</ul>
</div>
</div>
{% endblock %}
......@@ -61,6 +61,25 @@ def index(request):
},
)
@login_required
def my_questions(request):
questions = Question.objects.filter(user__id=request.user.id)
paginator = Paginator(questions, 10) # show 25 questions per page
page = request.GET.get('page')
try:
questions = paginator.page(page)
except PageNotAnInteger:
questions = paginator.page(1)
except EmptyPage:
questions = paginator.page(paginator.num_pages)
return render_to_response('my_questions.html', {
'questions' : questions,
'page_range' : range(1, int(questions.paginator.num_pages)+1),
},
)
@login_required
def feedback(request):
if request.method == 'POST':
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment