1
# IVLE - Informatics Virtual Learning Environment
2
# Copyright (C) 2007-2009 The University of Melbourne
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
# Author: Nick Chadwick
21
from ivle.data import ProjectSet, Project, Subject, Semester, Offering
23
from ivle.webapp.base.rest import (XHTMLRESTView, named_operation,
25
from ivle.webapp.errors import NotFound
27
class ProjectSETRESTView(XHTMLRESTView):
28
"""Rest view for a project.
30
Add new, delete, edit functionality is given here."""
31
template = "projectset.html"
33
def __init__(self, req, subject, year, semester, projectset):
34
self.context = req.store.find(Offering,
35
Offering.subject_id == Subject.id,
36
Subject.short_name == unicode(subject),
37
Offering.semester_id == Semester.id,
38
Semester.year == unicode(year),
39
Semester.semester == unicode(semester))
41
if self.context is None:
44
self.projectset = req.store.find(ProjectSet,
45
ProjectSet.offering_id == self.context.id,
46
ProjectSet.id == int(projectset))
48
@require_permission('edit')
49
def PUT(self, req, max_students):
50
"""Add a new ProjectSet"""
51
new_projectset = ProjectSet()
52
new_projectset.max_students = int(max_students)
53
new_projectset.offering = self.context