Exemple #1
0
def _edit_sidebar(user, app, context):
    widgets = __get_widget_class_infos()
    sidebars = [
        model.get_widget_instances(0, False), [], [], [], [], [], [], [], [],
        []
    ]
    info = ''
    btn = context.get_argument('btn', '')
    if btn == 'add':
        # add a new widget instance:
        widget_name = context.get_argument('widget_name')
        sidebar = int(context.get_argument('sidebar'))
        title = None
        for w in widgets:
            if w['id'] == widget_name:
                title = w['title']
                break
        info = 'A new widget "%s" was added to sidebar %s.' % (
            title,
            (sidebar + 1),
        )
        model.create_widget_instance(widget_name, sidebar)
    return {
        'info': info,
        '__view__': 'manage_sidebar',
        'widgets': widgets,
        'sidebars': sidebars,
        'theme': theme.get_theme_info(theme.get_current_theme()),
    }
Exemple #2
0
def _edit_sidebar(user, app, context):
    widgets = __get_widget_class_infos()
    sidebars = [
            model.get_widget_instances(0, False),
            [], [], [], [], [],
            [], [], [], []
    ]
    info = ''
    btn = context.get_argument('btn', '')
    if btn=='add':
        # add a new widget instance:
        widget_name = context.get_argument('widget_name')
        sidebar = int(context.get_argument('sidebar'))
        title = None
        for w in widgets:
            if w['id']==widget_name:
                title = w['title']
                break
        info = 'A new widget "%s" was added to sidebar %s.' % (title,(sidebar+1),)
        model.create_widget_instance(widget_name, sidebar)
    return {
            'info' : info,
            '__view__' : 'manage_sidebar',
            'widgets' : widgets,
            'sidebars' : sidebars,
            'theme' : theme.get_theme_info(theme.get_current_theme()),
    }
Exemple #3
0
    def test_get_widget_instances(self):
        model.create_widget_instance('adsense', 0)
        model.create_widget_instance('html', 0)
        instances = model.get_widget_instances(0, False)
        self.assertEquals(2, len(instances))

        self.assertEquals('adsense', instances[0].name)
        self.assertEquals(0, instances[0].sidebar)
        self.assertEquals(0, instances[0].display_order)

        self.assertEquals('html', instances[1].name)
        self.assertEquals(0, instances[1].sidebar)
        self.assertEquals(1, instances[1].display_order)
Exemple #4
0
    def test_get_widget_instances(self):
        model.create_widget_instance('adsense', 0)
        model.create_widget_instance('html', 0)
        instances = model.get_widget_instances(0, False)
        self.assertEquals(2, len(instances))

        self.assertEquals('adsense', instances[0].name)
        self.assertEquals(0, instances[0].sidebar)
        self.assertEquals(0, instances[0].display_order)

        self.assertEquals('html', instances[1].name)
        self.assertEquals(0, instances[1].sidebar)
        self.assertEquals(1, instances[1].display_order)