Commit 22000642 authored by Ben Waters's avatar Ben Waters
Browse files

changed models, views are now class based, added mixins and autoslug to requirements

parent 07d4418a
...@@ -145,6 +145,7 @@ class Trajectory(TimeStampedModel): ...@@ -145,6 +145,7 @@ class Trajectory(TimeStampedModel):
name = models.CharField(max_length = 150) name = models.CharField(max_length = 150)
slug = AutoSlugField(populate_from='name',unique=True) slug = AutoSlugField(populate_from='name',unique=True)
owner = models.ForeignKey(User)
# Takes courses # Takes courses
previousCourses = models.ManyToManyField('Trajectory',) previousCourses = models.ManyToManyField('Trajectory',)
......
from django.shortcuts import render, get_object_or_404 from django.shortcuts import render, get_object_or_404
from trajectories.models import Course, CourseCollection, Program, Student, Trajectory
from django.db.models import Max from django.db.models import Max
from trajectories.models import Course, CourseCollection, Program, Student, Trajectory
from trajecgtories.utils import *
from braces.views import LoginRequiredMixin
# processing functions # processing functions
# run on each coursecollection # run on each coursecollection
...@@ -122,68 +125,45 @@ def enoughCourses(coursesTaken, degreeCreditsReqNum): ...@@ -122,68 +125,45 @@ def enoughCourses(coursesTaken, degreeCreditsReqNum):
# a page for creating new trajectories # a page for creating new trajectories
# @login_required # @login_required
def new(request): def create_trajectory(LoginRequiredMixin, CreateView):
programs = Program.objects.all() model = Trajectory
courses = Course.objects.all() form = CreateTrajectoryForm
# select year
return render(request, 'new.html', {
'programs' : programs,
},
)
# student selects the classes for their trajectories #programs = Program.objects.all()
# @login_required #courses = Course.objects.all()
# def create(request, slug): slug is the user's # select year
def create(request):
# programs = theProgramThatWasJustSelected
return render(request, 'create.html', { # "Build"
def update_trajectory(LoginRequiredMixin, UpdateView):
}, model = Trajectory
) form = UpdateTrajectoryForm
# student's page; shows saved trajectories # student's page; shows saved trajectories
# @login_required # @login_required
def student(request, slug):
student = get_object_or_404(Student, user__username=username) def detail_student(LoginRequiredMixin, DetailView):
model = Student
trajectories = Trajectory.objects.filter(student__user__username=username) trajectories = Trajectory.objects.filter(student__user__username=username)
topTrajectories = topTrajectories(trajectories) topTrajectories = topTrajectories(trajectories)
return render(request, 'student.html', {
'student' : student,
'topTrajectories' : topTrajectories,
},
)
# simply displays a page for the course # simply displays a page for the course
def course(request, slug): def detail_course(DetailView):
course = get_object_or_404(Course, slug=slug) #courseSlug model = Course
return render(request, 'course.html', {
'course' : course,
},
)
# simply returns a page showing a program # simply returns a page showing a program
# @login_required # @login_required
def program (request): def detail_program(DetailView):
program = get_object_or_404(Program, slug=slug) #programSlug model = Program
return render(request, 'program.html', { def detail_trajectory(LoginRequiredMixin, DetailView):
'program' : program, model = Trajectory
},
) def list_trajectory(LoginRequiredMixin, ListView):
model = Trajectory
def list_program(ListView):
model = Program
# simply displays a page for an individual trajectory, (along with edit links) # simply displays a page for an individual trajectory, (along with edit links)
# @login_required # @login_required
def trajectory(request, slug):
# actually needs more than one slug, the one for the user # actually needs more than one slug, the one for the user
trajectory = get_object_or_404(Trajectory, slug=slug) #trajectorySlug
return render(request, 'trajectory.html', {
'trajectory' : trajectory,
},
)
...@@ -5,6 +5,7 @@ argparse==1.2.1 ...@@ -5,6 +5,7 @@ argparse==1.2.1
django-appconf==0.6 django-appconf==0.6
django-auth-ldap==1.1.7 django-auth-ldap==1.1.7
django-autoslug==1.7.2 django-autoslug==1.7.2
django-braces==1.3.1
django-dynamic-forms==0.2 django-dynamic-forms==0.2
django-guardian==1.1.1 django-guardian==1.1.1
django-model-utils==2.0 django-model-utils==2.0
......
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