Пример #1
0
    def navigation_widget_breadcrumbs(self):
        """Views for the "breadcrumbs" display type, which is essentially the
           same as Kotti's default breadcrumbs display, except that here you
           have control of the associated label.
             - They each use the general navigation_widget_breadcrumbs()
               function.
        """
        resource_group.need()
        root = get_root()
        options = get_setting(self.location + "_options", default=[])
        include_root = "include_root" in options
        label = parse_label(self.context.title, get_setting(self.location + "_label"))

        # When the nav display is set to the beforebodyend slot, the class
        # for the containing div needs to be 'container' so it fits to the
        # middle span12 area for content. When nav is in any of the other
        # slots, no class is needed, because the inherited CSS works to fit
        # nav to the slot.
        use_container_class = self.location == "beforebodyend"

        lineage_items = get_lineage(self.context, self.request, self.location)
        if not include_root and root in lineage_items:
            lineage_items.remove(root)

        lineage_items.reverse()

        return {
            "location": self.location,
            "use_container_class": use_container_class,
            "label": label,
            "lineage_items": lineage_items,
        }
Пример #2
0
def test_get_setting_not_found(db_session, root):
    from kotti_settings.util import get_setting

    setting = get_setting('not_exiting_setting')
    assert setting == None
    setting = get_setting('not_exiting_setting', 'default')
    assert setting == 'default'
Пример #3
0
def grid_widget(context, request):
    show_in_context = get_setting(u'show_in_context')
    show = False
    if show_in_context == u'everywhere':
        show = True
    elif show_in_context == u'only on root':
        show = context == get_root()
    elif show_in_context == u'not on root':
        show = context != get_root()
    elif show_in_context == u'nowhere':
        show = False
    if show:
        from js.jquery_colorpicker import jquery_colorpicker
        from js.gridster import gridster
        jquery_colorpicker.need()
        gridster.need()
    return {
        'tiles': grid_settings()['tiles'],
        'tile_content': tile_content,
        'show': show,
        'dimension_x': get_setting(u'dimension_x', 150),
        'dimension_y': get_setting(u'dimension_y', 150),
        'margin_x': get_setting(u'margin_x', 10),
        'margin_y': get_setting(u'margin_y', 10)
    }
Пример #4
0
 def serialize(self, field, cstruct, readonly=False):
     from kotti_settings.util import get_setting
     if cstruct in (null, None):
         cstruct = ''
     template = readonly and self.readonly_template or self.template
     return field.renderer(template, field=field, cstruct=cstruct,
                           public_key=get_setting('public_key'),
                           theme=get_setting('recaptcha_theme')
                           )
Пример #5
0
def get_nav_class(location):
    """Build up a nav class for the navigation items.
    """
    display_manner = get_setting(location + '_display_manner', default='pills')
    options = get_setting(location + '_options', default=[])
    nav_class = 'nav nav-{0}'.format(display_manner)
    if 'stacked' in options:
        nav_class += ' nav-stacked'
    return nav_class
Пример #6
0
    def navigation_widget_top(self):
        """View for the special-case top location, which must be handled this
           way because Kotti's own default nav display must be overridden, and
           because the top location is not a simple "slot." It consists of a
           navbar at the very top, and a div location underneath that, as used
           here. The menu (represented by a single button) is appropriate for
           use within the navbar, but not so for the other display types, which
           are put in the div underneath.
           The driver for these views is the overridden nav.pt, which you will
           find in /kotti-overrides/templates/view/nav.pt.
        """
        display_type = get_setting(self.location + '_display_type')

        options = get_setting(self.location + '_options', default=[])
        include_root = 'include_root' in options
        label = get_setting(self.location + '_label')
        show_menu = 'show_menu' in options

        top_properties = {}

        if display_type == 'items':
            tree_properties = self.navigation_widget_items()

        elif display_type == 'tree' and 'list' in options:
            tree_properties = self.navigation_widget_items()

        elif display_type == 'tree':
            display_manner = get_setting(self.location + '_display_manner')
            tree_is_open_all = 'open_all' in options

            tree_properties = self.navigation_widget_tree()

            tree_properties['nav_class'] = \
                'nav nav-{0} nav-stacked'.format(display_manner)
            tree_properties['tree_is_open_all'] = tree_is_open_all
            tree_properties['is_node_open'] = is_node_open

            top_properties = tree_properties

        elif display_type == 'breadcrumbs':
            top_properties = self.navigation_widget_breadcrumbs()

        elif display_type == 'menu':
            top_properties = self.navigation_widget_menu()

        top_properties['location'] = 'top'
        top_properties['display_type'] = display_type
        top_properties['include_root'] = include_root
        top_properties['label'] = label
        top_properties['show_menu'] = show_menu

        return top_properties
