~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-06-29 06:43:20 UTC
  • Revision ID: grantw@unimelb.edu.au-20090629064320-vrahlocbh0d5852w
Allow admins to set the admin flag with ivle-adduser (issue #151).

ivle-makeuser was also renamed to ivle-adduser.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from ivle.webapp.base.views import BaseView
29
29
from ivle.webapp.base.plugins import ViewPlugin, OverlayPlugin
30
30
from ivle.webapp.errors import HTTPError, Unauthorized
31
 
from ivle.webapp.publisher import NoPath
32
 
from ivle.webapp.breadcrumbs import Breadcrumber
33
31
 
34
32
class XHTMLView(BaseView):
35
33
    """
39
37
    """
40
38
 
41
39
    template = 'template.html'
 
40
 
 
41
    plugin_scripts = {}
 
42
    plugin_styles = {}
 
43
    scripts_init = []
 
44
 
42
45
    allow_overlays = True
43
 
 
44
 
    def __init__(self, *args, **kwargs):
45
 
        super(XHTMLView, self).__init__(*args, **kwargs)
46
 
 
47
 
        self.overlay_blacklist = []
48
 
 
49
 
        self.plugin_scripts = {}
50
 
        self.plugin_styles = {}
51
 
        self.scripts_init = []
52
 
 
53
 
        self.extra_breadcrumbs = []
54
 
        self.overlay_blacklist = []
55
 
 
56
 
    def get_context_ancestry(self, req):
57
 
        return req.publisher.get_ancestors(self.context)
 
46
    overlay_blacklist = []
 
47
 
 
48
    def __init__(self, req, **kwargs):
 
49
        for key in kwargs:
 
50
            setattr(self, key, kwargs[key])
58
51
 
59
52
    def filter(self, stream, ctx):
60
53
        return stream
103
96
        ctx['scripts_init'] = self.scripts_init + overlay_bits[3]
104
97
        ctx['app_template'] = app
105
98
        ctx['title_img'] = media_url(req, CorePlugin,
106
 
                                     "images/chrome/root-breadcrumb.png")
107
 
        try:
108
 
            ctx['ancestry'] = self.get_context_ancestry(req)
109
 
        except NoPath:
110
 
            ctx['ancestry'] = []
111
 
 
112
 
        # Allow the view to add its own fake breadcrumbs.
113
 
        ctx['extra_breadcrumbs'] = self.extra_breadcrumbs
114
 
 
115
 
        ctx['crumb'] = Breadcrumber(req).crumb
 
99
                                     "images/chrome/title.png")
116
100
        self.populate_headings(req, ctx)
117
101
        tmpl = loader.load(os.path.join(os.path.dirname(__file__), 
118
102
                                                        'ivle-headings.html'))
209
193
class XHTMLErrorView(XHTMLView):
210
194
    template = 'xhtmlerror.html'
211
195
 
212
 
    def __init__(self, req, context, lastobj):
213
 
        super(XHTMLErrorView, self).__init__(req, context)
214
 
        self.lastobj = lastobj
215
 
 
216
 
    def get_context_ancestry(self, req):
217
 
        return req.publisher.get_ancestors(self.lastobj)
 
196
    def __init__(self, req, exception):
 
197
        self.context = exception
218
198
 
219
199
    def populate(self, req, ctx):
220
 
        ctx['req'] = req
221
200
        ctx['exception'] = self.context
222
201
 
223
202
class XHTMLUnauthorizedView(XHTMLErrorView):
224
203
    template = 'xhtmlunauthorized.html'
225
204
 
226
 
    def __init__(self, req, exception, lastobj):
227
 
        super(XHTMLUnauthorizedView, self).__init__(req, exception, lastobj)
 
205
    def __init__(self, req, exception):
 
206
        super(XHTMLUnauthorizedView, self).__init__(req, exception)
228
207
 
229
208
        if req.user is None:
230
209
            # Not logged in. Redirect to login page.