~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-15 09:16:49 UTC
  • Revision ID: grantw@unimelb.edu.au-20100215091649-qrp5emn7wjt2jlmj
Add 'Create new offering' link to /subjects, and rebrand the 'Manage subjects' link to include semesters too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
 
38
38
    @property
39
39
    def text(self):
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
 
40
        return self.context.nick
47
41
 
48
42
    @property
49
43
    def extra_breadcrumbs_before(self):
50
44
        return [UsersBreadcrumb()]
51
45
 
52
46
 
53
 
class SubjectsBreadcrumb(object):
54
 
    @property
55
 
    def url(self):
56
 
        return '/subjects'
57
 
 
58
 
    @property
59
 
    def text(self):
60
 
        return 'Subjects'
61
 
 
62
47
class SubjectBreadcrumb(object):
63
48
    def __init__(self, req, context):
64
49
        self.req = req
65
50
        self.context = context
66
51
 
67
52
    @property
68
 
    def url(self):
69
 
        return self.req.publisher.generate(self.context)
70
 
 
71
 
    @property
72
53
    def text(self):
73
54
        return self.context.name
74
55
 
75
 
    @property
76
 
    def extra_breadcrumbs_before(self):
77
 
        return [SubjectsBreadcrumb()]
78
 
 
79
56
 
80
57
class OfferingBreadcrumb(object):
81
58
    def __init__(self, req, context):
88
65
 
89
66
    @property
90
67
    def text(self):
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'
 
68
        return '%s semester %s' % (self.context.semester.year,
 
69
                                   self.context.semester.semester)
111
70
 
112
71
 
113
72
class ProjectBreadcrumb(object):
123
82
    def text(self):
124
83
        return self.context.name
125
84
 
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)]