Пример #7
0
    def navigation_widget(self):
        show_here = get_setting(self.location + "_show_in_context")
        show = show_in_context(show_here, self.context)

        if not show:
            raise PredicateMismatch()

        display_type = get_setting(self.location + "_display_type")
        if not display_type:
            raise PredicateMismatch()

        view_name = "navigation-widget-" + display_type
        return render_view(self.context, self.request, name=view_name)
Пример #8
0
    def navigation_widget_top(self):
        """View for the special-case top location, which must be handled this
           way because Kotti's own default nav display must be overridden, and
           because the top location is not a simple "slot." It consists of a
           navbar at the very top, and a div location underneath that, as used
           here. The menu (represented by a single button) is appropriate for
           use within the navbar, but not so for the other display types, which
           are put in the div underneath.
           The driver for these views is the overridden nav.pt, which you will
           find in /kotti-overrides/templates/view/nav.pt.
        """
        display_type = get_setting(self.location + "_display_type")

        options = get_setting(self.location + "_options", default=[])
        include_root = "include_root" in options
        label = get_setting(self.location + "_label")
        show_menu = "show_menu" in options

        top_properties = {}

        if display_type == "items":
            tree_properties = self.navigation_widget_items()

        elif display_type == "tree" and "list" in options:
            tree_properties = self.navigation_widget_items()

        elif display_type == "tree":
            tabs_or_pills = "tabs" if "tabs" in options else "pills"
            tree_is_open_all = "open_all" in options

            tree_properties = self.navigation_widget_tree()

            tree_properties["nav_class"] = "nav nav-{0} nav-stacked".format(tabs_or_pills)
            tree_properties["tree_is_open_all"] = tree_is_open_all
            tree_properties["is_node_open"] = is_node_open

            top_properties = tree_properties

        elif display_type == "breadcrumbs":
            top_properties = self.navigation_widget_breadcrumbs()

        elif display_type == "menu":
            top_properties = self.navigation_widget_menu()

        top_properties["location"] = "top"
        top_properties["display_type"] = display_type
        top_properties["include_root"] = include_root
        top_properties["label"] = label
        top_properties["show_menu"] = show_menu

        return top_properties
Пример #9
0
def grid_widget(context, request):
    show = show_in_context(get_setting(u"show_in_context"), context)
    if show:
        kotti_grid.need()
        return {
            "tiles": grid_settings()["tiles"],
            "tile_content": tile_content,
            "show": show,
            "width": get_setting(u"width", 150),
            "height": get_setting(u"height", 150),
            "margin_x": get_setting(u"margin_x", 10),
            "margin_y": get_setting(u"margin_y", 10),
        }
    raise (PredicateMismatch)
Пример #10
0
    def nav_recurse(self):
        """Recursive view for the "tree" display type.
        """
        display_manner = get_setting(self.location + '_display_manner', default='pills')
        options = get_setting(self.location + '_options', default=[])
        tree_is_open_all = 'open_all' in options
        nav_class = get_nav_class(self.location)

        return {'tree_is_open_all': tree_is_open_all,
                'is_node_open': is_node_open,
                'nav_class': nav_class,
                'children': get_children(self.context,
                                         self.request,
                                         self.location),
                }
