Beispiel #1
0
    def __init__(self, traceback, desc, **kwargs):
        # Look for the theme file
        srcdir = os.path.dirname(os.path.realpath(__file__))
        theme_file = os.path.join(srcdir, 'exception.html')
        bt = quote(traceback).replace('%', '%%')

        # Set up the template
        template = CTK.Template(filename=theme_file)

        template['title'] = _("Internal Error")
        template['body_props'] = ' id="body-error"'

        # Parent's constructor
        CTK.Page.__init__(self, template, **kwargs)

        # Thank you: submitted
        dialog_ok = CTK.Dialog({
            'title': _("Thank you!"),
            'autoOpen': False,
            'draggable': False,
            'width': 480
        })
        dialog_ok += CTK.RawHTML('<p>%s</p>' % (_(NOTE_EXCEPT_THANKS)))
        dialog_ok.AddButton(_('Close'), "close")

        dialog_fail = CTK.Dialog({
            'title': _("Could not report the issue"),
            'autoOpen': False,
            'draggable': False,
            'width': 480
        })
        dialog_fail += CTK.Notice('error', CTK.RawHTML(_(NOTE_EXCEPT_FAIL)))
        dialog_fail.AddButton(_('Close'), "close")

        self += dialog_ok
        self += dialog_fail

        # Build the page content
        self += CTK.RawHTML('<h1>%s</h1>' % (_("Unexpected Exception")))
        self += CTK.RawHTML('<h2>%s</h2>' % (desc))
        self += CTK.RawHTML(_(NOTE_EXCEPT_SORRY))
        self += CTK.RawHTML(
            formatter('<pre class="backtrace">%s</pre>', traceback))
        self += CTK.RawHTML(_(NOTE_EXCEPT_COMMENT))

        submit = CTK.Submitter(URL_APPLY)
        submit.bind('submit_success', dialog_ok.JS_to_show())
        submit.bind('submit_fail', dialog_fail.JS_to_show())
        self += submit

        submit += CTK.TextArea({
            'name': 'comments',
            'rows': 10,
            'cols': 80,
            'class': 'noauto'
        })
        submit += CTK.Hidden('traceback', bt)
        submit += CTK.SubmitterButton(_("Report this"))
Beispiel #2
0
    def Add (self, content):
        c_types = ['collection', 'asset']
        c_type  = c_types[isinstance (content, Asset.Asset)]

        c_id     = '%s=%s' % (c_type[0], str(content['id']))
        link     = LINK_HREF % ("%s/meta/%s" %(LOCATION,c_id),'Metadatos')
        links    = [CTK.RawHTML(link)]

        try:
            Auth.check_if_authorized (content)
            link = LINK_HREF % ("/acl/%s/%d" % (c_type, content['id']), 'Permisos')
            links.append(CTK.RawHTML(link))
        except Error.Unauthorized:
            pass

        if c_id[0] == 'c':
            link = LINK_HREF % ("%s/view/%s" % (LOCATION, c_id), 'Ver')
            links.append(CTK.RawHTML(link))

        elif c_id[0] == 'a':
            if content['attachment']:
                if not content._file['queue_flag']:
                    if self._has_valid_attachment (content):
                        links = links + self._get_attachment_links(content, c_id)
                    else:
                        # Error notice
                        dialog = CTK.Dialog ({'title': 'Activo #%d corrupto'%content['id'], 'autoOpen': False})
                        dialog += CTK.RawHTML (FAULTY_NOTE)
                        dialog.AddButton ('Cerrar', "close")
                        link = LINK_JS_ON_CLICK %(dialog.JS_to_show(), FAULTY_LINK)
                        self += dialog
                        links.append(CTK.RawHTML(link))
                else:
                    # Transcoding notice
                    dialog = CTK.Dialog ({'title': 'Procesando #%d...'%content['id'], 'autoOpen': False})
                    dialog += CTK.RawHTML (TRANSCODING_NOTE)
                    dialog.AddButton ('Cerrar', "close")
                    link = LINK_JS_ON_CLICK %(dialog.JS_to_show(), TRANSCODING_LINK)
                    self += dialog
                    links.append(CTK.RawHTML(link))

            links.append (self._get_bookmark_link (content['id']))

        table = CTK.Table({'class':"abstract_actions"})
        n = 1
        for link in links:
            table[(n,1)] = link
            n+=1
        self+= table
Beispiel #3
0
    def __init__(self):
        CTK.Box.__init__(self, {'id': 'halt-admin-box'})

        submit = CTK.Submitter('/halt')
        submit += CTK.Hidden('what', 'ever')

        dialog = CTK.Dialog({
            'title': _('Shutdown Cherokee-admin'),
            'width': 560
        })
        dialog.AddButton(_('Cancel'), "close")
        dialog.AddButton(_('Shut down'), dialog.JS_to_trigger('submit'))
        dialog += CTK.RawHTML(
            "<h2>%s</h2>" %
            (_('You are about to shut down this instance of Cherokee-admin')))
        dialog += CTK.RawHTML("<p>%s</p>" %
                              (_('Are you sure you want to proceed?')))
        dialog += submit
        dialog.bind('submit', dialog.JS_to_close())
        dialog.bind(
            'submit', "$('body').html('<h1>%s</h1>');" %
            (_('Cherokee-admin has been shut down')))

        link = CTK.Link(None, CTK.RawHTML(_('Shut down Cherokee-Admin')))
        link.bind('click', dialog.JS_to_show())

        self += link
        self += dialog
