示例#1
0
文件: base.py 项目: nkhine/ztm-ikaaro
    def get_search_namespace(self, resource, context):
        types = self.get_search_types(resource, context)

        # Build dynamic datatype and widget
        search_type = self._get_query_value(resource, context, 'search_type')
        datatype = Enumerate(options=types)
        widget = SelectWidget(name='search_type', datatype=datatype,
                              value=search_type)
        search_text = self._get_query_value(resource, context, 'search_text')

        # Hidden widgets
        hidden_widgets = []
        for name in self.hidden_fields:
            value = self._get_query_value(resource, context, name)
            hidden_widgets.append({'name': name, 'value': value})

        return {'search_text': search_text,
                'search_types_widget': widget.render(),
                'hidden_widgets': hidden_widgets}
示例#2
0
    def get_search_namespace(self, resource, context):
        orderable_classes = resource.orderable_classes
        enum = Enumerate()
        options = []
        for cls in orderable_classes:
            options.append({'name': cls.class_id, 'value': cls.class_title})
        enum.options = options

        format = context.query['format']
        widget = SelectWidget('format', datatype=enum, value=format)
        namespace = {}
        namespace['format_widget'] = widget.render()
        # is admin popup
        if context.method == 'POST' and context.form_action == 'action':
            # filter by type only forward is_admin_popup
            is_admin_popup = context.get_form_value('is_admin_popup')
        else:
            is_admin_popup = context.get_query_value('is_admin_popup')
        namespace['is_admin_popup'] = is_admin_popup

        return namespace
示例#3
0
文件: popup.py 项目: hforge/itws
def itws_get_table_namespace(self, resource, context, items):
    namespace =  Feed_View.get_table_namespace(self, resource, context, items)
    # Sort by
    widget = SelectWidget('sort_by',
                          datatype=SortBy_Enumerate,
                          value=context.query['sort_by'],
                          has_empty_option=False)
    namespace['sort_by'] = widget.render()
    widget = SelectWidget('reverse',
                          datatype=Reverse_Enumerate,
                          value=str(int(context.query['reverse'])),
                          has_empty_option=False)
    namespace['reverse'] = widget.render()
    for key in ['target', 'target_id', 'mode']:
        namespace[key] = context.get_form_value(key)
    # If target is no defined in the query (when we open the popup)
    # Get the target value from attributes
    if namespace['target'] is None:
        popup_root_abspath = self.popup_root.get_abspath()
        target = popup_root_abspath.get_pathto(self.target.get_abspath())
        namespace['target'] = target
    return namespace
示例#4
0
 def reminders(self):
     return SelectWidget('%s-unit' % self.name,
                         value=self.reminder_value,
                         datatype=Reminder_Unit,
                         has_empty_option=False)