Ejemplo n.º 1
0
def __handle_get_edit_instance():
    # get widget instances of default group:
    instances = widget.get_widget_instances()
    all_settings = widget.get_all_instances_settings()
    import logging
    for s in all_settings:
        logging.warning('Load all settings: ' + s.setting_name + '=' + s.setting_value)
    widget.bind_instance_model(instances, all_settings)
    for instance in instances:
        wclass = widget.get_installed_widget(instance.widget_id)
        logging.warning('\n\n\n$$\n\n' + str(wclass))
        def_setting_dict = widget.get_widget_settings(wclass)
        logging.warning('\n\n\n###\n\n\n' + str(def_setting_dict))
        ins_settings = store.get_instance_settings(instance)
        # attach ins_settings to def_settings:
        for key in def_setting_dict:
            for ins_setting in ins_settings:
                if key==ins_setting.setting_name:
                    def_setting_dict[key].value = ins_setting.setting_value
        instance.settings = def_setting_dict

    return {
            'template' : 'widget_edit.html',
            'setting_to_html' : widget_setting_to_html,
            'instances' : instances,
            'installed_widgets' : get_installed_widgets_details()
    }
Ejemplo n.º 2
0
def __handle_get_edit_instance():
    # get widget instances of default group:
    instances = widget.get_widget_instances()
    all_settings = widget.get_all_instances_settings()
    import logging
    for s in all_settings:
        logging.warning('Load all settings: ' + s.setting_name + '=' +
                        s.setting_value)
    widget.bind_instance_model(instances, all_settings)
    for instance in instances:
        wclass = widget.get_installed_widget(instance.widget_id)
        logging.warning('\n\n\n$$\n\n' + str(wclass))
        def_setting_dict = widget.get_widget_settings(wclass)
        logging.warning('\n\n\n###\n\n\n' + str(def_setting_dict))
        ins_settings = store.get_instance_settings(instance)
        # attach ins_settings to def_settings:
        for key in def_setting_dict:
            for ins_setting in ins_settings:
                if key == ins_setting.setting_name:
                    def_setting_dict[key].value = ins_setting.setting_value
        instance.settings = def_setting_dict

    return {
        'template': 'widget_edit.html',
        'setting_to_html': widget_setting_to_html,
        'instances': instances,
        'installed_widgets': get_installed_widgets_details()
    }
Ejemplo n.º 3
0
def __handle_post_edit_instance():
    form = context.form
    if form.get('btn') == 'add':
        # add a new widget instance:
        widget_id = form.get('widget_id')
        max = len(widget.get_widget_instances())
        instance = widget.WidgetInstance(widget_id=widget_id, widget_order=max)
        instance.put()
    elif form.get('btn') == 'edit':
        # update:
        instance = widget.get_widget_instance(form.get('id'))
        defaults = widget.get_widget_settings(
            widget.get_installed_widget(instance.widget_id))
        args = form.arguments()
        d = {}
        for arg in args:
            if arg in defaults:
                d[arg] = form.get(arg)
        import logging
        logging.warning('update... ' + str(d))
        store.update_instance_settings(instance, d)
    elif form.get('btn') == 'remove':
        # remove:
        store.delete_widget_instance(form.get('id'))
    return __handle_get_edit_instance()
Ejemplo n.º 4
0
def update_model(rootpath, appname, model):

    # set current theme = 'simple':
    theme = shared.get_setting('theme', 'selected', '')
    if not theme:
        themes = manage.get_themes()
        theme = themes[0]
        shared.save_setting('theme', 'selected', theme)
    model['theme'] = theme
    # add widgets:
    instances = widget.get_widget_instances()
    all_settings = widget.get_all_instances_settings()
    widget.bind_instance_model(instances, all_settings)
    import logging
    model['widgets'] = instances
    model['show_widget__raw__'] = show_widget
    logging.warning('loaded ' + str(instances))
Ejemplo n.º 5
0
def update_model(rootpath, appname, model):

    # set current theme = 'simple':
    theme = shared.get_setting('theme', 'selected', '')
    if not theme:
        themes = manage.get_themes()
        theme = themes[0]
        shared.save_setting('theme', 'selected', theme)
    model['theme'] = theme
    # add widgets:
    instances = widget.get_widget_instances()
    all_settings = widget.get_all_instances_settings()
    widget.bind_instance_model(instances, all_settings)
    import logging
    model['widgets'] = instances
    model['show_widget__raw__'] = show_widget
    logging.warning('loaded ' + str(instances))
Ejemplo n.º 6
0
def __handle_post_edit_instance():
    form = context.form
    if form.get('btn')=='add':
        # add a new widget instance:
        widget_id = form.get('widget_id')
        max = len(widget.get_widget_instances())
        instance = widget.WidgetInstance(widget_id=widget_id, widget_order=max)
        instance.put()
    elif form.get('btn')=='edit':
        # update:
        instance = widget.get_widget_instance(form.get('id'))
        defaults = widget.get_widget_settings(widget.get_installed_widget(instance.widget_id))
        args = form.arguments()
        d = {}
        for arg in args:
            if arg in defaults:
                d[arg] = form.get(arg)
        import logging
        logging.warning('update... ' + str(d))
        store.update_instance_settings(instance, d)
    elif form.get('btn')=='remove':
        # remove:
        store.delete_widget_instance(form.get('id'))
    return __handle_get_edit_instance()