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

« back to all changes in this revision

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

  • Committer: William Grant
  • Date: 2010-02-23 08:55:42 UTC
  • mto: This revision was merged to the branch mainline in revision 1674.
  • Revision ID: grantw@unimelb.edu.au-20100223085542-r8xw14bxxoraza51
Permit underscores in all names.

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
 
 
19
class UsersBreadcrumb(object):
 
20
    @property
 
21
    def url(self):
 
22
        return '/users'
 
23
 
 
24
    @property
 
25
    def text(self):
 
26
        return 'Users'
 
27
 
 
28
 
 
29
class UserBreadcrumb(object):
 
30
    def __init__(self, req, context):
 
31
        self.req = req
 
32
        self.context = context
 
33
 
 
34
    @property
 
35
    def url(self):
 
36
        return self.req.publisher.generate(self.context)
 
37
 
 
38
    @property
 
39
    def text(self):
 
40
        return self.context.nick
 
41
 
 
42
    @property
 
43
    def extra_breadcrumbs_before(self):
 
44
        return [UsersBreadcrumb()]
 
45
 
 
46
 
 
47
class SubjectBreadcrumb(object):
 
48
    def __init__(self, req, context):
 
49
        self.req = req
 
50
        self.context = context
 
51
 
 
52
    @property
 
53
    def text(self):
 
54
        return self.context.name
 
55
 
 
56
 
 
57
class OfferingBreadcrumb(object):
 
58
    def __init__(self, req, context):
 
59
        self.req = req
 
60
        self.context = context
 
61
 
 
62
    @property
 
63
    def url(self):
 
64
        return self.req.publisher.generate(self.context)
 
65
 
 
66
    @property
 
67
    def text(self):
 
68
        return '%s semester %s' % (self.context.semester.year,
 
69
                                   self.context.semester.semester)
 
70
 
 
71
 
 
72
class ProjectsBreadcrumb(object):
 
73
    """Static 'Projects' breadcrumb to precede ProjectBreadcrumb."""
 
74
    def __init__(self, req, context):
 
75
        self.req = req
 
76
        self.context = context
 
77
 
 
78
    @property
 
79
    def url(self):
 
80
        return self.req.publisher.generate(self.context, None, '+projects')
 
81
 
 
82
    @property
 
83
    def text(self):
 
84
        return 'Projects'
 
85
 
 
86
 
 
87
class ProjectBreadcrumb(object):
 
88
    def __init__(self, req, context):
 
89
        self.req = req
 
90
        self.context = context
 
91
 
 
92
    @property
 
93
    def url(self):
 
94
        return self.req.publisher.generate(self.context)
 
95
 
 
96
    @property
 
97
    def text(self):
 
98
        return self.context.name
 
99
 
 
100
    @property
 
101
    def extra_breadcrumbs_before(self):
 
102
        return [ProjectsBreadcrumb(self.req, self.context.project_set.offering)]
 
103
 
 
104
 
 
105
class EnrolmentsBreadcrumb(object):
 
106
    """Static 'Enrolments' breadcrumb to precede EnrolmentBreadcrumb."""
 
107
    def __init__(self, req, context):
 
108
        self.req = req
 
109
        self.context = context
 
110
 
 
111
    @property
 
112
    def url(self):
 
113
        return self.req.publisher.generate(self.context, None, '+enrolments')
 
114
 
 
115
    @property
 
116
    def text(self):
 
117
        return 'Enrolments'
 
118
 
 
119
 
 
120
class EnrolmentBreadcrumb(object):
 
121
    def __init__(self, req, context):
 
122
        self.req = req
 
123
        self.context = context
 
124
 
 
125
    @property
 
126
    def text(self):
 
127
        return self.context.user.fullname
 
128
 
 
129
    @property
 
130
    def extra_breadcrumbs_before(self):
 
131
        return [EnrolmentsBreadcrumb(self.req, self.context.offering)]