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
20
"""Project submissions user interface."""
22
from ivle.database import (User, ProjectGroup, Offering, Subject, Semester,
24
from ivle.webapp.errors import NotFound
25
from ivle.webapp.base.xhtml import XHTMLView
26
from ivle.webapp.base.plugins import ViewPlugin
29
class SubmitView(XHTMLView):
30
"""A view to submit a Subversion repository path for a project."""
31
template = 'submit.html'
33
permission = 'submit_project'
35
def __init__(self, req, rtype, rname, path):
36
# We need to work out which entity owns the repository, so we look
37
# at the first two path segments. The first tells us the type.
39
self.context = User.get_by_login(req.store, rname)
40
elif rtype == 'groups':
41
namebits = rname.split('_', 3)
42
if len(namebits) != 4:
44
self.context = req.store.find(ProjectGroup,
45
ProjectGroup.name == namebits[3],
46
ProjectGroup.project_set_id == ProjectSet.id,
47
ProjectSet.offering_id == Offering.id,
48
Offering.subject_id == Subject.id,
49
Subject.short_name == namebits[0],
50
Offering.semester_id == Semester.id,
51
Semester.year == namebits[1],
52
Semester.semester == namebits[2]).one()
56
if self.context is None:
59
def populate(self, req, ctx):
62
class Plugin(ViewPlugin):
64
('+submit/:rtype/:rname/*path', SubmitView),