Commit 88339853 authored by Daniel W Bond's avatar Daniel W Bond
Browse files

added getting objects and such to the views

parent 5684c5d9
......@@ -59,6 +59,7 @@ class CourseCollection(BaseModel):
class Program(BaseModel):
name = models.CharField(max_length = 150)
# slug = models.SlugField(max_length = 50, unique = True)
# courseCollections
courseReqs = models.ManyToManyField('CourseCollection',)
......@@ -77,6 +78,9 @@ class Program(BaseModel):
def __unicode__(self):
return self.name
# def get_absolute_url(self):
# return 'my-trajectories/%s/' % self.slug
# should inherit from the standard Django User Model
class Student(models.Model):
......@@ -113,10 +117,12 @@ class Trajectory(BaseModel):
# Takes courses
previousCourses = models.ManyToManyField('Trajectory',)
# def getPreviousTrajectory(Trajectory):
# return Trajectory
isPublic = models.BooleanField()
# this isn't exactly done correctly-- ideally courses should be elements
# of a list, not one created for each and every semester
# semesters since entering college
semester = models.IntegerField()
class Meta:
......
from django.shortcuts import render, render_to_response
from django.shortcuts import render, render_to_response, get_object_or_404
from trajectories.models import Course, CourseCollection, Program, Student, Trajectory
from django.db.models import Max
......@@ -108,15 +108,6 @@ def enoughCourses(coursesTaken):
# page render functions
# "homepage", create a new trajectory
#@login_required
def index(request):
return render(request, 'index.html', {
},
)
# this is where all users not signed in are redirected
def login(request):
......@@ -125,57 +116,38 @@ def login(request):
},
)
# SRCT, how to contribute information, how Advisor works
def about(request):
# "homepage", create a new trajectory
#@login_required
def index(request):
return render(request, 'about.html', {
return render(request, 'index.html', {
},
)
# student selects the classes for their trajectories
# @login_required
# def create(request, slug):
# def create(request, slug): slug is the user's
def create(request):
# needs to get list of programs from user
programs = []
#
return render(request, 'create.html', {
},
)
# simply displays a page for the course
def course(request, slug):
return render(request, 'course.html', {
},
)
# simply displays a page for a trajectory, (along with edit links)
# @login_required
def trajectory(request, slug):
# actually needs more than one slug
return render(request, 'trajectory.html', {
},
)
# student's page; shows saved trajectories
# @login_required
def student(request, slug):
student = get_object_or_404(Student, user__username=username)
trajectories = Trajectory.objects.filter(student__user__username=username)
topTrajectories = topTrajectories(trajectories)
return render(request, 'student.html', {
'student' : student,
'topTrajectories' : topTrajectories,
'student' : student,
'topTrajectories' : topTrajectories,
},
)
......@@ -185,11 +157,54 @@ def student(request, slug):
# def compare(request, slug):
def compare(request):
# this is gonna be hella slow; I need to learn how ajax works and what
# it will actually need
trajectories = Trajectory.objects.all()
return render(request, 'compare.html', {
'trajectories' : trajectories,
},
)
# simply displays a page for the course
def course(request, slug):
course = get_object_or_404(Course, slug=slug)
return render(request, 'course.html', {
'course' : course,
},
)
# page like one for courses, except for programs? >_>
# simply returns a page showing a program
# def program (request, slug):
# program = get_object_or_404(Program, slug=slug)
# return render(request, 'program.html, {
# 'program' : program,
# },
# )
# simply displays a page for an individual trajectory, (along with edit links)
# @login_required
def trajectory(request, slug):
# actually needs more than one slug, the one for the user
trajectory = get_object_or_404(Trajectory, slug=slug)
return render(request, 'trajectory.html', {
'trajectory' : trajectory,
},
)
# search
# # # # # STATIC PAGES # # # # #
# SRCT, how to contribute information, how Advisor works
def about(request):
return render(request, 'about.html', {
},
)
# search for courses or programs view
# def privacy(request):
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