Example #1
0
def shared_widgets(context):
    return {
        'title': formish.Input(empty=''),
        'description': formish.TextArea(cols=60, rows=10, empty=''),
        'text': karlwidgets.RichTextWidget(empty=''),
        'tools': formish.CheckboxMultiChoice(options=context.tools)
    }
Example #2
0
File: people.py Project: zagy/karl
 def form_widgets(self, fields):
     widgets = super(AddUserFormController, self).form_widgets(fields)
     groups_widget = formish.CheckboxMultiChoice(self.group_options)
     widgets.update({'login': formish.Input(empty=''),
                     'groups': groups_widget,
                     'home_path': formish.Input(empty=''),
                     'password': karlwidgets.KarlCheckedPassword()})
     return widgets
Example #3
0
 def test_renders_with_options(self):
     schema = schemaish.Structure()
     schema.add('foo', schemaish.Sequence(schemaish.String()))
     form = formish.Form(schema)
     form['foo'].widget = formish.CheckboxMultiChoice(options=[('opt1',
                                                                'Opt #1')])
     html = form()
     assert 'foo' in html
     assert 'opt1' in html
     assert 'Opt #1' in html
Example #4
0
File: people.py Project: zagy/karl
 def form_widgets(self, fields):
     widgets = super(AdminEditProfileFormController, self
                    ).form_widgets(fields)
     if self.user is not None:
         groups_widget = formish.CheckboxMultiChoice(self.group_options)
         widgets.update({'login': formish.Input(empty=''),
                         'groups': groups_widget,
                         'password': karlwidgets.KarlCheckedPassword(),
                        })
     widgets.update({'home_path': formish.Input(empty=''),
                     'websites': formish.TextArea(
                         rows=3,
                         converter_options={'delimiter':'\n'}),
                    })
     return widgets
Example #5
0
    def test_complex_form(self):

        one = schemaish.Structure([
            ("a", schemaish.String(validator=v.All(v.Email(), v.Required()))),
            ("b", schemaish.String()),
            ("c", schemaish.Sequence(schemaish.Integer()))
        ])
        two = schemaish.Structure([("a", schemaish.String()), ("b", schemaish.Date()),\
                         ('c', schemaish.Sequence(schemaish.String())), ("d", schemaish.String()), \
                         ("e", schemaish.Integer(validator=v.Required())), ("f", schemaish.String(validator=v.Required())) ])
        schema = schemaish.Structure([("one", one), ("two", two)])
        f = formish.Form(schema, name="form", add_default_action=False)

        f['one.b'].widget = formish.TextArea()
        f['two.a'].widget = formish.SelectChoice(
            [('opt1', "Options 1"), ('opt2', "Option 2")],
            none_option=('-select option-', None))
        f['two.b'].widget = formish.DateParts()
        f['two.c'].widget = formish.CheckboxMultiChoice([('opt1', "Options 1"),
                                                         ('opt2', "Option 2")])
        f['two.d'].widget = formish.RadioChoice([('opt1', "Options 1"),
                                                 ('opt2', "Option 2")])
        f['two.f'].widget = formish.CheckedPassword()

        f.add_action('submit', "Submit Me")
        f.defaults = {
            'one': {
                'a': 'ooteenee',
                'c': ['3', '4', '5']
            },
            'two': {
                'a': 'opt1',
                'b': date(1966, 1, 3),
                'c': ['opt2'],
                'd': 'opt2'
            }
        }
        f()
Example #6
0
    def form_widgets(self, fields):
        widgets = super(AdminFCBase, self).form_widgets(fields)
        if self.user is not None:
            groups_widget = formish.CheckboxMultiChoice(self.group_options)
            widgets.update({
                'login': formish.Input(empty=''),
                'groups': groups_widget,
            })
        widgets['home_path'] = formish.Input(empty='')
        if self.is_staff:
            widgets['former_staff_action'] = VerticalRadioChoice(
                options=(
                    (None, 'No action'),
                    ('remove_and_notify', 'Remove user from all communities '
                     'and notify moderators'),
                    ('remove_only', 'Remove user from all communities without '
                     'notifying moderators'),
                ),
                none_option=None,
            )
        elif self.user is not None:
            widgets['password'] = karlwidgets.KarlCheckedPassword()

        return widgets