Beispiel #4
0
def default(message=None):
    # Authentication
    fail = Auth.assert_is_role(Role.ROLE_ADMIN)
    if fail: return fail

    # List of users
    q = (
        "SELECT users.id as id, username, password, forename, surname1, surname2, email, description "
        + " FROM users JOIN profiles WHERE profiles.id = users.profile_id;")
    users = Query(q)

    table = CTK.Table()
    title = [
        CTK.RawHTML(x) for x in
        ['Login', 'Nombre', 'Apellido', 'Apellido', 'E-Mail', 'Profile']
    ]
    table[(1, 1)] = title
    table.set_header(row=True, num=1)

    page = Page.Default()

    n = 2
    for user in users:
        user_id = users[user]['id']
        username = users[user]['username']

        # Delete user link
        dialog = CTK.Dialog({
            'title': "Eliminando usuario %s" % (username),
            'autoOpen': False
        })
        dialog += CTK.RawHTML(NOTE_DELETE)
        dialog.AddButton('Cancelar', "close")
        dialog.AddButton('Borrar', "/admin/user/del/%s" % (user_id))

        del_img = '<img src="/CTK/images/del.png" alt="Del"'
        linkdel = LINK_JS_ON_CLICK % (dialog.JS_to_show(), del_img)
        linkname = LINK_HREF % ("/admin/user/%s" % user_id, username)

        table[(n, 1)] = [
            CTK.RawHTML(linkname),
            CTK.RawHTML(users[user]['forename']),
            CTK.RawHTML(users[user]['surname1']),
            CTK.RawHTML(users[user]['surname2']),
            CTK.RawHTML(users[user]['email']),
            CTK.RawHTML(users[user]['description']),
            CTK.RawHTML(linkdel)
        ]

        page += dialog
        n += 1

    page += CTK.RawHTML("<h1>%s: Administración de Usuarios</h1>" % ADMIN_LINK)
    page += CTK.RawHTML(LINK_HREF % ('/admin/user/new', 'Añadir usuario'))
    page += table

    if message:
        page += Message(message)

    return page.Render()
Beispiel #5
0
    def __call__ (self):
        dialog = CTK.Dialog ({'title': "New Virtual Server", 'width': 500, 'autoOpen': True})
        dialog += CTK.Druid (CTK.RefreshableURL ('/url1'))

        page = CTK.Page()
        page += dialog
        return page.Render()
Beispiel #6
0
        def __init__ (self, refresh, right_box):
            CTK.Container.__init__ (self)

            # Sanity check
            if not CTK.cfg.keys('vserver'):
                CTK.cfg['vserver!1!nick']           = 'default'
                CTK.cfg['vserver!1!document_root']  = '/tmp'
                CTK.cfg['vserver!1!rule!1!match']   = 'default'
                CTK.cfg['vserver!1!rule!1!handler'] = 'common'

            # Helper
            entry = lambda klass, key: CTK.Box ({'class': klass}, CTK.RawHTML (CTK.escape_html (CTK.cfg.get_val(key, ''))))

            # Build the panel list
            panel = SelectionPanel.SelectionPanel (reorder, right_box.id, URL_BASE, '', container='vservers_panel')
            self += panel

            # Build the Virtual Server list
            vservers = CTK.cfg.keys('vserver')
            vservers.sort (lambda x,y: cmp(int(x), int(y)))
            vservers.reverse()

            for k in vservers:
                # Document root widget
                droot_str = CTK.cfg.get_val ('vserver!%s!document_root'%(k), '')

                # Market install base scenario
                if self.__is_market_installation (k, droot_str):
                    droot_widget = CTK.Box ({'class': 'droot'}, CTK.RawHTML(_('Market installation')))
                else:
                    droot_widget = CTK.Box ({'class': 'droot'}, CTK.RawHTML(CTK.escape_html (droot_str)))

                if k == vservers[-1]:
                    content = [entry('nick', 'vserver!%s!nick'%(k)), droot_widget]
                    panel.Add (k, '/vserver/content/%s'%(k), content, draggable=False)
                else:
                    nick     = CTK.cfg.get_val ('vserver!%s!nick'%(k), _('Unknown'))
                    nick_esc = CTK.escape_html (nick)

                    # Remove
                    dialog = CTK.Dialog ({'title': _('Do you really want to remove it?'), 'width': 480})
                    dialog.AddButton (_('Cancel'), "close")
                    dialog.AddButton (_('Remove'), CTK.JS.Ajax (URL_APPLY, async=True,
                                                                data    = {'vserver!%s'%(k):''},
                                                                success = dialog.JS_to_close() + \
                                                                    refresh.JS_to_refresh()))
                    dialog += CTK.RawHTML (_(NOTE_DELETE_DIALOG) %(locals()))
                    self += dialog
                    remove = CTK.ImageStock('del')
                    remove.bind ('click', dialog.JS_to_show() + "return false;")

                    # Disable
                    is_disabled = bool (int (CTK.cfg.get_val('vserver!%s!disabled'%(k), "0")))
                    disclass = ('','vserver-inactive')[is_disabled][:]

                    disabled = CTK.ToggleButtonOnOff (not is_disabled)
                    disabled.bind ('changed',
                                   CTK.JS.Ajax (URL_APPLY, async=True,
                                                data = '{"vserver!%s!disabled": event.value}'%(k)))
