Skip to content

Commit

Permalink
scheduler separate app (original files unchanged for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
ngokevin committed Jun 14, 2011
1 parent ae9020f commit 1217af1
Show file tree
Hide file tree
Showing 8 changed files with 198 additions and 1 deletion.
Empty file added scheduler/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions scheduler/models.py
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
144 changes: 144 additions & 0 deletions 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 %}
16 changes: 16 additions & 0 deletions 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)
7 changes: 7 additions & 0 deletions 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'),
)
25 changes: 25 additions & 0 deletions 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})

1 change: 1 addition & 0 deletions settings.py
Expand Up @@ -84,4 +84,5 @@
'schedule',
'transcript',
'course',
'scheduler',
)
3 changes: 2 additions & 1 deletion urls.py
Expand Up @@ -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 1217af1

Please sign in to comment.