Skip to content
Browse files

registration implemented on course pages with checkboxes. will need m…

…ore handling such as adding conflicting courses and such. and other stuff
  • Loading branch information...
1 parent e11ff5e commit eda3e5f66bbaadb145e9b605c7f8607cdf35554b @ngokevin ngokevin committed Jun 4, 2011
View
94 course/templates/course/show.html
@@ -3,55 +3,63 @@
{% block content %}
+{% if courses %}
+
<h1>{{courses.0.department|upper}}{{courses.0.number}}</h1><br/>
<h3>{{courses.0.title}}</h3>
<h4>{{courses.0.description}}</h4>
-<table>
- <tr id="table headers">
- <th>Term</th>
- <th>Course</th>
- <th>CRN</th>
- <th>Type</th>
- <th>Credits</th>
- <th>Instructor</th>
- <th>Days</th>
- <th>Time</th>
- <th>Dates</th>
- <th>Location</th>
- <th>Available Spots</th>
- <th>Cap</th>
- <th>Available Waitlist</th>
- <th>Restrictions</th>
- <th>Click to Register</th>
- </tr>
-{% for course in courses %}
- <tr>
- <td>{{course.term}}</td>
- <td>{{course.department}}{{course.number}}</td>
- <td>{{course.crn}}</td>
- <td>{{course.type}}</td>
- <td>{{course.credits}}</td>
- <td>{{course.instructor}}</td>
- <td>
- {% for day in course.days%}
- {{day}}
+<form action="." method="post">
+ <table>
+ <tr id="table headers">
+ <th>Term</th>
+ <th>Course</th>
+ <th>CRN</th>
+ <th>Type</th>
+ <th>Credits</th>
+ <th>Instructor</th>
+ <th>Days</th>
+ <th>Time</th>
+ <th>Dates</th>
+ <th>Location</th>
+ <th>Available Spots</th>
+ <th>Cap</th>
+ <th>Available Waitlist</th>
+ <th>Restrictions</th>
+ <th><input type="submit" name="register" value="Register"></th>
+ </tr>
+ {% for course in courses %}
+ <tr>
+ <td>{{course.term}}</td>
+ <td>{{course.department|upper}}{{course.number}}</td>
+ <td>{{course.crn}}</td>
+ <td>{{course.type}}</td>
+ <td>{{course.credits}}</td>
+ <td>{{course.instructor}}</td>
+ <td>
+ {% for day in course.days%}
+ {{day}}
+ {% endfor %}
+ </td>
+ <td>
+ {{course.times.0}} - {{course.times.1}}
+ </td>
+ <td>{{course.duration}}</td>
+ <td>{{course.location}}</td>
+ <td>{{course.available}}</td>
+ <td>{{course.cap}}</td>
+ <td>{{course.wl_available}}</td>
+ <td>{{course.restrictions}}</td>
+ <td><input type="checkbox" name="choose" value={{course.crn}}></td>
+ </tr>
{% endfor %}
- </td>
- <td>
- {{course.times.0}} - {{course.times.1}}
- </td>
- <td>{{course.duration}}</td>
- <td>{{course.location}}</td>
- <td>{{course.available}}</td>
- <td>{{course.cap}}</td>
- <td>{{course.wl_available}}</td>
- <td>{{course.restrictions}}</td>
- <td><a href="/register/{{course.crn}}"><button>Register</button></a></td>
- </tr>
- {% endfor %}
-</table>
+ </table>
+</form>
<h6><a href="http://catalog.oregonstate.edu/CourseDetail.aspx?Columns=abcdefghijklmnopqrstuvwxyz&SubjectCode={{department}}&CourseNumber={{course_number}}&Campus=corvallis">Class Catalog Entry</a></h6>
+{% else %}
+ <h1>The course you seek is in another castle</h1>
+{% endif %}
+
{% endblock %}
View
7 course/urls.py
@@ -4,7 +4,8 @@
urlpatterns = patterns('course.views',
(r'^$', 'index'),
- (r'^(?P<department>\w\w)(?P<number>\d\d\d)/$', 'show'),
- (r'^(?P<department>\w\w\w)(?P<number>\d\d\d)/$', 'show'),
- (r'^(?P<department>\w\w\w\w)(?P<number>\d\d\d)/$', 'show'),
+ (r'^(?P<department>\w+)(?P<number>\d\d\d)/$', 'show'),
+ (r'^(?P<department>\w+)(?P<number>\d\d\d)\?status=(?P<status>.*)/$', 'show'),
+ (r'^register/(?P<crn1>\d+)/$', 'register'),
+ (r'^register/(?P<crn1>\d+)\&(?P<crn2>\d+)/$', 'register'),
)
View
36 course/views.py
@@ -5,6 +5,7 @@
import reglib
def index(request):
+ """ main course page that contains a search bar """
if not 'regclass' in request.session:
return HttpResponseRedirect('/')
@@ -13,6 +14,7 @@ def index(request):
if request.method == 'GET':
return render_to_response('course/index.html')
+ # Search form for jumping to a course info page (show)
course = request.POST['course']
course = reglib.utilities.utilities.format_course(course)
course_dict = reglib.utilities.utilities.course_to_dep_and_num(course)
@@ -25,13 +27,39 @@ def index(request):
return render_to_response('course/show.html', {'courses': courses})
-
-def show(request, department, number):
+def show(request, department, number, status=''):
+ """ shows information about single course and can register from here """
regclass = request.session['regclass']
+ regerror = 0
+ if status == "error":
+ regerror = 1
+
+ # to come back when redirecting to a different view func
+ request.session['department'] = department
+ request.session['number'] = number
+
courses = regclass.class_search(department, number)
if courses is None:
raise Http404
+
+ if request.method == 'GET':
+ 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
+ crn_list_reg = request.POST.getlist('choose')
+ if len(crn_list_reg) is 1:
+ return HttpResponseRedirect('/course/register/' + crn_list_reg[0])
+ 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 """
+ regclass = request.session['regclass']
+
+ error = regclass.add_class(crn1, crn2)
- return render_to_response('course/show.html', {'courses': courses})
-
+ if error:
+ return HttpResponseRedirect('/course/' + request.session['department'] + request.session['number'] + '?status=error')
+ return HttpResponseRedirect('/course/' + request.session['department'] + request.session['number'] + '?status=success')
+
View
2 main/templates/planner/index.html
@@ -13,7 +13,7 @@
</tr>
{% for course in required_courses %}
<tr>
- <td><a href="/course/{{course.Disc}}{{course.Num}}">{{course.Disc}}{{course.Num}}</a></td>
+ <td><a href="/course/{{course.Disc}}{{course.Num}}">{{course.Disc}} {{course.Num}}</a></td>
<td>{{course.Title}}</td>
<td>{{course.Credits}}</td>
</tr>
View
8 transcript/templates/transcript/index.html
@@ -24,18 +24,16 @@
<table>
<tr id="table headers">
<th>Term</th>
- <th>Department</th>
- <th>Course Number</th>
+ <th>Course</th>
<th>Course Title</th>
<th>Credits</th>
<th>Grade</th>
</tr>
{% for course in transcript %}
<tr>
<td>{{course.term}}</td>
- <td>{{course.department}}</td>
- <td>{{course.number}}</td>
- <td><a href="/course/{{course.department}}{{course.number}}">{{course.title}}</a></td>
+ <td><a href="/course/{{course.department}}{{course.number}}">{{course.department}}{{course.number}}</td>
+ <td>{{course.title}}</td>
<td>{{course.credits}}</td>
<td>{{course.grade}}</td>
</tr>

0 comments on commit eda3e5f

Please sign in to comment.
Something went wrong with that request. Please try again.