Beispiel #7
0
    def __get_del_dialog(self, url_params, msg):
        # Link to delete target
        dialog = CTK.Dialog({'title': "Aviso", 'autoOpen': False})
        dialog += CTK.RawHTML(msg)
        dialog.AddButton('Cancelar', "close")
        dialog.AddButton('Borrar',
                         "%s/%s" % (PageCollection.LOCATION, url_params))

        return dialog
Beispiel #8
0
def default(message=None):
    # Authentication
    fail = Auth.assert_is_role(Role.ROLE_ADMIN)
    if fail: return fail

    # List of licenses
    q = ("SELECT id, name, description FROM licenses;")
    licenses = Query(q)

    table = CTK.Table()
    title = [CTK.RawHTML(x) for x in ['Nombre', 'Descripción']]
    table[(1, 1)] = title
    table.set_header(row=True, num=1)

    page = Page.Default()

    n = 2
    for license in licenses:
        license_id = licenses[license]['id']
        licensename = licenses[license]['name']
        description = licenses[license]['description']
        if not description:
            description = ''

        # Delete license link
        dialog = CTK.Dialog({
            'title': "¿Quieres eliminar %s?" % (licensename),
            'autoOpen': False
        })
        dialog += CTK.RawHTML(NOTE_DELETE)
        dialog.AddButton('Cancelar', "close")
        dialog.AddButton('Borrar', "%s/del/%s" % (LOCATION, license_id))

        linkdel = LINK_JS_ON_CLICK % (dialog.JS_to_show(), "Borrar")
        linkname = LINK_HREF % ("%s/edit/%s" %
                                (LOCATION, license_id), licensename)

        table[(n, 1)] = [
            CTK.RawHTML(linkname),
            CTK.RawHTML(description),
            CTK.RawHTML(linkdel)
        ]

        page += dialog
        n += 1

    # Render
    page += CTK.RawHTML("<h1>%s: Administraci&oacute;n de Licencias</h1>" %
                        (ADMIN_LINK))
    page += table
    page += CTK.RawHTML(LINK_HREF %
                        ('%s/new' % LOCATION, 'A&ntilde;adir licencia'))

    if message:
        page += Message(message)

    return page.Render()
Beispiel #9
0
        def __init__(self):
            CTK.Box.__init__(self, {'class': 'panel-buttons'})

            # Add New
            dialog = CTK.Dialog({
                'title': _('Add New Information Source'),
                'width': 530
            })
            dialog.AddButton(_('Cancel'), "close")
            dialog.AddButton(_('Add'), dialog.JS_to_trigger('submit'))
            dialog += AddSource()

            button = CTK.Button(
                '<img src="/static/images/panel-new.png" />', {
                    'id': 'source-new-button',
                    'class': 'panel-button',
                    'title': _('Add New Information Source')
                })
            button.bind('click', dialog.JS_to_show())
            dialog.bind('submit_success', dialog.JS_to_close())
            dialog.bind('submit_success', self.JS_to_trigger('submit_success'))

            self += button
            self += dialog

            # Clone
            dialog = CTK.Dialog({
                'title': _('Clone Information Source'),
                'width': 480
            })
            dialog.AddButton(_('Cancel'), "close")
            dialog.AddButton(_('Clone'), JS_CLONE + dialog.JS_to_close())
            dialog += CloneSource()

            button = CTK.Button(
                '<img src="/static/images/panel-clone.png" />', {
                    'id': 'source-clone-button',
                    'class': 'panel-button',
                    'title': _('Clone Selected Information Source')
                })
            button.bind('click', dialog.JS_to_show())

            self += dialog
            self += button
Beispiel #10
0
def welcome():
    if CTK.cookie['secret'] != SECRET:
        return CTK.HTTP_Redir('/')

    dialog = CTK.Dialog ({'title': "You did it"})
    dialog += CTK.RawHTML ("<h1>Welcome Sir!</h1>")

    page = CTK.Page()
    page += dialog
    return page.Render()
