Skip to content
Browse files

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

  • Loading branch information...
2 parents e4a3028 + 1217af1 commit e7b80cfc04bd646cc47e381926e8c75a37ce7206 @thedjpetersen committed Jun 13, 2011
Showing with 198 additions and 1 deletion.
  1. 0 scheduler/__init__.py
  2. +3 −0 scheduler/models.py
  3. +144 −0 scheduler/scheduler/index.html
  4. +16 −0 scheduler/tests.py
  5. +7 −0 scheduler/urls.py
  6. +25 −0 scheduler/views.py
  7. +1 −0 settings.py
  8. +2 −1 urls.py
View
0 scheduler/__init__.py
No changes.
View
3 scheduler/models.py
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
View
144 scheduler/scheduler/index.html
@@ -0,0 +1,144 @@
+{% extends "application.html" %}
+
+{% load utilities %}
+
+{% block content %}
+
+<h1>Scheduler</h1><br/><br/>
+
+<form action="." method="POST">
+ <span>Enter a list of classes separated commas</span><br/>
+
+ <input name="classes" />
+ <select name="term">
+ <option value="F">Fall</option>
+ <option value="W">Winter</option>
+ <option value="Sp">Spring</option>
+ <option value="Su">Summer</option>
+ </select>
+ <select name="year">
+ <option value="11">2011</option>
+ <option value="12">2012</option>
+ <option value="13">2013</option>
+ </select>
+ <input type="submit" value="Submit" />
+ <br/>
+</form>
+
+{% if combinations %}
+
+{% block header %}
+ <link rel="stylesheet" type="text/css" href="/site_media/stylesheets/make_schedule.css" />
+ <script type="text/javascript" src="/site_media/javascripts/jquery-min.js" ></script>
+ <script>
+ combinations = {{json|safe}}
+ </script>
+
+ <script type="text/javascript" src="/site_media/javascripts/make_schedule.js" ></script>
+{% endblock %}
+<div class="span-24 last">
+ <div class="span-18">
+ <table>
+ <tr id="headers">
+ <th>Hour</th>
+ <th>Monday</th>
+ <th>Tuesday</th>
+ <th>Wednesday</th>
+ <th>Thursday</th>
+ <th>Friday</th>
+ <th>Saturday</th>
+ <th>Sunday</th>
+ </tr>
+ {% for hour in range %}
+ <tr id="hour-{{hour}}" class="hours">
+ <td class="Hour">{{hour}}:00</td>
+ <td class="Monday"></td>
+ <td class="Tuesday"></td>
+ <td class="Wednesday"></td>
+ <td class="Thursday"></td>
+ <td class="Friday"></td>
+ <td class="Saturday"></td>
+ <td class="Sunday"></td>
+ </tr>
+ <tr id="hour-{{hour}}-half" class="hours">
+ <td class="Hour">{{hour}}:30</td>
+ <td class="Monday"></td>
+ <td class="Tuesday"></td>
+ <td class="Wednesday"></td>
+ <td class="Thursday"></td>
+ <td class="Friday"></td>
+ <td class="Saturday"></td>
+ <td class="Sunday"></td>
+ </tr>
+ {% endfor %}
+ </table>
+</div>
+<div id="combinations" class="span-6 last">
+ <h5><img alt="Complete combination" src="/site_media/images/check16.png"></img> Complete combination</h5>
+ {% for combination in combinations %}
+ <div id="combination-{{forloop.counter}}" class="combination">
+ <h4>
+ {% ifequal combination|length classes_possible%}
+ <img src="/site_media/images/check16.png" alt="Complete combination"></img>
+ {% endifequal %}
+ Combination {{forloop.counter}}
+ </h4>
+
+ {% for class in combination %}
+ <div class="{{class.crn}} colorbox" style="width:10px; height:10px; display:none"></div>
+ <span>({{class.type}}) {{class.department|upper}} {{class.number}} </span>
+ <span>
+ {% ifnotequal class.times "TBA" %}
+ {{class.days|join:"" }}
+ {{ class.times|join:"-" }}
+ {% endifnotequal %}
+ </span><br/>
+ {% endfor %}
+ <br/>
+ </div>
+ {% endfor %}
+</div>
+<div id="combinations-full" class="span-24 last">
+{% for combination in combinations %}
+ <div id="combinationfull-{{forloop.counter}}" class="combination-full">
+ <h3>
+ {% ifequal combination|length classes_possible%}
+ <img src="/site_media/images/check16.png" alt="Complete combination"></img>
+ {% endifequal %}
+ Combination {{forloop.counter}}
+ </h4>
+ <table>
+ <tr>
+ <th>Class</th>
+ <th>Title</th>
+ <th>Type</th>
+ <th>Instructor</th>
+ <th>Days</th>
+ <th>Time</th>
+ <th>CRN</th>
+ </tr>
+ {% for course in combination %}
+ <tr>
+ <td><a href="/course/{{course.department|upper}}{{course.number}}">{{course.department|upper}} {{course.number}}</a></td>
+ <td>{{course.title}}</td>
+ <td>{{course.type}}</td>
+ <td>{{course.instructor}}</td>
+ <td>{{course.days|join:"" }}</td>
+ {% ifnotequal course.times "TBA" %}
+ <td>{{course.times|join:"-" }}</td>
+ {% else %}
+ <td>TBA</td>
+ {% endifnotequal %}
+ <td>{{course.crn}}</td>
+ </tr>
+ {% endfor %}
+
+ </table>
+ <br/>
+ </div>
+ {% endfor %}
+</div>
+
+{% endif %}
+
+{% endblock %}
View
16 scheduler/tests.py
@@ -0,0 +1,16 @@
+"""
+This file demonstrates writing tests using the unittest module. These will pass
+when you run "manage.py test".
+
+Replace this with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+
+class SimpleTest(TestCase):
+ def test_basic_addition(self):
+ """
+ Tests that 1 + 1 always equals 2.
+ """
+ self.assertEqual(1 + 1, 2)
View
7 scheduler/urls.py
@@ -0,0 +1,7 @@
+from django.conf.urls.defaults import *
+from reggit import main
+from django.conf import settings
+
+urlpatterns = patterns('scheduler.views',
+ (r'^$', 'index'),
+)
View
25 scheduler/views.py
@@ -0,0 +1,25 @@
+from django.shortcuts import render_to_response
+from django.http import Http404
+import simplejson as json
+from django.http import HttpResponseRedirect
+import reglib
+
+def index(request):
+ if not 'regclass' in request.session:
+ return HttpResponseRedirect('/')
+
+ if request.method == 'GET':
+ return render_to_response('scheduler/index.html')
+ regclass = request.session['regclass']
+ #try:
+ classes = request.POST['classes'].split(', ')
+ term_year = request.POST['term'] + request.POST['year']
+ results = regclass.make_schedule(classes, term_year)
+ combinations = results['combinations']
+ classes_possible = results['classes_possible']
+ combinations_json = json.dumps(combinations)
+ #except:
+ #return render_to_response('scheduler/index.html')
+
+ return render_to_response('scheduler/index.html', {'combinations':combinations, 'json':combinations_json, 'range':range(24), 'classes_possible':classes_possible})
+
View
1 settings.py
@@ -84,4 +84,5 @@
'schedule',
'transcript',
'course',
+ 'scheduler',
)
View
3 urls.py
@@ -11,7 +11,8 @@
(r'^main/$', 'main.views.main'),
(r'^transcript/$', include('transcript.urls')),
(r'^schedule/$', include('schedule.urls')),
- (r'^scheduler/$', 'main.views.scheduler'),
+ (r'^scheduler/$', include('scheduler.urls')),
(r'^course/', include('course.urls')),
(r'^planner/', 'main.views.planner'),
)
+

0 comments on commit e7b80cf

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