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

« back to all changes in this revision

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

  • Committer: Matt Giuca
  • Date: 2010-07-28 05:38:15 UTC
  • Revision ID: matt.giuca@gmail.com-20100728053815-6zel7yx96o0n4275
database.ProjectSubmission.get_svn_export_command now appends the file extension of the submission onto the output path, so if a student submits a file (not a directory), e.g., test.html, it will check out as 'studenta.html', not 'studenta' (so it has its correct file extension). (LP: #608040)

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
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
 
18
29
class UserBreadcrumb(object):
19
30
    def __init__(self, req, context):
20
31
        self.req = req
26
37
 
27
38
    @property
28
39
    def text(self):
29
 
        return self.context.nick
 
40
        perms = self.context.get_permissions(self.req.user, self.req.config)
 
41
        # Show nickname iff current user has permission to view this user
 
42
        # (Else, show just the login name)
 
43
        if 'view' in perms:
 
44
            return self.context.nick
 
45
        else:
 
46
            return self.context.login
 
47
 
 
48
    @property
 
49
    def extra_breadcrumbs_before(self):
 
50
        return [UsersBreadcrumb()]
 
51
 
 
52
 
 
53
class SubjectsBreadcrumb(object):
 
54
    @property
 
55
    def url(self):
 
56
        return '/subjects'
 
57
 
 
58
    @property
 
59
    def text(self):
 
60
        return 'Subjects'
30
61
 
31
62
class SubjectBreadcrumb(object):
32
63
    def __init__(self, req, context):
34
65
        self.context = context
35
66
 
36
67
    @property
 
68
    def url(self):
 
69
        return self.req.publisher.generate(self.context)
 
70
 
 
71
    @property
37
72
    def text(self):
38
73
        return self.context.name
39
74
 
 
75
    @property
 
76
    def extra_breadcrumbs_before(self):
 
77
        return [SubjectsBreadcrumb()]
 
78
 
 
79
 
40
80
class OfferingBreadcrumb(object):
41
81
    def __init__(self, req, context):
42
82
        self.req = req
48
88
 
49
89
    @property
50
90
    def text(self):
51
 
        return '%s semester %s' % (self.context.semester.year,
52
 
                                   self.context.semester.semester)
53
 
 
54
 
    @property
55
 
    def menu(self):
56
 
        return {
57
 
            'Worksheets': self.req.publisher.generate(self.context, None,
58
 
                                                   ('+worksheets')),
59
 
            }
 
91
        return '%s %s' % (self.context.semester.year,
 
92
                          self.context.semester.display_name)
 
93
 
 
94
 
 
95
class ProjectsBreadcrumb(object):
 
96
    """Static 'Projects' breadcrumb to precede ProjectBreadcrumb.
 
97
    context must be a ProjectSet.
 
98
    """
 
99
    def __init__(self, req, context):
 
100
        self.req = req
 
101
        self.context = context
 
102
 
 
103
    @property
 
104
    def url(self):
 
105
        return self.req.publisher.generate(self.context.offering, None,
 
106
                                           '+projects')
 
107
 
 
108
    @property
 
109
    def text(self):
 
110
        return 'Projects'
 
111
 
60
112
 
61
113
class ProjectBreadcrumb(object):
62
114
    def __init__(self, req, context):
71
123
    def text(self):
72
124
        return self.context.name
73
125
 
 
126
    @property
 
127
    def extra_breadcrumbs_before(self):
 
128
        return [ProjectsBreadcrumb(self.req, self.context.project_set)]
 
129
 
 
130
 
 
131
class EnrolmentsBreadcrumb(object):
 
132
    """Static 'Enrolments' breadcrumb to precede EnrolmentBreadcrumb."""
 
133
    def __init__(self, req, context):
 
134
        self.req = req
 
135
        self.context = context
 
136
 
 
137
    @property
 
138
    def url(self):
 
139
        return self.req.publisher.generate(self.context, None, '+enrolments')
 
140
 
 
141
    @property
 
142
    def text(self):
 
143
        return 'Enrolments'
 
144
 
 
145
 
 
146
class EnrolmentBreadcrumb(object):
 
147
    def __init__(self, req, context):
 
148
        self.req = req
 
149
        self.context = context
 
150
 
 
151
    @property
 
152
    def text(self):
 
153
        return self.context.user.fullname
 
154
 
 
155
    @property
 
156
    def extra_breadcrumbs_before(self):
 
157
        return [EnrolmentsBreadcrumb(self.req, self.context.offering)]