Beispiel #11
0
        def __init__ (self):
            CTK.Box.__init__ (self, {'class': 'panel-buttons'})

            # Add New
            dialog = CTK.Dialog ({'title': _('Add New Virtual Server'), 'width': 720})
            dialog.id = 'dialog-new-vserver'
            dialog.AddButton (_('Cancel'), "close")
            dialog.AddButton (_('Add'), dialog.JS_to_trigger('submit'))
            dialog += VirtualServerNew()

            druid  = CTK.Druid (CTK.RefreshableURL())
            wizard = CTK.Dialog ({'title': _('Virtual Server Configuration Assistant'), 'width': 550})
            wizard += druid
            druid.bind ('druid_exiting',
                        wizard.JS_to_close() +
                        self.JS_to_trigger('submit_success'))

            button = CTK.Button('<img src="/static/images/panel-new.png" />', {'id': 'vserver-new-button', 'class': 'panel-button', 'title': _('Add New Virtual Server')})
            button.bind ('click',
                         JS_ACTIVATE_FIRST %(dialog.id) +
                         dialog.JS_to_show())
            dialog.bind ('submit_success', dialog.JS_to_close())
            dialog.bind ('submit_success', self.JS_to_trigger('submit_success'))
            dialog.bind ('open_wizard',
                         dialog.JS_to_close() +
                         druid.JS_to_goto("'/wizard/vserver/' + event.wizard") +
                         wizard.JS_to_show())

            self += button
            self += dialog
            self += wizard

            # Clone
            dialog = CTK.Dialog ({'title': _('Clone Virtual Server'), 'width': 480})
            dialog.AddButton (_('Cancel'), "close")
            dialog.AddButton (_('Clone'), JS_CLONE + dialog.JS_to_close())
            dialog += CTK.RawHTML ('<p>%s</p>' %(_(NOTE_CLONE_DIALOG)))

            button = CTK.Button('<img src="/static/images/panel-clone.png" />', {'id': 'vserver-clone-button', 'class': 'panel-button', 'title': _('Clone Selected Virtual Server')})
            button.bind ('click', dialog.JS_to_show())

            self += dialog
            self += button
Beispiel #12
0
def main():
    page = CTK.Page()

    refresh = CTK.RefreshableURL ('/content', {'id': "test-refresh"})
    druid   = CTK.Druid (refresh)

    dialog = CTK.Dialog({'title': "Test", 'autoOpen': True})
    dialog += druid

    page += dialog
    return page.Render()
Beispiel #13
0
def __get_del_dialog(url_params, msg):
    # Link to delete target
    dialog = CTK.Dialog({
        'title': "¿Confirmar eliminación?",
        'autoOpen': False
    })
    dialog += CTK.RawHTML(msg)
    dialog.AddButton('Cancelar', "close")
    dialog.AddButton('Borrar', "%s/%s" % (LOCATION, url_params))

    return dialog
Beispiel #14
0
        def _get_dialog(self, k, refresh):
            if k in self.protected_sources:
                rules = _rules_per_source(k)

                links = []
                for rule in rules:
                    rule_pre = rule.split('!handler')[0]
                    r = Rule.Rule('%s!match' % (rule_pre))
                    rule_name = r.GetName()
                    rule_link = rule_pre.replace('!', '/')
                    links.append(CTK.consts.LINK_HREF % (rule_link, rule_name))

                dialog = CTK.Dialog({
                    'title': _('Deletion is forbidden'),
                    'width': 480
                })
                dialog += CTK.RawHTML(
                    _('<h2>%s</h2>' % (_("Configuration consistency"))))
                dialog += CTK.RawHTML(_(NOTE_FORBID_1))
                dialog += CTK.RawHTML('<p>%s: %s</p>' %
                                      (_(NOTE_FORBID_2), ', '.join(links)))
                dialog.AddButton(_('Close'), "close")

            else:
                actions = {'source!%s' % (k): ''}
                rule_entries_to_delete = _rules_per_source(k)
                for r in rule_entries_to_delete:
                    actions[r] = ''

                dialog = CTK.Dialog({
                    'title':
                    _('Do you really want to remove it?'),
                    'width':
                    480
                })
                dialog.AddButton(_('Cancel'), "close")
                dialog.AddButton (_('Remove'), CTK.JS.Ajax (URL_APPLY, async=False,
                                                            data    = actions,
                                                            success = dialog.JS_to_close() + \
                                                                      refresh.JS_to_refresh()))
                dialog += CTK.RawHTML(_(NOTE_DELETE_DIALOG))
Beispiel #15
0
    def __init__ (self, refreshable, key, url_apply, **kwargs):
        CTK.Container.__init__ (self, **kwargs)

        # List
        entries = CTK.cfg.keys(key)
        entries.sort (sorting_func)

        if entries:
            table = CTK.Table({'id': 'error-redirection'})
            table.set_header(1)
            table += [CTK.RawHTML(x) for x in ('Error', 'Redirection', 'Type', '')]

            for i in entries:
                show  = CTK.ComboCfg ('%s!%s!show'%(key,i), trans_options(REDIRECTION_TYPE))
                redir = CTK.TextCfg  ('%s!%s!url'%(key,i), False)
                rm    = CTK.ImageStock('del')
                table += [CTK.RawHTML(i), redir, show, rm]

                rm.bind ('click', CTK.JS.Ajax (url_apply,
                                               data = {"%s!%s"%(key,i): ''},
                                               complete = refreshable.JS_to_refresh()))
            submit = CTK.Submitter (url_apply)
            submit += table
            self += submit

        # Add new
        redir_codes  = [('default', _('Default Error'))]
        redir_codes += [x for x in ERROR_CODES if not x[0] in entries]

        table = CTK.PropsTable()
        table.Add (_('Error'),       CTK.ComboCfg('new_error', redir_codes, {'class':'noauto'}), _(NOTE_ERROR))
        table.Add (_('Redirection'), CTK.TextCfg ('new_redir', False, {'class':'noauto'}), _(NOTE_REDIR))
        table.Add (_('Type'),        CTK.ComboCfg('new_type', trans_options(REDIRECTION_TYPE), {'class':'noauto'}), _(NOTE_TYPE))

        submit = CTK.Submitter(url_apply)

        dialog = CTK.Dialog({'title': _('Add New Custom Error'), 'width': 540})
        dialog.AddButton (_("Close"), 'close')
        dialog.AddButton (_("Add"),   submit.JS_to_submit())

        submit += table
        submit += CTK.HiddenField ({'name': 'key', 'value': key})
        submit.bind ('submit_success', refreshable.JS_to_refresh())
        submit.bind ('submit_success', dialog.JS_to_close())

        dialog += submit
        self += dialog

        add_new = CTK.Button(_('Add New'))
        add_new.bind ('click', dialog.JS_to_show())
        self += add_new