Пример #11
0
def deferred_default_sender(node, kw):
    sender = kw.get('sender')
    if not sender:
        sender = get_setting(
            'default_sender',
            get_settings().get('mail.default_sender', ''))
    return sender
Пример #12
0
def _check_children(request, location, children):
    user = the_user(request)
    options = get_setting(location + '_options', default=[])
    show_hidden = 'show_hidden_while_logged_in' in options
    content_types_to_include = get_setting(location + '_include')
    content_types_to_exclude = get_setting(location + '_exclude')

    if not (show_hidden and user):
        children = [c for c in children if c.in_navigation]
    if content_types_to_include:
        children = [c for c in children
                    if c.type_info.name in content_types_to_include]
    if content_types_to_exclude:
        children = [c for c in children
                    if c.type_info.name not in content_types_to_exclude]
    return children
Пример #13
0
    def navigation_widget_tree(self):
        """Views for display type "tree", continued:
          - These are the main views for the tree display type, each using the
            general navigation_widget_tree() view function.
          - The nav recurse view above is called from nav_widget_tree.pt,
            used in each of these.
        """
        resource_group.need()
        root = get_root()

        display_type = get_setting(self.location + '_display_type')
        options = get_setting(self.location + '_options')
        if 'dropdowns' in options:
            dropdown_resource_group.need()

        include_root = 'include_root' in options
        show_menu = 'show_menu' in options
        label = get_setting(self.location + '_label')
        if label:
            label = parse_label(self.context.title, label)

        # When the nav display is set to the beforebodyend slot, the class
        # for the containing div needs to be 'container' so it fits to the
        # middle span12 area for content. When nav is in any of the other
        # slots, no class is needed, because the inherited CSS works to fit
        # nav to the slot.
        use_container_class = self.location == 'beforebodyend'

        items = get_children(root, self.request, self.location)
        tree_is_open_all = 'open_all' in options
        nav_class = get_nav_class(self.location)

        return {'location': self.location,
                'root': root,
                'display_type': display_type,
                'include_root': include_root,
                'show_menu': show_menu,
                'show_divider': show_menu and self.location != 'top' and items,
                'nav_class': nav_class,
                'tree_is_open_all': tree_is_open_all,
                'is_node_open': is_node_open,
                'use_container_class': use_container_class,
                'items': items,
                'label': label,
                'dropdowns': 'dropdowns' in options,
                'hidden': ''}
Пример #14
0
def set_assigned_slot(event):
    """Reset the widget to the enabled slots."""
    if get_setting(u'left_display_type'):
        if not widget_in_slot('navigation-widget', 'left'):
            assign_slot('navigation-widget', 'left')
    if get_setting(u'right_display_type'):
        if not widget_in_slot('navigation-widget', 'right'):
            assign_slot('navigation-widget', 'right')
    if get_setting(u'abovecontent_display_type'):
        if not widget_in_slot('navigation-widget', 'abovecontent'):
            assign_slot('navigation-widget', 'abovecontent')
    if get_setting(u'belowcontent_display_type'):
        if not widget_in_slot('navigation-widget', 'belowcontent'):
            assign_slot('navigation-widget', 'belowcontent')
    if get_setting(u'beforebodyend_display_type'):
        if not widget_in_slot('navigation-widget', 'beforebodyend'):
            assign_slot('navigation-widget', 'beforebodyend')
Пример #15
0
def tagcloud_widget(context, request):
    show = show_in_context(get_setting(u'show_in_context'), context)
    if show:
        tags = Tag.query.all()
        if tags:
            from kotti_tagcloud.fanstatic import tagcloud
            tagcloud.need()
            return {'tags': tags}
    raise(PredicateMismatch)
