~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/webapp/admin/traversal.py

  • Committer: William Grant
  • Date: 2009-06-29 06:43:20 UTC
  • Revision ID: grantw@unimelb.edu.au-20090629064320-vrahlocbh0d5852w
Allow admins to set the admin flag with ivle-adduser (issue #151).

ivle-makeuser was also renamed to ivle-adduser.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
from ivle.database import Offering, ProjectSet, Project, Subject, User
19
 
 
20
 
from ivle.webapp import ApplicationRoot
21
 
from ivle.webapp.routing import ROOT
22
 
from ivle.webapp.routing.decorators import forward_route, reverse_route
23
 
 
24
 
@forward_route(ApplicationRoot, argc=1)
25
 
def root_to_user(root, segment):
26
 
    if not segment.startswith('~'):
27
 
        return None
28
 
    return User.get_by_login(root.store, segment[1:])
29
 
 
30
 
@forward_route(ApplicationRoot, 'subjects', argc=1)
31
 
def root_to_subject(root, name):
32
 
    return root.store.find(Subject, short_name=name).one()
33
 
 
34
 
@forward_route(Subject, argc=2)
35
 
def subject_to_offering(subject, year, semester):
36
 
    return subject.offering_for_semester(year, semester)
37
 
 
38
 
@forward_route(Offering, '+projects', argc=1)
39
 
def offering_to_project(offering, name):
40
 
    return Store.of(offering).find(Project,
41
 
                                   Project.project_set_id == ProjectSet.id,
42
 
                                   ProjectSet.offering == offering).one()
43
 
 
44
 
@forward_route(Offering, '+projectsets', argc=1)
45
 
def offering_to_projectset(offering, name):
46
 
    return Store.of(offering).find(ProjectSet,
47
 
                                   ProjectSet.offering == offering).one()
48
 
 
49
 
@reverse_route(User)
50
 
def user_url(user):
51
 
    return (ROOT, '~' + user)
52
 
 
53
 
@reverse_route(Subject)
54
 
def subject_url(subject):
55
 
    return (ROOT, ('subjects', subject.short_name))
56
 
 
57
 
@reverse_route(Offering)
58
 
def offering_url(offering):
59
 
    return (offering.subject, (offering.semester.year,
60
 
                               offering.semester.semester))
61
 
 
62
 
@reverse_route(ProjectSet)
63
 
def projectset_url(project_set):
64
 
    return (project_set.offering, ('+projectsets', project_set.name))
65
 
 
66
 
@reverse_route(Project)
67
 
def project_url(project):
68
 
    return (project.project_set.offering, ('+projects', project.name))