Permalink
Browse files

Merge branch 'master' of github.com:ngokevin/reggit

  • Loading branch information...
2 parents 52ab889 + 969828d commit 50a0f4180670f67ddcfb9c0eb6afae6deb34eb99 @thedjpetersen committed Jun 15, 2011
Showing with 24 additions and 2 deletions.
  1. +5 −1 course/templates/course/show.html
  2. +19 −1 course/views.py
@@ -56,7 +56,11 @@
<td>{{course.cap}}</td>
<td>{{course.wl_available}}</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>
{% endfor %}
</table>
View
@@ -44,6 +44,7 @@ def show(request, department, number, status=''):
raise Http404
if request.method == 'GET':
+ find_time_conflicts(regclass, courses)
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
@@ -53,7 +54,6 @@ def show(request, department, number, status=''):
else:
return HttpResponseRedirect('/course/register/' + crn_list_reg[0] + "&" + crn_list_reg[1])
-
def register(request, crn1, crn2=""):
""" register via parsing the url and calling the add_class """
@@ -65,3 +65,21 @@ def register(request, crn1, crn2=""):
return HttpResponseRedirect('/course/' + request.session['prevcourse'] + '?status=error')
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.