Commit 2c96a55a authored by Jean Michel Rouly's avatar Jean Michel Rouly
Browse files

Added modal popup and course seciton input form procsesor

parent 1b308289
......@@ -21,7 +21,7 @@ Homepage
<div class="row">
<div class="col-sm-4">
<a href="{% url 'filter_by_section' 'cat100' %}">
<a href="#" data-toggle="modal" data-target="#CourseSelector">
Filter by Section
......@@ -48,7 +48,7 @@ Homepage
<div class="col-lg-10 col-lg-offset-1">
<div class="alert alert-dismissable alert-info text-center">
<button type="button" class="close" data-dismiss="alert">&times;</button>
Filtering questions on section <strong>{{ filter }}</strong>.
<strong>Filtering questions on section {{ filter }}</strong>.
......@@ -200,4 +200,52 @@ Homepage
<!-- Delete Lookout Modal -->
<div class="modal fade" id="CourseSelector" tabindex="-1" role="dialog"
aria-labelledby="CourseSelectorLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form class="form-horizontal" id="CourseSelectorForm" method="post"
action="" role="form">
{% csrf_token %}
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
<h4 class="modal-title" id="CourseSelectorLabel">Course Filter
<div class="modal-body">
<div class="form-group">
<label class="col-lg-3 control-label"
Course Section
<div class="col-lg-9">
{{ form.section }}
<div class="help-block col-lg-9 col-lg-offset-3">
Enter the course section you'd like to filter by.
<div class="modal-footer">
<a class="btn btn-default btn-sm" data-dismiss="modal" href="#">
<input type="submit" class="btn btn-primary btn-sm"
value="Filter by Course" name="filter">
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
{% endblock %}
from website.models import Question, Comment, Reply
from website.forms import QuestionForm, CommentForm, ReplyForm, FeedbackForm
from website.forms import CourseSectionFilterForm
from django.conf import settings
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.shortcuts import render_to_response, get_object_or_404
......@@ -47,6 +48,19 @@ def submit_question(request):
def index(request, *args, **kwargs):
if request.method == 'POST':
form = CourseSectionFilterForm( request.POST )
if form.is_valid():
data = form.cleaned_data
section = data.get("section")
return redirect( 'filter_by_section', section = section )
return redirect( '/' )
form = CourseSectionFilterForm()
questions = Question.objects.all()
section = kwargs.get('section')
......@@ -80,6 +94,7 @@ def index(request, *args, **kwargs):
'sort' : sort,
'questions' : questions,
'page_range' : range(1, int(questions.paginator.num_pages)+1),
'form' : form,
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