Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ngokevin/reggit
Browse files Browse the repository at this point in the history
  • Loading branch information
thedjpetersen committed Jun 15, 2011
2 parents 52ab889 + 969828d commit 50a0f41
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
6 changes: 5 additions & 1 deletion course/templates/course/show.html
Expand Up @@ -56,7 +56,11 @@ <h4>{{courses.0.description}}</h4>
<td>{{course.cap}}</td> <td>{{course.cap}}</td>
<td>{{course.wl_available}}</td> <td>{{course.wl_available}}</td>
<td>{{course.restrictions}}</td> <td>{{course.restrictions}}</td>
<td><input type="checkbox" name="choose" value={{course.crn}}></td> {% if not course.conflict %}
<td><input type="checkbox" name="choose" value={{course.crn}}></td>
{% else %}
<td>Time conflict with {{course.conflict}}</td>
{% endif %}
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
Expand Down
20 changes: 19 additions & 1 deletion course/views.py
Expand Up @@ -44,6 +44,7 @@ def show(request, department, number, status=''):
raise Http404 raise Http404


if request.method == 'GET': if request.method == 'GET':
find_time_conflicts(regclass, courses)
return render_to_response('course/show.html', {'courses':courses, 'regerror': regerror}) return render_to_response('course/show.html', {'courses':courses, 'regerror': regerror})


# user sumbitted crns to register for courses, use urls to redirect to register view # user sumbitted crns to register for courses, use urls to redirect to register view
Expand All @@ -53,7 +54,6 @@ def show(request, department, number, status=''):
else: else:
return HttpResponseRedirect('/course/register/' + crn_list_reg[0] + "&" + crn_list_reg[1]) return HttpResponseRedirect('/course/register/' + crn_list_reg[0] + "&" + crn_list_reg[1])



def register(request, crn1, crn2=""): def register(request, crn1, crn2=""):
""" register via parsing the url and calling the add_class """ """ register via parsing the url and calling the add_class """


Expand All @@ -65,3 +65,21 @@ def register(request, crn1, crn2=""):
return HttpResponseRedirect('/course/' + request.session['prevcourse'] + '?status=error') return HttpResponseRedirect('/course/' + request.session['prevcourse'] + '?status=error')
return HttpResponseRedirect('/course/' + request.session['prevcourse'] + '?status=success') return HttpResponseRedirect('/course/' + request.session['prevcourse'] + '?status=success')


def find_time_conflicts(regclass, courses):
""" given a list of courses, checks current and next schedule for time conflicts """
schedules = [regclass.schedule, regclass.next_schedule]
for schedule in schedules:
for course in courses:
course['conflict'] = None
term = reglib.utilities.utilities.adjust_schedule_term(schedule.current_term)
term = reglib.utilities.utilities.format_term(term)
print term
if course['term'] != term:
continue
else:
for course_sched in schedule.current_classes:
if reglib.utilities.class_search_conflict(course, course_sched):
course['conflict'] = course_sched['department'] + course_sched['number']



0 comments on commit 50a0f41

Please sign in to comment.