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 |
|
1165.3.2
by Nick Chadwick
Created a new view for IVLE, allowing lecturers and tutors to |
21 |
from ivle.database import ProjectSet, Project, Subject, Semester, Offering |
1165.2.3
by Nick Chadwick
Added a new Admin view, which allows for the administration of projects |
22 |
|
23 |
from ivle.webapp.base.rest import (XHTMLRESTView, named_operation, |
|
24 |
require_permission) |
|
25 |
from ivle.webapp.errors import NotFound |
|
26 |
||
1165.3.2
by Nick Chadwick
Created a new view for IVLE, allowing lecturers and tutors to |
27 |
class ProjectSetRESTView(XHTMLRESTView): |
28 |
"""Rest view for a projectset.
|
|
1165.2.3
by Nick Chadwick
Added a new Admin view, which allows for the administration of projects |
29 |
|
30 |
Add new, delete, edit functionality is given here."""
|
|
1165.3.2
by Nick Chadwick
Created a new view for IVLE, allowing lecturers and tutors to |
31 |
template = "templates/projectset_fragment.html" |
32 |
||
33 |
def _project_url(self, project): |
|
1165.3.15
by William Grant
Remove the ProjectSet from Project URLs. |
34 |
return "/subjects/%s/%s/%s/+projects/%s" % \ |
35 |
(self.context.offering.subject.short_name, |
|
1165.3.11
by Nick Chadwick
Fixed a broken link when adding a new project. |
36 |
self.context.offering.semester.year, |
37 |
self.context.offering.semester.semester, |
|
38 |
project.short_name) |
|
1165.3.2
by Nick Chadwick
Created a new view for IVLE, allowing lecturers and tutors to |
39 |
|
40 |
@named_operation('edit') |
|
41 |
def add_project(self, req, name, short_name, synopsis): |
|
42 |
"""Add a Project to this ProjectSet"""
|
|
43 |
new_project = Project() |
|
44 |
new_project.name = unicode(name) |
|
45 |
new_project.short_name = unicode(short_name) |
|
46 |
new_project.synopsis = unicode(synopsis) |
|
47 |
new_project.project_set = self.context |
|
48 |
||
49 |
req.store.add(new_project) |
|
50 |
req.store.flush() |
|
1165.2.3
by Nick Chadwick
Added a new Admin view, which allows for the administration of projects |
51 |
|
1165.3.2
by Nick Chadwick
Created a new view for IVLE, allowing lecturers and tutors to |
52 |
self.template = "templates/project_fragment.html" |
53 |
self.ctx['project'] = new_project |
|
54 |
self.ctx['project_url'] = self._project_url(new_project) |
|
55 |
||
56 |
return {'success': True, 'projectset_id': self.context.id} |
|
57 |
||
58 |
class ProjectRESTView(XHTMLRESTView): |
|
59 |
"""Rest view for a project."""
|