Beispiel #1
0
 def form_widgets(self, fields):
     tagdata = get_tags_client_data(self.context, self.request)
     widgets = {
         'title':
         formish.Input(empty=''),
         'tags':
         karlwidgets.TagsEditWidget(tagdata=tagdata),
         'text':
         karlwidgets.RichTextWidget(empty=''),
         'attachments':
         karlwidgets.AttachmentsSequence(sortable=False,
                                         min_start_fields=0),
         'attachments.*':
         karlwidgets.FileUpload2(filestore=self.filestore),
         'photo':
         karlwidgets.PhotoImageWidget(filestore=self.filestore,
                                      url_base=resource_url(
                                          self.context, self.request),
                                      show_image_thumbnail=True,
                                      show_remove_checkbox=self.photo
                                      is not None),
         'caption':
         formish.Input(empty=''),
         'publication_date':
         karlwidgets.DateTime(
             converter_options={'datetime_format': self.datetime_format},
             js_date_format=self.js_date_format,
         ),
     }
     return widgets
Beispiel #2
0
 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
Beispiel #3
0
 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
Beispiel #4
0
 def form_widgets(self, fields):
     tagdata = get_tags_client_data(self.context, self.request)
     widgets = {'title': formish.Input(empty=''),
                'tags': karlwidgets.TagsEditWidget(tagdata=tagdata),
                'description': formish.TextArea(rows=5, cols=60, empty=''),
                }
     return widgets
Beispiel #5
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)
    }
Beispiel #6
0
 def form_widgets(self, fields):
     widgets = {
         'title': formish.Input(empty=''),
         'tags': karlwidgets.TagsAddWidget(),
         'description': formish.TextArea(rows=5, cols=60, empty=''),
     }
     return widgets
Beispiel #7
0
 def form_widgets(self, fields):
     widgets = {
         'title':
         formish.Input(empty=''),
         'tags':
         karlwidgets.TagsAddWidget(),
         'text':
         karlwidgets.RichTextWidget(empty=''),
         'attachments':
         karlwidgets.AttachmentsSequence(sortable=False,
                                         min_start_fields=0),
         'attachments.*':
         karlwidgets.FileUpload2(filestore=self.filestore),
         'sendalert':
         karlwidgets.SendAlertCheckbox()
     }
     security_states = self._get_security_states()
     schema = dict(fields)
     if 'security_state' in schema:
         security_states = self._get_security_states()
         widgets['security_state'] = formish.RadioChoice(options=[
             (s['name'], s['title']) for s in security_states
         ],
                                                         none_option=None)
     return widgets
Beispiel #8
0
 def form_widgets(self, fields):
     widgets = {
         'title':formish.Input(empty=''),
         'description':formish.TextArea(cols=60, rows=10, empty=''),
         }
     security_states = self._get_security_states()
     schema = dict(fields)
     if 'security_state' in schema:
         security_states = self._get_security_states()
         widgets['security_state'] = formish.RadioChoice(
             options=[ (s['name'], s['title']) for s in security_states],
             none_option=None)
     return widgets
Beispiel #9
0
 def form_widgets(self, fields):
     widgets = {
         'title':
         formish.Input(empty=''),
         'tags':
         karlwidgets.TagsAddWidget(),
         'text':
         karlwidgets.RichTextWidget(empty=''),
         'attachments':
         karlwidgets.AttachmentsSequence(sortable=False,
                                         min_start_fields=0),
         'attachments.*':
         karlwidgets.FileUpload2(filestore=self.filestore),
     }
     return widgets
Beispiel #10
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
Beispiel #11
0
 def form_widgets(self, fields):
     tagdata = get_tags_client_data(self.context, self.request)
     widgets = {
         'title':
         formish.Input(empty=''),
         'tags':
         karlwidgets.TagsEditWidget(tagdata=tagdata),
         'text':
         karlwidgets.RichTextWidget(empty=''),
         'attachments':
         karlwidgets.AttachmentsSequence(sortable=False,
                                         min_start_fields=0),
         'attachments.*':
         karlwidgets.FileUpload2(filestore=self.filestore),
     }
     return widgets