Beispiel #16
0
    def Add(self, asset):
        assert isinstance(asset, Asset.Asset)
        asset_id = asset['id']
        linkname, linkdel = str(asset_id), ''

        if asset_id in self.acl.filter_assets("co", [asset_id]):
            linkname = LINK_HREF % ("/consume/a=%s" % (asset_id), asset_id)

        # Delete asset link
        if asset_id in self.acl.filter_assets("rm", [asset_id]):
            dialog = CTK.Dialog({
                'title': "Eliminar activo #%d?" % (asset_id),
                'autoOpen': False
            })
            dialog += CTK.RawHTML(NOTE_DELETE)
            dialog.AddButton('Cancelar', "close")
            dialog.AddButton('Borrar',
                             "%s/del/%s" % (PageAsset.LOCATION, asset_id))
            linkdel = LINK_JS_ON_CLICK % (dialog.JS_to_show(), "Borrar")
            self += dialog

        entries = [
            CTK.RawHTML(linkname),
            CTK.RawHTML(asset['title']),
            CTK.RawHTML(asset['Type']),
            CTK.RawHTML(linkdel)
        ]

        try:
            Auth.check_if_authorized(asset)
            link = LINK_HREF % ("/acl/asset/%d" % (asset['id']), 'Permisos')
            entries.append(CTK.RawHTML(link))
        except Error.Unauthorized:
            pass

        if Role.user_has_role (Role.ROLE_UPLOADER) and\
                asset_id in self.acl.filter_assets ("co" , [asset_id]):
            entries.append(
                CTK.RawHTML(LINK_HREF %
                            ('%s/evolve/parent=%d' %
                             (PageUpload.LOCATION, asset_id), 'Evolucionar')))
        if Role.user_has_role (Role.ROLE_EDITOR) and\
                asset_id in self.acl.filter_assets ("ed" , [asset_id]):
            entries.append(
                CTK.RawHTML(LINK_HREF %
                            ('%s/edit/%d' %
                             (PageAsset.LOCATION, asset_id), 'Editar')))

        self.n += 1
        self.table[(self.n, 1)] = entries
Beispiel #17
0
    def __init__ (self):
        CTK.Box.__init__ (self, {'class': 'mime-button'})

        # Add New
        dialog = CTK.Dialog ({'title': _('Add New MIME-Type'), 'width': 550})
        dialog.AddButton (_('Cancel'), "close")
        dialog.AddButton (_('Add'), dialog.JS_to_trigger('submit'))
        dialog += AddMime()

        button = CTK.Button(_('Add New'))
        button.bind ('click', dialog.JS_to_show())
        dialog.bind ('submit_success', dialog.JS_to_close())
        dialog.bind ('submit_success', self.JS_to_trigger('submit_success'));

        self += button
        self += dialog
Beispiel #18
0
def default(message=None):
    # Authentication
    fail = Auth.assert_is_role(Role.ROLE_ADMIN)
    if fail: return fail

    # List of types
    q = ("SELECT id,type FROM asset_types;")
    types = Query(q)

    table = CTK.Table()
    title = [CTK.RawHTML(x) for x in ['Tipo de activo']]
    table[(1, 1)] = title
    table.set_header(row=True, num=1)

    page = Page.Default()

    n = 2
    for asset_type in types:
        type_id = types[asset_type]['id']
        name = types[asset_type]['type']

        # Delete asset_type link
        dialog = CTK.Dialog({
            'title': "¿Quieres eliminar %s?" % (name),
            'autoOpen': False
        })
        dialog += CTK.RawHTML(NOTE_DELETE)
        dialog.AddButton('Cancelar', "close")
        dialog.AddButton('Borrar', "%s/del/%s" % (LOCATION, type_id))

        linkdel = LINK_JS_ON_CLICK % (dialog.JS_to_show(), "Borrar")
        linkname = LINK_HREF % ("%s/edit/%s" % (LOCATION, type_id), name)

        table[(n, 1)] = [CTK.RawHTML(linkname), CTK.RawHTML(linkdel)]

        page += dialog
        n += 1

    # Render
    page += CTK.RawHTML("<h1>%s: Tipos</h1>" % ADMIN_LINK)
    page += table
    page += CTK.RawHTML(LINK_HREF %
                        ('%s/new' % LOCATION, 'A&ntilde;adir tipo'))
    if message:
        page += Message(message)
    return page.Render()
    def __init__(self):
        CTK.Box.__init__(self, {'class': 'backup-restore'})

        # Druid
        druid = CTK.Druid(CTK.RefreshableURL())
        dialog = CTK.Dialog({'title': _(NOTE_RESTORE_H2), 'width': 480})
        dialog += druid

        # Trigger button
        link = CTK.Link("#", CTK.RawHTML(_('Restore…')))
        link.bind(
            'click',
            druid.JS_to_goto('"%s"' % (URL_RESTORE_NOTE)) +
            dialog.JS_to_show())

        self += dialog
        self += link
    def __init__(self):
        CTK.Box.__init__(self, {'class': 'backup-save'})

        # Druid
        druid = CTK.Druid(CTK.RefreshableURL())
        dialog = CTK.Dialog({'title': _(NOTE_SAVE_H2), 'width': 480})
        dialog += druid
        druid.bind('druid_exiting', dialog.JS_to_close())

        # Trigger button
        link = CTK.Link("#", CTK.RawHTML(_('Back up…')))
        link.bind(
            'click',
            druid.JS_to_goto('"%s"' % (URL_SAVE_NOTE)) + dialog.JS_to_show())

        self += dialog
        self += link