Пример #16
0
def populate():
    add_settings(NavigationSettingsLeft)
    add_settings(NavigationSettingsRight)
    add_settings(NavigationSettingsTop)
    add_settings(NavigationSettingsAboveContent)
    add_settings(NavigationSettingsBelowContent)
    add_settings(NavigationSettingsBeforeBodyEnd)

    if get_setting(u'left_display_type'):
        assign_slot(u'navigation-widget', 'left')
    if get_setting(u'right_display_type'):
        assign_slot(u'navigation-widget', 'right')
    if get_setting(u'abovecontent_display_type'):
        assign_slot(u'navigation-widget', 'abovecontent')
    if get_setting(u'belowcontent_display_type'):
        assign_slot(u'navigation-widget', 'belowcontent')
    if get_setting(u'beforebodyend_display_type'):
        assign_slot(u'navigation-widget', 'beforebodyend')
Пример #17
0
    def navigation_widget_items(self):
        """Views for the "items" display type, a term used to avoid confusion
           that comes with calling this a "list" -- there are horizontal lists
           and there are vertical aspect lists. We distinguish here that the
           following views are not recursive and tree-like. They offer a
           limited list of items for the current context.
           - They each use the general navigation_widget_items() view function.
        """
        resource_group.need()

        display_type = get_setting(self.location + '_display_type')
        options = get_setting(self.location + '_options', default=[])
        nav_class = get_nav_class(self.location)

        # When the nav display is set to the beforebodyend slot, the class
        # for the containing div needs to be 'container' so it fits to the
        # middle span12 area for content. When nav is in any of the other
        # slots, no class is needed, because the inherited CSS works to fit
        # nav to the slot.
        use_container_class = self.location == 'beforebodyend'

        items = get_children(self.context, self.request, self.location)

        allowed_children = []
        for item in items:
            ac = get_children(item, self.request, self.location)
            allowed_children.append(ac if ac else [])

        label = parse_label(self.context.title,
                            get_setting(self.location + '_label'))

        careted = (display_type == 'items') and\
                    ('dropdowns' in options)

        return {'location': self.location,
                'items': items,
                'display_type': display_type,
                'nav_class': nav_class,
                'use_container_class': use_container_class,
                'show_menu': 'show_menu' in options,
                'allowed_children': allowed_children,
                'label': label,
                'dropdowns': 'dropdowns' in options,
            }
Пример #18
0
    def navigation_widget_tree(self):
        """Views for display type "tree", continued:
          - These are the main views for the tree display type, each using the
            general navigation_widget_tree() view function.
          - The nav recurse view above is called from nav_widget_tree.pt,
            used in each of these.
        """
        resource_group.need()
        root = get_root()

        display_type = get_setting(self.location + "_display_type")
        options = get_setting(self.location + "_options")

        include_root = "include_root" in options
        show_menu = "show_menu" in options
        label = get_setting(self.location + "_label")
        if label:
            label = parse_label(self.context.title, label)

        # When the nav display is set to the beforebodyend slot, the class
        # for the containing div needs to be 'container' so it fits to the
        # middle span12 area for content. When nav is in any of the other
        # slots, no class is needed, because the inherited CSS works to fit
        # nav to the slot.
        use_container_class = self.location == "beforebodyend"

        items = get_children(root, self.request, self.location)
        tree_is_open_all = "open_all" in options
        nav_class = get_nav_class(options)

        return {
            "location": self.location,
            "root": root,
            "display_type": display_type,
            "include_root": include_root,
            "show_menu": show_menu,
            "show_divider": show_menu and self.location != "top" and items,
            "nav_class": nav_class,
            "tree_is_open_all": tree_is_open_all,
            "is_node_open": is_node_open,
            "use_container_class": use_container_class,
            "items": items,
            "label": label,
        }
Пример #19
0
def set_assigned_slot(event):
    """Reset the widget to the choosen slot."""

    # Check if the settings for this module was saved.
    if not event.module == __package__:
        return

    slot = get_setting('slot', u'left')
    remove_from_slots('tagcloud-widget')
    assign_slot('tagcloud-widget', slot)