Beispiel #12
0
 def form_widgets(self, fields):
     tagdata = get_tags_client_data(self.context, self.request)
     widgets = {
         'title': formish.Input(empty=''),
         'tags': karlwidgets.TagsEditWidget(tagdata=tagdata),
         'text': karlwidgets.RichTextWidget(empty=''),
     }
     security_states = self._get_security_states()
     schema = dict(fields)
     if 'security_state' in schema:
         security_states = self._get_security_states()
         widgets['security_state'] = formish.RadioChoice(options=[
             (s['name'], s['title']) for s in security_states
         ],
                                                         none_option=None)
     return widgets
Beispiel #13
0
 def test_with_method_GET(self):
     import schemaish
     import validatish
     import formish
     from pyramid_formish.zcml import FormAction
     action = FormAction(None, 'cancel', False)
     title = schemaish.String(validator=validatish.validator.Required())
     actions = [action]
     titlewidget = formish.Input()
     factory = make_controller_factory(fields=[('title', title)],
                                       widgets={'title': titlewidget})
     view = self._makeOne(factory, action, actions, method='GET')
     context = testing.DummyModel()
     request = testing.DummyRequest()
     result = view(context, request)
     self.assertEqual(result.body, '123')
Beispiel #14
0
 def form_widgets(self, fields):
     tagdata = get_tags_client_data(self.context, self.request)
     widgets = {
         'title':formish.Input(empty=''),
         'tags':karlwidgets.TagsEditWidget(tagdata=tagdata),
         'text':karlwidgets.RichTextWidget(empty=''),
         'attachments': karlwidgets.AttachmentsSequence(sortable=False,
                                                        min_start_fields=0),
         'attachments.*':karlwidgets.FileUpload2(filestore=self.filestore),
         }
     security_states = self._get_security_states()
     schema = dict(fields)
     if 'security_state' in schema:
         security_states = self._get_security_states()
         widgets['security_state'] = formish.RadioChoice(
             options=[ (s['name'], s['title']) for s in security_states],
             none_option=None)
     return widgets
Beispiel #15
0
 def test_readonly_field(self):
     """Test a form that has no a read only field"""
     schema_readonly = schemaish.Structure([("a", schemaish.String()),
                                            ("b", schemaish.String())])
     name = "Flat Form"
     request = Request(name)
     form = formish.Form(schema_readonly, name)
     form['a'].widget = formish.Input(readonly=True)
     request = Request(name, {'b': 'bar'})
     actualdata = form.validate(request)
     expecteddata = {'a': None, 'b': 'bar'}
     assert actualdata == expecteddata
     form.defaults = {'a': 'foo'}
     actualdata = form.validate(request)
     expecteddata = {'a': 'foo', 'b': 'bar'}
     assert actualdata == expecteddata
     # XXX Is building a form part of the test? Leaving it in, just in case.
     form()
Beispiel #16
0
 def form_widgets(self, fields):
     widgets = {
         'login': formish.Input(empty=''),
         'password': karlwidgets.KarlCheckedPassword()
     }
     return widgets
Beispiel #17
0
 def form_widgets(self, fields):
     return {'email': formish.Input(empty='')}
Beispiel #18
0
 def form_widgets(self, fields):
     api = TemplateAPI(self.context, self.request, self.page_title)
     default_icon = '%s/images/defaultUser.gif' % api.static_url
     show_remove_checkbox = self.photo is not None
     widgets = {
         'firstname':
         formish.Input(empty=''),
         'lastname':
         formish.Input(empty=''),
         'email':
         formish.Input(),
         'phone':
         formish.Input(empty=''),
         'extension':
         formish.Input(empty=''),
         'fax':
         formish.Input(empty=''),
         'department':
         formish.Input(empty=''),
         'position':
         formish.Input(empty=''),
         'organization':
         formish.Input(empty=''),
         'location':
         formish.Input(empty=''),
         'country':
         formish.SelectChoice(options=countries),
         'websites':
         formish.TextArea(rows=3, converter_options={'delimiter': '\n'}),
         'languages':
         formish.Input(empty=''),
         'photo':
         karlwidgets.PhotoImageWidget(
             filestore=self.filestore,
             url_base=resource_url(self.context, self.request),
             image_thumbnail_default=default_icon,
             show_remove_checkbox=show_remove_checkbox),
         'biography':
         karlwidgets.RichTextWidget(empty=''),
         'date_format':
         karlwidgets.VerticalRadioChoice(options=cultures,
                                         none_option=None),
     }
     return widgets