Beispiel #21
0
    def __init__(self):
        CTK.Container.__init__(self)

        # List ports
        self.refresh = CTK.Refreshable({'id': 'general_ports'})
        self.refresh.register(lambda: PortsTable(self.refresh).Render())

        # Add new - dialog
        table = CTK.PropsTable()
        table.Add(_('Port'), CTK.TextCfg('new_port',
                                         False, {'class': 'noauto'}),
                  _(NOTE_ADD_PORT))
        table.Add(_('Interface'),
                  CTK.TextCfg('new_if', True, {'class': 'noauto'}),
                  _(NOTE_ADD_IF))

        submit = CTK.Submitter(URL_APPLY)
        submit += table

        dialog = CTK.Dialog({
            'title': _('Add a new listening port'),
            'autoOpen': False,
            'draggable': False,
            'width': 550
        })
        dialog.AddButton(_("Cancel"), "close")
        dialog.AddButton(_("Add"), submit.JS_to_submit())
        dialog += submit
        dialog += CTK.Notice(content=CTK.RawHTML('<p>%s</p>' %
                                                 (_(NOTE_PORTS_INFO))))

        submit.bind('submit_success', self.refresh.JS_to_refresh())
        submit.bind('submit_success', dialog.JS_to_close())

        # Add new
        button = CTK.SubmitterButton("%s…" % (_('Add new port')))
        button.bind('click', dialog.JS_to_show())
        button_s = CTK.Submitter(URL_APPLY)
        button_s += button

        # Integration
        self += CTK.RawHTML("<h2>%s</h2>" % (_('Listening to Ports')))
        self += CTK.Indenter(self.refresh)
        self += button_s
        self += dialog
Beispiel #22
0
    def __init__(self, src_num):
        CTK.Container.__init__(self)

        # List ports
        self.refresh = CTK.Refreshable({'id': 'environment_table'})
        self.refresh.register(
            lambda: EnvironmentTable(self.refresh, src_num).Render())

        # Add new - dialog
        table = CTK.PropsTable()
        table.Add(_('Variable'),
                  CTK.TextCfg('tmp!new_variable', False, {'class': 'noauto'}),
                  _(NOTE_ADD_VARIABLE))
        table.Add(_('Value'),
                  CTK.TextCfg('tmp!new_value', False, {'class': 'noauto'}),
                  _(NOTE_ADD_VALUE))

        submit = CTK.Submitter(URL_APPLY)
        submit += CTK.Hidden('tmp!source_pre', 'source!%s!env' % (src_num))
        submit += table

        dialog = CTK.Dialog({
            'title': _('Add new Environment variable'),
            'autoOpen': False,
            'draggable': False,
            'width': 530
        })
        dialog.AddButton(_("Cancel"), "close")
        dialog.AddButton(_("Add"), submit.JS_to_submit())
        dialog += submit

        submit.bind('submit_success', self.refresh.JS_to_refresh())
        submit.bind('submit_success', dialog.JS_to_close())

        # Add new
        button = CTK.SubmitterButton("%s…" % (_('Add new variable')))
        button.bind('click', dialog.JS_to_show())
        button_s = CTK.Submitter(URL_APPLY)
        button_s += button

        # Integration
        self += self.refresh
        self += button_s
        self += dialog
Beispiel #23
0
    def __init__ (self, key, title, **kwargs):
        CTK.Box.__init__ (self, {'class': '%s-button' %(kwargs.get('klass', 'icon'))})
        submit_label = kwargs.get('submit_label', _('Add'))
        button_label = kwargs.get('button_label', submit_label)

        # Dialog
        dialog = CTK.Dialog ({'title': title, 'width': 375})
        dialog.AddButton (_('Cancel'), "close")
        dialog.AddButton (submit_label, dialog.JS_to_trigger('submit'))
        dialog += AddIcon(key, **kwargs)

        # Button
        button = CTK.Button (button_label)
        button.bind ('click', dialog.JS_to_show())
        dialog.bind ('submit_success', dialog.JS_to_close())
        dialog.bind ('submit_success', self.JS_to_trigger('submit_success'));

        self += button
        self += dialog
