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

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
</a>
</div>
......@@ -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>.
</div>
</div>
</div>
......@@ -200,4 +200,52 @@ Homepage
</div>
</div>
<!-- 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"
aria-hidden="true">&times;</button>
<h4 class="modal-title" id="CourseSelectorLabel">Course Filter
Selector</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label class="col-lg-3 control-label"
for="{{form.section.id_for_label}}">
Course Section
</label>
<div class="col-lg-9">
{{ form.section }}
</div>
<div class="help-block col-lg-9 col-lg-offset-3">
Enter the course section you'd like to filter by.
</div>
</div>
</div>
<div class="modal-footer">
<a class="btn btn-default btn-sm" data-dismiss="modal" href="#">
Cancel
</a>
<input type="submit" class="btn btn-primary btn-sm"
value="Filter by Course" name="filter">
</div>
</form>
</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):
@login_required
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 )
else:
return redirect( '/' )
else:
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