Пример #20
0
def view_contactform(context, request):

    locale_name = get_locale_name(request)

    tmpstore = FileUploadTempStore(request)

    def file_size_limit(node, value):
        value["fp"].seek(0, 2)
        size = value["fp"].tell()
        value["fp"].seek(0)
        max_size = 10
        if size > max_size * 1024 * 1024:
            msg = _("Maximum file size: ${size}MB", mapping={"size": max_size})
            raise colander.Invalid(node, msg)

    def maybe_show(node, kw):
        if kw.get("show_attachment", True) is False:
            del node["attachment"]
        if kw.get("show_captcha", False) is False:
            del node["captcha"]

    class SubmissionSchema(colander.MappingSchema):

        name = colander.SchemaNode(colander.String(), title=_("Full Name"))
        sender = colander.SchemaNode(colander.String(), validator=colander.Email(), title=_("E-Mail Address"))
        subject = colander.SchemaNode(colander.String(), title=_("Subject"))
        content = colander.SchemaNode(
            colander.String(), widget=TextAreaWidget(cols=40, rows=5), title=_("Your message")
        )
        attachment = colander.SchemaNode(
            FileData(),
            title=_("Attachment"),
            widget=FileUploadWidget(tmpstore),
            validator=file_size_limit,
            missing=None,
        )
        captcha = colander.SchemaNode(colander.String(), title=_("Captcha"), widget=deferred_recaptcha_widget)
        _LOCALE_ = colander.SchemaNode(colander.String(), widget=HiddenWidget(), default=locale_name)

    schema = SubmissionSchema(after_bind=maybe_show)
    schema = schema.bind(
        show_attachment=context.show_attachment, show_captcha=get_setting("show_captcha", False), request=request
    )
    form = Form(schema, buttons=[Button("submit", _("Submit"))])
    appstruct = None
    rendered_form = None
    if "submit" in request.POST:
        controls = request.POST.items()
        try:
            appstruct = form.validate(controls)
            mail_submission(context, request, appstruct)
        except ValidationFailure, e:
            appstruct = None
            rendered_form = e.render()
Пример #21
0
 def view_blog(self):
     macros = get_renderer('templates/macros.pt').implementation()
     query = DBSession.query(BlogEntry)
     query = query.filter(BlogEntry.parent_id == self.context.id)
     query = query.order_by(BlogEntry.date.desc())
     items = query.all()
     items = [item for item in items if has_permission('view', item, self.request)]
     page = self.request.params.get('page', 1)
     use_pagination = get_setting('use_pagination')
     if use_pagination:
         items = Batch.fromPagenumber(items,
                     pagesize=get_setting('pagesize'),
                     pagenumber=int(page))
     return {
         'api': template_api(self.context, self.request),
         'macros': macros,
         'items': items,
         'use_pagination': use_pagination,
         'link_headline': get_setting('link_headline'),
         }
Пример #22
0
def set_assigned_slot(event):
    """Reset the widget to the choosen slot."""

    # Check if the settings for this module was saved.
    if not event.module == __package__:  # pragma: no cover
        return

    slot = get_setting("slot", u"left")
    names = [name[0] for name in slot_names]

    remove_from_slots("grid-widget")
    assign_slot("grid-widget", slot)
Пример #23
0
def grid_settings(context, request):
    return {'resize_tiles': get_setting(u'resize_tiles', False),
            'width': get_setting(u'width', 150),
            'height': get_setting(u'height', 150),
            'margin_x': get_setting(u'margin_x', 10),
            'margin_y': get_setting(u'margin_y', 10),
            'slot': get_setting(u'slot', 'belowcontent')}
Пример #24
0
def test_set_setting_conversion(db_session, root):
    from kotti.sqla import NestedMutationList
    from kotti_settings.util import get_setting
    from kotti_settings.util import set_setting

    set_setting('kotti_settings-test_conversion', set(['a', 'b', 'c']))
    setting = get_setting('test_conversion')
    assert type(setting) == NestedMutationList

    # We sort this because we can't rely on the order in a set.
    setting = list(setting)
    setting.sort()
    assert setting == ['a', 'b', 'c']
