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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from ivle.webapp.base.plugins import ViewPlugin, OverlayPlugin, MediaPlugin
from ivle.webapp.console.service import ConsoleServiceRESTView
from ivle.webapp.console.overlay import ConsoleOverlay
from ivle.webapp.base.xhtml import XHTMLView
from ivle.webapp import ApplicationRoot


class ConsoleView(XHTMLView):
    tab = 'console'
    help = 'Console'
    breadcrumb_text = 'Console'

    # Overide the the standard constructor view
    def __init__(self, *args, **kwargs):
        super(ConsoleView, self).__init__(*args, **kwargs)

        self.plugin_scripts = {'ivle.webapp.console': ['console.js']}
        self.plugin_styles  = {'ivle.webapp.console': ['console.css']}
        self.scripts_init = ['start_server_early']

        # Don't load the console overlay when we already have a console.
        self.overlay_blacklist = [ConsoleOverlay]

    def authorize(self, req):
        return req.user is not None

    def populate(self, req, ctx):
        ctx['windowpane'] = False
        ctx['start_body_attrs'] = {'class': 'console_body'}

class Plugin(ViewPlugin, OverlayPlugin, MediaPlugin):
    views = [(ApplicationRoot, ('console', '+index'), ConsoleView),
             (ApplicationRoot, ('console', 'service'), ConsoleServiceRESTView),
             ]

    tabs = [
        ('console', 'Console', 'Try out your code in a Python console',
         'console.png', 'console', 3)
    ]

    overlays = [
        ConsoleOverlay,
    ]

    media = 'media'
    help = {'Console': 'help.html'}