1165.2.3
by Nick Chadwick
Added a new Admin view, which allows for the administration of projects |
1 |
# IVLE - Informatics Virtual Learning Environment
|
2 |
# Copyright (C) 2007-2009 The University of Melbourne
|
|
3 |
#
|
|
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.
|
|
8 |
#
|
|
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.
|
|
13 |
#
|
|
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
|
|
17 |
||
18 |
# Author: Nick Chadwick
|
|
19 |
||
20 |
import ivle.database |
|
21 |
from ivle.data import ProjectSet, Project, Subject, Semester, Offering |
|
22 |
||
23 |
from ivle.webapp.base.rest import (XHTMLRESTView, named_operation, |
|
24 |
require_permission) |
|
25 |
from ivle.webapp.errors import NotFound |
|
26 |
||
27 |
class ProjectSETRESTView(XHTMLRESTView): |
|
28 |
"""Rest view for a project.
|
|
29 |
|
|
30 |
Add new, delete, edit functionality is given here."""
|
|
31 |
template = "projectset.html" |
|
32 |
||
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)) |
|
40 |
||
41 |
if self.context is None: |
|
42 |
raise NotFound() |
|
43 |
||
44 |
self.projectset = req.store.find(ProjectSet, |
|
45 |
ProjectSet.offering_id == self.context.id, |
|
46 |
ProjectSet.id == int(projectset)) |
|
47 |
||
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 |
|
54 |
||
55 |