Пример #25
0
 def view_blog(self):
     macros = get_renderer('templates/macros.pt').implementation()
     query = DBSession.query(BlogEntry)
     query = query.filter(BlogEntry.parent_id == self.context.id)
     query = query.order_by(BlogEntry.date.desc())
     items = query.all()
     items = [
         item for item in items
         if has_permission('view', item, self.request)
     ]
     page = self.request.params.get('page', 1)
     use_pagination = get_setting('use_pagination')
     if use_pagination:
         items = Batch.fromPagenumber(items,
                                      pagesize=get_setting('pagesize'),
                                      pagenumber=int(page))
     return {
         'api': template_api(self.context, self.request),
         'macros': macros,
         'items': items,
         'use_pagination': use_pagination,
         'link_headline': get_setting('link_headline'),
     }
Пример #26
0
def test_get_setting(db_session, root):
    from kotti_settings.util import add_settings
    from kotti_settings.util import get_setting
    test_settings = {
        'name': 'test-get-setting',
        'title': "Some test settings.",
        'settings': [
            {'type': 'String',
             'name': 'first_test_setting',
             'title': 'first test setting',
             'default': 'first test string', },
            {'type': 'Integer',
             'name': 'second_test_setting',
             'title': 'second test setting',
             'default': 5, },
        ]
    }
    add_settings(test_settings)

    first = get_setting('first_test_setting')
    assert first == 'first test string'
    second = get_setting('kotti_settings-second_test_setting')
    assert second == 5
Пример #27
0
    def deserialize(self, field, pstruct):

        from kotti_settings.util import get_setting

        if pstruct is null:
            return null

        challenge = pstruct.get('recaptcha_challenge_field') or ''
        if not challenge:
            raise Invalid(field.schema, 'Missing challenge')

        response = pstruct.get('recaptcha_response_field') or ''
        if not response:
            raise Invalid(field.schema, 'No input')

        privatekey = get_setting('private_key')
        remoteip = self.request.remote_addr
        data = urlencode(dict(privatekey=privatekey,
                              remoteip=remoteip,
                              challenge=challenge,
                              response=response))
        h = httplib2.Http(timeout=10)
        try:
            resp, content = h.request(self.url, "POST", headers=self.headers,
                                      body=data)
        except AttributeError as e:
            if e == "'NoneType' object has no attribute 'makefile'":
                ## XXX: catch a possible httplib regression in 2.7 where
                ## XXX: there is no connextion made to the socker so
                ## XXX sock is still None when makefile is called.
                raise Invalid(field.schema,
                              _("Could not connect to the captcha service."))

        if not resp['status'] == '200':
            raise Invalid(field.schema,
                          "There was an error talking to the recaptcha \
                          server{0}".format(resp['status']))

        valid, reason = content.split('\n')

        if not valid == 'true':
            if reason == 'incorrect-captcha-sol':
                reason = _(u"Incorrect solution")
            raise Invalid(field.schema, reason.replace('\\n', ' ').strip("'"))

        return reason
Пример #28
0
    def nav_recurse(self):
        """Recursive view for the "tree" display type.
        """
        options = get_setting(self.location + "_options", default=[])
        tabs_or_pills = "tabs" if "tabs" in options else "pills"
        tree_is_open_all = "open_all" in options

        nav_class = "nav nav-{0}".format(tabs_or_pills)
        if "stacked" in options:
            nav_class += " {0}-stacked".format(tabs_or_pills)

        return {
            "tree_is_open_all": tree_is_open_all,
            "is_node_open": is_node_open,
            "nav_class": nav_class,
            "children": get_children(self.context, self.request, self.location),
        }