Beispiel #24
0
        def __init__(self, key):
            CTK.Box.__init__(self, {'class': 'mime-button'})

            # Add New
            dialog = CTK.Dialog({
                'title': _('Add New Regular Expression'),
                'width': 540
            })
            dialog.AddButton(_('Add'), dialog.JS_to_trigger('submit'))
            dialog.AddButton(_('Cancel'), "close")
            dialog += self.Content(key)

            button = CTK.Button(_('Add New RegEx'))
            button.bind('click', dialog.JS_to_show())
            dialog.bind('submit_success', dialog.JS_to_close())
            dialog.bind('submit_success', self.JS_to_trigger('submit_success'))

            self += button
            self += dialog
Beispiel #25
0
        def __init__(self, refresh, right_box, vsrv_num):
            CTK.Container.__init__(self)
            url_base = '/vserver/%s/rule' % (vsrv_num)
            url_apply = URL_APPLY % (vsrv_num)

            # Build the panel list
            panel = SelectionPanel.SelectionPanel(reorder,
                                                  right_box.id,
                                                  url_base,
                                                  '',
                                                  container='rules_panel')
            self += panel

            # Build the Rule list
            rules = CTK.cfg.keys('vserver!%s!rule' % (vsrv_num))
            rules.sort(lambda x, y: cmp(int(x), int(y)))
            rules.reverse()

            for r in rules:
                rule = Rule('vserver!%s!rule!%s!match' % (vsrv_num, r))
                rule_name = rule.GetName()
                rule_name_esc = CTK.escape_html(rule_name)

                # Comment
                comment = []

                handler = CTK.cfg.get_val('vserver!%s!rule!%s!handler' %
                                          (vsrv_num, r))
                if handler:
                    desc = filter(lambda x: x[0] == handler, HANDLERS)[0][1]
                    comment.append(_(desc))

                auth = CTK.cfg.get_val('vserver!%s!rule!%s!auth' %
                                       (vsrv_num, r))
                if auth:
                    desc = filter(lambda x: x[0] == auth, VALIDATORS)[0][1]
                    comment.append(_(desc))

                for e in CTK.cfg.keys('vserver!%s!rule!%s!encoder' %
                                      (vsrv_num, r)):
                    val = CTK.cfg.get_val('vserver!%s!rule!%s!encoder!%s' %
                                          (vsrv_num, r, e))
                    if val == 'allow':
                        comment.append(e)
                    elif val == 'forbid':
                        comment.append("no %s" % (e))

                if CTK.cfg.get_val('vserver!%s!rule!%s!flcache' %
                                   (vsrv_num, r)) == "allow":
                    comment.append('Cache')

                if CTK.cfg.get_val('vserver!%s!rule!%s!timeout' %
                                   (vsrv_num, r)):
                    comment.append('Timeout')

                if CTK.cfg.get_val('vserver!%s!rule!%s!rate' % (vsrv_num, r)):
                    comment.append('Traffic')

                if int(
                        CTK.cfg.get_val(
                            'vserver!%s!rule!%s!no_log' %
                            (vsrv_num, r), "0")) > 0:
                    comment.append('No log')

                # List entry
                row_id = '%s_%s' % (r, vsrv_num)

                if r == rules[-1]:
                    content = [
                        CTK.Box({'class': 'name'}, CTK.RawHTML(rule_name_esc)),
                        CTK.Box({'class': 'comment'},
                                CTK.RawHTML(', '.join(comment)))
                    ]
                    panel.Add(row_id,
                              '/vserver/%s/rule/content/%s' % (vsrv_num, r),
                              content,
                              draggable=False)
                else:
                    # Remove
                    dialog = CTK.Dialog({
                        'title':
                        _('Do you really want to remove it?'),
                        'width':
                        480
                    })
                    dialog.AddButton(_('Cancel'), "close")
                    dialog.AddButton (_('Remove'), CTK.JS.Ajax (url_apply, async=False,
                                                                data    = {'vserver!%s!rule!%s'%(vsrv_num, r):''},
                                                                success = dialog.JS_to_close() + \
                                                                          refresh.JS_to_refresh()))
                    dialog += CTK.RawHTML(
                        _(NOTE_DELETE_DIALOG) % (rule_name_esc))
                    self += dialog
                    remove = CTK.ImageStock('del')
                    remove.bind('click', dialog.JS_to_show() + "return false;")

                    # Disable
                    is_disabled = bool(
                        int(
                            CTK.cfg.get_val(
                                'vserver!%s!rule!%s!disabled' % (vsrv_num, r),
                                "0")))
                    disclass = ('', 'rule-inactive')[is_disabled][:]

                    disabled = CTK.ToggleButtonOnOff(not is_disabled)
                    disabled.bind(
                        'changed',
                        CTK.JS.Ajax(
                            url_apply,
                            async=True,
                            data='{"vserver!%s!rule!%s!disabled": event.value}'
                            % (vsrv_num, r)))
