Skip to content

Loading…

Issue #33: Add search by major feature to the resume list page #44

Merged
merged 1 commit into from

1 participant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 9 additions and 5 deletions.
  1. BIN db.sqlite3
  2. +2 −2 info/templates/resume_list.html
  3. +7 −3 info/views.py
View
BIN db.sqlite3
Binary file not shown.
View
4 info/templates/resume_list.html
@@ -17,12 +17,12 @@ <h1 class="page-header">Resumes</h1>
<form method='GET' name='submit'>
<div class='row'>
-<!-- <div class='col-sm-2'>
+ <div class='col-sm-2'>
Majors: <br />
{% for major in majors %}
<input type='checkbox' name='major' value='{{ major.majorName }}'>{{ major.majorName }}<br />
{% endfor %}
- </div> -->
+ </div>
<div class='col-sm-2'>
Graduation Years: <br />
{% for year in years %}
View
10 info/views.py
@@ -87,10 +87,14 @@ def resumes(request):
for i in xrange(5):
years.append(year+i)
grad_year_requests = request.GET.getlist('gradyear')
- reqs = Q()
+ major_requests = request.GET.getlist('major')
+ grad_year_reqs = Q()
for grad_year_request in grad_year_requests:
- reqs = reqs | Q(graduationYear=int(grad_year_request))
- brothers = Brother.objects.filter(reqs).order_by('lastName', 'firstName', 'middleName')
+ grad_year_reqs = grad_year_reqs | Q(graduationYear=int(grad_year_request))
+ major_reqs = Q()
+ for major_request in major_requests:
+ major_reqs = major_reqs | Q(majors__majorName=major_request)
+ brothers = Brother.objects.filter(major_reqs, grad_year_reqs).order_by('lastName', 'firstName', 'middleName')
majors = Major.objects.all().order_by('majorName')
c = Context({'brothers': brothers, 'majors': majors, 'years': years})
t = loader.get_template('resume_list.html')
Something went wrong with that request. Please try again.