Пример #29
0
    def navigation_widget_menu(self):
        """Views for the "menu" display type, which consists of a single button
           with a dropdown for presenting a full site context menu.
           - They each use the general navigation_widget_menu() view function.
           - The menu can be used standalone as the only nav display in a given
             location, or it can be combined with a label and/or another
             display type, e.g. a horizontal items nav display.
        """
        resource_group.need()
        root = get_root()
        options = get_setting(self.location + "_options", default=[])
        include_root = "include_root" in options

        # When the nav display is set to the beforebodyend slot, the class
        # for the containing div needs to be 'container' so it fits to the
        # middle span12 area for content. When nav is in any of the other
        # slots, no class is needed, because the inherited CSS works to fit
        # nav to the slot.
        use_container_class = self.location == "beforebodyend"

        items = get_children(self.context, self.request, self.location)

        top_level_items = get_children(root, self.request, self.location)

        # The lineage function of pyramid is used to make a breadcrumbs-style
        # display for the context menu.
        lineage_items = get_lineage(self.context, self.request, self.location)
        if not include_root and root in lineage_items:
            lineage_items.remove(root)

        # The lineage comes back in root-last order, so reverse.
        lineage_items.reverse()

        # The lineage (breadcrumbs style) display in navigation.pt shows
        # lineage_items in an indented dropdown list, and below that has a li
        # repeat on items, indented beneath context.

        return {
            "root": root,
            "location": self.location,
            "items": items,
            "use_container_class": use_container_class,
            "include_root": include_root,
            "top_level_items": top_level_items,
            "lineage_items": lineage_items,
        }
Пример #30
0
def set_assigned_slot(event):
    """Reset the widget to the choosen slot."""

    # Check if the settings for this module was saved.
    if not event.module == __package__:
        return

    slot = get_setting('slot', u'left')
    names = [name[0] for name in slot_names]

    # This is somewhat awkward. We check all slots if the widget is already
    # set and remove it from the listener before we set it to another one.
    for slot_event in slot_events:
        if slot_event.name not in names:
            continue
        try:
            listener = objectevent_listeners[(slot_event, None)]
        except TypeError:
            listener = None
        if listener is not None:
            for func in listener:
                if func.func_closure[1].cell_contents == 'grid-widget':
                    listener.remove(func)
    assign_slot('grid-widget', slot)
Пример #31
0
        _LOCALE_ = colander.SchemaNode(
            colander.String(),
            widget=HiddenWidget(),
            default=locale_name)

    schema = SubmissionSchema(after_bind=maybe_show)
    schema = schema.bind(show_attachment=context.show_attachment,
                         show_captcha=get_setting('show_captcha', False),
                         request=request)
    form = Form(schema, buttons=[Button('submit', _('Submit'))])
    appstruct = None
    rendered_form = None
    if 'submit' in request.POST:
        controls = request.POST.items()
        try:
            appstruct = form.validate(controls)
        except ValidationFailure, e:
            appstruct = None
            rendered_form = e.render()
        else:
            mail_submission(context, request, appstruct)
            request.session.flash(_('Thanks for your submission!'), 'success')
    else:
        rendered_form = form.render()
    return {
        'form': rendered_form,
        'appstruct': appstruct,
        'use_captcha': get_setting('use_captcha'),
        'api': template_api(context, request),
    }
Пример #32
0
def contentpreview_settings(context, request):
    return {'view_name': get_setting('view_name'),
            'window_size': get_setting('window_size'),
            'delay_show': get_setting('delay_show'),
            'delay_hide': get_setting('delay_hide')}
Пример #33
0
def social_media_buttons(context, request):
    social_media_buttons = get_setting('social_media_buttons', [])
    if social_media_buttons:
        social_media_buttons = [str(button) for button in social_media_buttons]
    return {'social_media_buttons': social_media_buttons}
Пример #34
0
def use_auto_pagination(context, request):
    return {'use_auto_pagination': get_setting('use_auto_pagination')}
Пример #35
0
def populate():
    add_settings(GridSettings)
    slot = get_setting(u'slot', u'belowcontent')
    assign_slot('grid-widget', slot)
Пример #36
0
def populate():
    add_settings(TagcloudSettings)
    slot = get_setting('slot', u'left')
    assign_slot('tagcloud-widget', slot)