Beispiel #26
0
    def __init__(self, app_name):
        CTK.Box.__init__(self, {'class': 'cherokee-market-app'})

        index = Distro.Index()

        app = index.get_package(app_name, 'software')
        maintainer = index.get_package(app_name, 'maintainer')

        # Install dialog
        install = InstallDialog(app_name)

        # Author
        by = CTK.Container()
        by += CTK.RawHTML('%s ' % (_('By')))
        by += CTK.LinkWindow(app['URL'], CTK.RawHTML(app['author']))

        install_button = CTK.Button(_("Install"))
        install_button.bind('click', install.JS_to_show())

        # Report button
        druid = CTK.Druid(CTK.RefreshableURL())
        report_dialog = CTK.Dialog({
            'title': (_("Report Application")),
            'width': 480
        })
        report_dialog += druid
        druid.bind('druid_exiting', report_dialog.JS_to_close())

        report_link = CTK.Link(None, CTK.RawHTML(_("Report issue")))
        report_link.bind ('click', report_dialog.JS_to_show() + \
                                   druid.JS_to_goto('"%s/%s"'%(URL_REPORT, app_name)))

        report = CTK.Container()
        report += report_dialog
        report += report_link

        # Info
        repo_url = CTK.cfg.get_val('admin!ows!repository', REPO_MAIN)
        url_icon_big = os.path.join(repo_url, app['id'], "icons",
                                    app['icon_big'])

        appw = CTK.Box({'class': 'market-app-desc'})
        appw += CTK.Box({'class': 'market-app-desc-icon'},
                        CTK.Image({'src': url_icon_big}))
        appw += CTK.Box({'class': 'market-app-desc-buy'}, install_button)
        appw += CTK.Box({'class': 'market-app-desc-title'},
                        CTK.RawHTML(app['name']))
        appw += CTK.Box({'class': 'market-app-desc-version'},
                        CTK.RawHTML("%s: %s" % (_("Version"), app['version'])))
        appw += CTK.Box({'class': 'market-app-desc-url'}, by)
        appw += CTK.Box(
            {'class': 'market-app-desc-packager'},
            CTK.RawHTML("%s: %s" %
                        (_("Packager"), maintainer['name'] or _("Orphan"))))
        appw += CTK.Box({'class': 'market-app-desc-category'},
                        CTK.RawHTML("%s: %s" %
                                    (_("Category"), app['category'])))
        appw += CTK.Box({'class': 'market-app-desc-short-desc'},
                        CTK.RawHTML(app['desc_short']))
        appw += CTK.Box({'class': 'market-app-desc-report'}, report)

        # Support
        ext_description = CTK.Box({'class': 'market-app-desc-description'})
        ext_description += CTK.RawHTML(app['desc_long'])
        desc_panel = CTK.Box({'class': 'market-app-desc-desc-panel'})
        desc_panel += ext_description
        desc_panel += CTK.Box({'class': 'market-app-desc-support-box'},
                              SupportBox(app_name))

        # Shots
        shots = CTK.CarouselThumbnails()
        shot_entries = app.get('screenshots', [])

        if shot_entries:
            for s in shot_entries:
                shots += CTK.Image({
                    'src':
                    os.path.join(repo_url, app_name, "screenshots", s)
                })
        else:
            shots += CTK.Box({'id': 'shot-box-empty'},
                             CTK.RawHTML('<h2>%s</h2>' %
                                         (_("No screenshots"))))

        # Tabs
        tabs = CTK.Tab()
        tabs.Add(_('Screenshots'), shots)
        tabs.Add(_('Description'), desc_panel)

        # GUI Layout
        self += appw
        self += tabs
        self += install
Beispiel #27
0
def default(message=None):
    # Authentication
    fail = Auth.assert_is_role(Role.ROLE_ADMIN)
    if fail: return fail

    # List of profiles
    q = "SELECT * FROM profiles;"
    profiles = Query(q)

    table = CTK.Table()
    title = [CTK.RawHTML(x) for x in ['Profile', 'Descripcion', 'Role']]
    table[(1, 1)] = title
    table.set_header(row=True, num=1)

    page = Page.Default()

    n = 2
    for profile in profiles:
        # Fetch data
        profile_id = profiles[profile]['id']
        profile_name = profiles[profile]['name']
        profile_desc = profiles[profile]['description']

        # Role
        q = "SELECT * FROM profiles_has_roles WHERE profiles_id='%s';" % (
            profile_id)
        roles = Query(q)
        profile_roles_str = ', '.join(
            [Role.role_to_name(roles[x]['roles_id']) for x in roles])

        # Delete profile
        dialog = CTK.Dialog({
            'title': "Eliminando profile %s?" % (profile_name),
            'autoOpen': False
        })
        dialog += CTK.RawHTML(NOTE_DELETE)
        dialog.AddButton('Cancelar', "close")
        dialog.AddButton('Borrar', "/admin/profile/del/%s" % (profile_id))

        del_img = '<img src="/CTK/images/del.png" alt="Borrar"'
        linkdel = LINK_JS_ON_CLICK % (dialog.JS_to_show(), del_img)
        linkname = LINK_HREF % ("/admin/profile/%s" % profile_id, profile_name)

        table[(n, 1)] = [
            CTK.RawHTML(linkname),
            CTK.RawHTML(profile_desc),
            CTK.RawHTML(profile_roles_str),
            CTK.RawHTML(linkdel)
        ]

        page += dialog
        n += 1

    # Render
    page += CTK.RawHTML("<h1>%s: Administraci&oacute;n de Profiles</h1>" %
                        (ADMIN_PREFIX))
    page += CTK.RawHTML(LINK_HREF %
                        ('/admin/profile/new', 'A&ntilde;adir profile'))
    page += table

    if message:
        page += Message(message)

    return page.Render()