~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: 2012-06-28 01:52:02 UTC
  • Revision ID: me@williamgrant.id.au-20120628015202-f6ru7o367gt6nvgz
Hah

Show diffs side-by-side

added added

removed removed

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