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

« back to all changes in this revision

Viewing changes to ivle/webapp/base/xhtml.py

  • Committer: William Grant
  • Date: 2009-12-01 08:03:21 UTC
  • mto: This revision was merged to the branch mainline in revision 1353.
  • Revision ID: grantw@unimelb.edu.au-20091201080321-q8fngigm32fkrj2d
Allow views to specify text for their breadcrumb.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
 
41
41
    template = 'template.html'
42
42
    allow_overlays = True
 
43
    breadcrumb_text = None
43
44
 
44
45
    def __init__(self, *args, **kwargs):
45
46
        super(XHTMLView, self).__init__(*args, **kwargs)
109
110
        except NoPath:
110
111
            ctx['ancestry'] = []
111
112
 
 
113
        # If the view has specified text for a breadcrumb, add one.
 
114
        if self.breadcrumb_text:
 
115
            ctx['extra_breadcrumbs'] = [ViewBreadcrumb(req, self)]
 
116
        else:
 
117
            ctx['extra_breadcrumbs'] = []
 
118
 
112
119
        # Allow the view to add its own fake breadcrumbs.
113
 
        ctx['extra_breadcrumbs'] = self.extra_breadcrumbs
 
120
        ctx['extra_breadcrumbs'] += self.extra_breadcrumbs
114
121
 
115
122
        ctx['crumb'] = Breadcrumber(req).crumb
116
123
        self.populate_headings(req, ctx)
235
242
            req.throw_redirect('/+login' + query_string)
236
243
 
237
244
        req.status = 403
 
245
 
 
246
class ViewBreadcrumb(object):
 
247
    def __init__(self, req, context):
 
248
        self.req = req
 
249
        self.context = context
 
250
 
 
251
    @property
 
252
    def text(self):
 
253
        return self.context.breadcrumb_text