Commit b2583ec1 authored by Ben Waters's avatar Ben Waters

merge index fix

parents 3b66207b b118a28f
......@@ -56,3 +56,4 @@ docs/_build/
# Database
advisor/db.sqlite3
advisor/whoosh_index/
......@@ -41,6 +41,7 @@ INSTALLED_APPS = (
'south',
'django_gravatar',
'autocomplete_light',
'haystack',
)
MIDDLEWARE_CLASSES = (
......@@ -125,3 +126,11 @@ SWAGGER_SETTINGS = {
LOGIN_URL = '/login/'
LOGOUT_URL = '/logout/'
LOGIN_REDIRECT_URL = '/'
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'),
},
}
from django.shortcuts import render
from django.shortcuts import render_to_response
# Create your views here.
from django.contrib.auth.decorators import login_required
from mainapp.models import (Trajectory, Course)
#@login_required
def compare(request):
trajectories = Trajectory.objects.all()
return render_to_response('compare.html', {
'trajectories' : trajectories,
})
#@login_required
def analytics(request):
trajectories = Trajectory.objects.all()
return render_to_response('analytics.html', {
'trajectories' : trajectories,
})
......@@ -5,7 +5,7 @@ from mainapp.models import *
class StudentAdmin(admin.ModelAdmin):
pass
filter_horizontal = ('programs', 'coursestaken',)
class CourseAdmin(admin.ModelAdmin):
......
......@@ -69,11 +69,13 @@ class Minor(Program):
class GenEd(Program):
pass
class Meta:
verbose_name = "General Education Requirements"
class Concentration(Program):
associatedmajors = models.ForeignKey(Major, null=True)
associatedmajors = models.ForeignKey(Major, null=True,
verbose_name="Associated Major")
class Requirement(TimeStampedModel):
......
from haystack import indexes
from django.utils import timezone # reqired for when the indexes were last updated
from mainapp.models import Course, Major, Minor
class CourseIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField( document = True, use_template = True)
#title = indexes.CharField( model_attr = "title" )
catalogyear = indexes.CharField( model_attr = "catalogyear" )
#description = indexes.CharField( model_attr = "description" )
#dept = indexes.CharField( model_attr = "dept" )
#courseid = indexes.CharField( model_attr = "courseid" )
credits = indexes.CharField( model_attr = "credits" )
def get_model(self):
return Course
def index_queryset(self, using=None):
return self.get_model().objects.all()
class MajorIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document = True, use_template = True)
#name = indexes.CharField(model_attr = "name")
#description = indexes.CharField(model_attr = "description")
def get_model(self):
return Major
def index_queryset(self, using=None):
return self.get_model().objects.all()
class MinorIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document = True, use_template = True)
#name = indexes.CharField(model_attr = "name")
#description = indexes.CharField(model_attr = "description")
def get_model(self):
return Minor
def index_queryset(self, using=None):
return self.get_model().objects.all()
......@@ -5,5 +5,5 @@
{% endblock %}
{% block content %}
<h1>No no the template from the other app! Fix said views and urls.</h1>
{% endblock %}
{% extends 'layouts/base.html' %}
{% block title %}
New | MySchool Advisor
{% endblock %}
{% block content %}
<div class="page-header" id="banner">
<div class="row">
<div class="col-md-12 text-center">
<h1><strong>New Trajectory</strong></h1>
<p class="lead">Pick the programs you'd like to visualize completing your degree.</p>
</div>
</div>
</div>
<div class="row">
<div class="col-md-offset-1 col-md-10 well">
<form class="form-horizontal" action="" method="post" role="form" enctype="multipart/form-data">
{% csrf_token %}
<fieldset>
<legend>Select your program(s).</legend>
<div class="form-group{% if starttrajectoryform.name.errors %} has-error {% endif %}">
<label for "{{ starttrajectoryform.name.id_for_label}}" class="col-sm-2">
{{ starttrajectoryform.name.id_for_label }}</label>
<div class="col-sm-8">
{{ starttrajectoryform.name }}
{% for error in starttrajectoryform.name.errors %}
<span class="help-block">{{ error }}</span>
{% endfor %}
<!-- autocompletion would be awesome -->
</div>
<div class="col-sm-offset-1 col-sm-1">
<button type="button" class="btn btn-primary">+</button>
</div>
</div>
<!-- Javascript for adding an additional field -->
<!-- Ensure no more than two majors -->
<legend>Select your minor(s).</legend>
<div class="form-group{% if starttrajectoryform.name.errors %} has-error {% endif %}">
<label for "{{ starttrajectoryform.name.id_for_label }}" class="col-sm-2">
{{ starttrajectoryform.name.id_for_label }}</label>
<div class="col-sm-8">
{{ starttrajectoryform.name }}
{% for error in starttrajectoryform.name.errors %}
<span class="help-block">{{ error }}</span>
{% endfor %}
<!-- autocompletion would be awesome -->
</div>
<div class="col-sm-offset-1 col-sm-1">
<button type="button" class="btn btn-primary">+</button>
</div>
</div>
<!-- Javascript for adding an additional field -->
<!-- ensure no more than three minors -->
<div class="form-group">
<div class="col-sm-offset-10 col-sm-2">
<button type="submit" class="btn btn-primary btn-block" value="Submit">Submit</button>
<!-- find the bar across the top loading js -->
</div>
</div>
</fieldset>
</form>
</div>
</div>
{% endblock %}
......@@ -23,9 +23,11 @@ urlpatterns = patterns('',
url(r'^build/', build_trajectory, name='build'),
url(r'^new/', StartTrajectoryView.as_view(), name='new-trac'),
url(r'^compare/', compare, name='compare'),
url(r'^search/', search, name='search'),
#url(r'^student/(?P<slug>[^/]+)/$', DetailStudent.as_view(),
#name='detail-student'),
url(r'^profile/', profile, name='profile-detail'),
#name='profile'),
url(r'^search/', include('haystack.urls')),
)
......@@ -4,14 +4,14 @@ from mainapp.models import Course # import more
def programCourses(program):
programCourses = []
courses = []
requirements = program.requirements
for requirement in requirements:
for coursegroup in requirement.coursegroup:
for course in coursegroup.courses:
programCourses.append(course)
courses.append(course)
return programCourses
return courses
### creating a trajectory
......@@ -23,7 +23,7 @@ def programCourses(program):
def assignedWeights(weightedCourse, programCourses):
""" assign weights to all courses in a program for automation """
assignedWeights = {}
weights = {}
for weightedCourse in programCourses:
weightedCourseCounter = 0
......@@ -39,63 +39,63 @@ def assignedWeights(weightedCourse, programCourses):
weightedCourseCounter += 1
childReqList.append(course)
assignedWeights(course, childReqList)
assignedWeights[weighedCourse] = coursecounter
return assignWeights
def customAssignedWeights(assignedWeights, selectedCourses):
weights[weightedCourse] = weightedCourseCounter
return weights
def customAssignedWeights(weights, selectedCourses):
""" remove courses that a student has not selected from the weighted
courses """
customAssignedWeights = assignedWeights
customweights = weights
for course in selectedCourses:
del customAssignedWeights[course]
del customweights[course]
return customAssignedWeights
return customweights
def shortestPath(assignedWeights):
def shortestPath(weights):
return True
### editing a trajectory
def requirementsFulfilled(alreadyTaken, program):
def requirementsFulfilled(taken, program):
""" for *A* program, return a list of all requirements fulfilled """
requirementsFulfilled = []
alreadyTaken = set(alreadyTaken)
fulfilled = []
taken = set(taken)
requirements = program.requirements
for requirement in requirements:
for coursegroup in requirement.coursegroup:
courseRequirements = set(coursegroup.courses)
requirementCoursesTaken = intersection(courseRequirements, alreadyTaken)
requirementCoursesTaken = courseRequirements.intersection(alreadyTaken)
if len(requirementCoursesTaken) is requirement.coursegroup.numneeded:
requirementsFulfilled.append(requirement)
fulfilled.append(requirement)
return requirementsFulfilled
return fulfilled
#def alreadyTaken():
# """ return all of the courses that a student has already taken so far
# in the trajectory """
# return True
def remainingReqCourses(alreadyTaken, program):
def remainingReqCourses(taken, program):
""" returns the remaining required courses for a program given
the already taken courses """
alreadyTaken = set(alreadyTaken)
programCourses = set( programCourses(program) )
taken = set(taken)
courses = set(programCourses(program))
remainingReqCourses = intersection(alreadyTaken, programCourses)
remainingReqCourses = taken.intersection(courses)
return remainingReqCourses
def nextCourses(remainingReqCourses, alreadyTaken):
def nextCourses(remainingReqCourses, taken):
""" which courses you can take next based on prereqs and coreqs, given
already taken courses and remaining required courses """
nextCourses = []
nextcourses = []
for course in remainingReqCourses:
reqs = set()
for prereq in course.preq:
......@@ -103,8 +103,8 @@ def nextCourses(remainingReqCourses, alreadyTaken):
for coreq in course.coreq:
reqs.add(coreq)
for req in reqs:
if req in previousCourses:
nextCourses.append(course)
if req in taken:
nextcourses.append(course)
return nextCourses
......@@ -113,35 +113,34 @@ def nextCourses(remainingReqCourses, alreadyTaken):
# """ the maximum credits allowed for a semester-- returns different values
# to warn or disallow if maximum credits are touched or exceeded """
def findDependancies(deletedCourse, semester):
def findDependencies(deletedCourse, semester):
""" if a student removes a course while editing, find all courses
that have require the removed courses """
foundDependancies = []
foundDependencies = []
for suspectCourse in semester.nextSemester.courses:
reqs = set()
for prereq in suspectCourse.preq:
reqs.add(prereq)
if prereq is deletedCourse:
reqs.append(foundDependencies)
for coreq in suspectCourse.coreq:
reqs.add(coreq)
for req in reqs:
if req is deletedCourse:
req.append(foundDependancies)
if coreq is deletedCourse:
reqs.append(foundDependencies)
findDependancies(deletedCourse, semester.nextSemester)
findDependencies(deletedCourse, semester.nextSemester)
return foundDependancies
return foundDependencies
def enoughCredits(previousCourses, numRequired):
""" checks if enough credits have been taken to graduate """
enoughCredits = False
enoughcredits = False
numTaken = 0
for course in previousCourses:
numTaken += course.credits
if numTaken >= numRequired:
enoughCredits = True
enoughcredits = True
return enoughCredits
return enoughcredits
### student page
......
......@@ -30,6 +30,11 @@ def compare(request):
return render_to_response('compare.html', {
})
# BEN MAKE THIS A CBV OR SOMETHING IDK
def search(request):
return render_to_response('search.html', {
})
#API SHIT
@login_required
def profile(request):
......
......@@ -15,7 +15,6 @@ body {
margin: 0 auto -30px;
/* Pad bottom by footer height */
padding: 0 0 30px;
padding-top: 53px;
}
#icon{
width: 16px;
......
......@@ -22,8 +22,13 @@ YourSchool Advisor
<div class="row">
<div class="col-md-offset-3 col-md-6">
<<<<<<< HEAD
<a href="{% url 'build-trac' %}">
<button type="button" class="btn btn-standard btn-lg btn-block">Create a new Trajectory</button>
=======
<a href="#new">
<button type="button" class="btn btn-primary btn-lg btn-block">Create a new Trajectory</button>
>>>>>>> b118a28f2aa9c22c1957ac03dd7f0badbc5864d6
</a>
</div>
</div>
......
<div class="container">
<p>
A project of <a href="www.gmu.edu">George Mason University's</a> <a href="http://srct.gmu.edu/">Student Run Computing and Technology</a>. Available under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>
A project of <a href="http://www.gmu.edu">George Mason University's</a> <a href="http://srct.gmu.edu/">Student Run Computing and Technology</a>. Available under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>
</p>
</div>
......@@ -11,7 +11,7 @@
<li><a href="{% url 'compare' %}">Compare</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Search</a></li>
<li><a href="{% url 'search' %}">Search</a></li>
{% if user.is_anonymous %}
<li><a href="{% url 'django.contrib.auth.views.login' %}">Log In</a></li>
{% else %}
......
......@@ -44,7 +44,7 @@ Login | YourSchool Advisor
</div>
<div class="form-group">
<div class="col-sm-offset-9 col-sm-3">
<button type="submit" class="btn btn-default btn-block">Sign in</button>
<button type="submit" class="btn btn-primary btn-lg btn-block">Sign in</button>
</div>
</div>
</form>
......
{% extends 'layout/base.html' %}
{% extends 'layouts/base.html' %}
{% load staticfiles %}
{% block title %}
......@@ -11,6 +11,7 @@ Search | YourSchool Advisor
<div class="row">
<div class="col-lg-12 text-center">
<h1>Search</h1>
<p class="lead">Search for... wait what are we indexing?</p>
</div>
</div>
</div>
......
{{ object.title }}
{{ object.description }}
{{ object.courseid }}
{{ object.dept }}
{{ object.title }}
{{ object.description }}
{{ object.title }}
{{ object.description }}
Django==1.6.2
South==0.8.4
Whoosh==2.6.0
argparse==1.2.1
django-appconf==0.6
django-autocomplete-light==1.4.13
......@@ -7,7 +8,6 @@ django-autoslug==1.7.2
django-braces==1.3.1
django-compressor==1.3
django-floppyforms==1.1.1
django-gravatar==0.1.0
django-gravatar2==1.1.3
django-haystack==2.1.0
django-model-utils==2.0.2
......@@ -16,6 +16,7 @@ django-rest-swagger==0.1.13
djangorestframework==2.3.12
djangorestframework-csv==1.3.0
futures==2.1.6
gunicorn==18.0
python-dateutil==2.2
six==1.5.2
wsgiref==0.1.2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment