Exemple #1
0
    def fields(self):
        provider = plugin.ProjectRegistrationProvider.get()
        tools_options = []
        for ep, tool in six.iteritems(g.entry_points["tool"]):
            if tool.status == 'production' and tool._installable(tool_name=ep,
                                                                 nbhd=c.project.neighborhood,
                                                                 project_tools=[]):
                tools_options.append(ew.Option(label=tool.tool_label, html_value=ep))

        return ew_core.NameList([
            ew.HiddenField(name='project_description', label='Public Description'),
            ew.HiddenField(name='neighborhood', label='Neighborhood'),
            ew.Checkbox(name='private_project', label="", attrs={'class': 'unlabeled'}),
            ew.InputField(name='project_name', label='Project Name',
                          field_type='text',
                          validator=formencode.All(
                              V.UnicodeString(not_empty=True, max=40),
                              V.MaxBytesValidator(max=40)),
                          ),
            ew.InputField(name='project_unixname',
                          label='Short Name', field_type='text',
                          attrs={
                              'title': 'Create a URL name that matches your project name as closely as possible to improve search indexing and maximize visibility.',
                              'class': 'tooltip'
                          },
                          validator=provider.shortname_validator),
            ew.CheckboxSet(name='tools', options=tools_options),
        ])
Exemple #2
0
 class fields(ew_core.NameList):
     project_description = ew.HiddenField(label='Public Description')
     neighborhood = ew.HiddenField(label='Neighborhood')
     private_project = ew.Checkbox(label="", attrs={'class': 'unlabeled'})
     project_name = ew.InputField(label='Project Name',
                                  field_type='text',
                                  validator=formencode.All(
                                      fev.UnicodeString(not_empty=True,
                                                        max=40),
                                      V.MaxBytesValidator(max=40)))
     project_unixname = ew.InputField(
         label='Short Name',
         field_type='text',
         validator=formencode.All(
             fev.String(not_empty=True), fev.MinLength(3),
             fev.MaxLength(15),
             fev.Regex(
                 r'^[A-z][-A-z0-9]{2,}$',
                 messages={
                     'invalid':
                     'Please use only letters, numbers, and dashes 3-15 characters long.'
                 }), NeighborhoodProjectTakenValidator()))
     tools = ew.CheckboxSet(
         name='tools',
         options=[
             ## Required for Neighborhood functional tests to pass
             ew.Option(label='Wiki', html_value='wiki', selected=True)
         ])
Exemple #3
0
 def fields(self):
     fields = [
         ew.InputField(name='screenshot',
                       field_type='file',
                       label='New Screenshot'),
         ew.InputField(name='caption', field_type="text", label='Caption')
     ]
     return fields
Exemple #4
0
class PostFilter(ff.ForgeForm):
    defaults = dict(
        ew.SimpleForm.defaults,
        submit_text=None,
        method='GET')
    fields = [
        ew.HiddenField(
            name='page',
            validator=fev.Int()),
        ew.FieldSet(label='Post Filter', fields=[
            ew.SingleSelectField(
                    name='status',
                    label='Show posts with status',
                    options=[
                        ew.Option(py_value='-', label='Any'),
                        ew.Option(py_value='spam', label='Spam'),
                        ew.Option(py_value='pending',
                                  label='Pending moderation'),
                        ew.Option(py_value='ok', label='Ok')],
                    if_missing='pending'),
            ew.InputField(name='username',
                          label='Show post filtered by username'),
            ew.SubmitButton(label='Filter Posts')
        ])
    ]
 def fields(self):
     fields = [
         ew.TextField(name='summary', label='Title',
             attrs={'style':'width: 425px','placeholder':'Title'},
             validator=fev.UnicodeString(not_empty=True, messages={'empty':"You must provide a Title"})),
         ffw.MarkdownEdit(label='Description',name='description',
                 attrs={'style':'width: 95%'}),
         ew.SingleSelectField(name='status', label='Status',
             options=lambda: c.app.globals.all_status_names.split()),
         ffw.ProjectUserCombo(name='assigned_to', label='Owner'),
         ffw.LabelEdit(label='Labels',name='labels', className='ticket_form_tags'),
         ew.Checkbox(name='private', label='Mark as Private', attrs={'class':'unlabeled'}),
         ew.InputField(name='attachment', label='Attachment', field_type='file', attrs={'multiple': 'True'}, validator=fev.FieldStorageUploadConverter(if_missing=None)),
         ffw.MarkdownEdit(name='comment', label='Comment',
                     attrs={'style':'min-height:7em; width:97%'}),
         ew.SubmitButton(label=self.submit_text,name='submit',
             attrs={'class':"ui-button ui-widget ui-state-default ui-button-text-only"}),
         ew.HiddenField(name='ticket_num', validator=fev.Int(if_missing=None)),
     ]
     # milestone is kind of special because of the layout
     # add it to the main form rather than handle with the other customs
     if c.app.globals.custom_fields:
         for cf in c.app.globals.custom_fields:
             if cf.name == '_milestone':
                 fields.append(TicketCustomField.make(cf))
                 break
     return ew_core.NameList(fields)
Exemple #6
0
 def fields(self):
     fields = [
         ew.InputField(name='screenshot',
                       field_type='file',
                       label='New Screenshot'),
         ew.InputField(
             name='caption',
             field_type="text",
             label='Caption',
             attrs={
                 'title':
                 "Reuse your project name in screenshot file names and create a caption to briefly describe each screenshot.",
                 'class': 'tooltip',
             })
     ]
     return fields
Exemple #7
0
 def fields(self):
     return ew_core.NameList([
         ew.TextField(name='title',
                      validator=fev.UnicodeString(
                          not_empty=True,
                          messages={'empty': "You must provide a Title"}),
                      attrs=dict(placeholder='Enter your title here',
                                 title='Enter your title here',
                                 style='width: 425px')),
         ffw.MarkdownEdit(name='text',
                          show_label=False,
                          attrs=dict(placeholder='Enter your content here',
                                     title='Enter your content here')),
         ew.SingleSelectField(name='state',
                              options=[
                                  ew.Option(py_value='draft',
                                            label='Draft'),
                                  ew.Option(py_value='published',
                                            label='Published')
                              ]),
         ffw.LabelEdit(name='labels',
                       placeholder='Add labels here',
                       title='Add labels here'),
         ew.InputField(
             name='attachment',
             label='Attachment',
             field_type='file',
             attrs={'multiple': 'True'},
             validator=fev.FieldStorageUploadConverter(if_missing=None)),
     ])
Exemple #8
0
 def fields(self):
     fields = [
         ew.InputField(name='file_info',
                       field_type='file',
                       label='New Attachment')
     ]
     return fields
Exemple #9
0
class SortableRepeatedMixin(JQueryMixin):
    js_widget_name = 'SortableRepeatedField'
    js_plugin_file = ew.JSLink('js/sortable_repeated_field.js')
    js_params = JQueryMixin.js_params + [
        'field_cls',
        'flist_cls',
        'stub_cls',
        'msg_cls',
        'append_to',
        'extra_field_on_focus_name',
    ]
    defaults = dict(container_cls='sortable-repeated-field',
                    field_cls='sortable-field',
                    flist_cls='sortable-field-list',
                    stub_cls='sortable-field-stub',
                    msg_cls='sortable-field-message',
                    append_to='top',
                    empty_msg='No fields have been defined',
                    nonempty_msg='Drag and drop the fields to reorder',
                    show_msg=True,
                    show_button=True,
                    extra_field_on_focus_name=None,
                    repetitions=0)

    button = ew.InputField(css_class='add',
                           field_type='button',
                           value='New Field')
Exemple #10
0
 class fields(ew_core.NameList):
     project_description = ew.HiddenField(label='Public Description')
     neighborhood = ew.HiddenField(label='Neighborhood')
     private_project = ew.Checkbox(label="", attrs={'class': 'unlabeled'})
     project_name = ew.InputField(label='Project Name',
                                  field_type='text',
                                  validator=formencode.All(
                                      fev.UnicodeString(not_empty=True,
                                                        max=40),
                                      V.MaxBytesValidator(max=40)))
     project_unixname = ew.InputField(
         label='Short Name', field_type='text',
         validator=None)  # will be set in __init__
     tools = ew.CheckboxSet(
         name='tools',
         options=[
             ## Required for Neighborhood functional tests to pass
             ew.Option(label='Wiki', html_value='wiki', selected=True)
         ])
class MilestonesAdmin(ffw.SortableTable):
    defaults = dict(
        ffw.SortableTable.defaults,
        button=ffw.AdminField(field=ew.InputField(
            css_class='add', field_type='button', value='New Milestone')),
        empty_msg='No milestones have been created.',
        nonempty_msg='Drag and drop the milestones to reorder.',
        repetitions=0)
    fields = [
        ew.HiddenField(name='old_name'),
        ffw.Radio(name='default',
                  label='Default',
                  css_class='default-milestone'),
        ew.Checkbox(name='complete', show_label=True, suppress_label=True),
        ew.TextField(name='name', attrs={'style': 'width: 80px'}),
        ffw.DateField(name='due_date', attrs={'style': 'width: 80px'}),
        ffw.AutoResizeTextarea(name='description',
                               attrs={'style': 'height:1em; width: 150px'}),
        ew.InputField(label='Delete',
                      field_type='button',
                      attrs={
                          'class': 'delete',
                          'value': 'Delete'
                      }),
    ]
    button = ew.InputField(css_class='add',
                           field_type='button',
                           value='New Milestone')

    def prepare_context(self, context):
        response = super(MilestonesAdmin, self).prepare_context(context)
        if 'value' in response:
            for milestone_data in response['value']:
                if 'name' in milestone_data:
                    milestone_data['old_name'] = milestone_data['name']
        return response

    def resources(self):
        for r in super(MilestonesAdmin, self).resources():
            yield r
        yield ew.CSSScript('''div.state-field table{ width: 700px; }''')
class GroupCard(CardField):
    new_item=ew.InputField(field_type='text', attrs=dict(placeholder='type a username'))
    sort_key = 'user.username'

    def item_display(self, item):
        return item.user.username

    def item_id(self, item):
        return item.user._id

    def role_name(self, role_id):
        return M.ProjectRole.query.get(_id=ObjectId(role_id)).name
Exemple #13
0
 def fields(self):
     search_fields = [ew.Option(py_value=v, label=l) for v, l in self._fields]
     search_fields.append(ew.Option(py_value='__custom__', label='custom query'))
     return [
         ew.RowField(fields=[
             ew.SingleSelectField(
                 name='f',
                 show_label=False,
                 options=search_fields),
             ew.InputField(name='q', show_label=False, attrs={'style': 'width: 600px'}),
             ew.SubmitButton(
                 show_label=False,
                 attrs={
                     'value': 'Search',
                     'style': 'float:none; margin-top:3px;',
                 },
                 show_errors=False),
         ])]
Exemple #14
0
 class fields(ew_core.NameList):
     subject = ew.InputField(label='Change subject:', attrs={'style':'width: 50%'})
     discussion = _ForumSelector(label='Move to different forum:')
     flags = ew.CheckboxSet(label='Options', options=['Sticky', 'Announcement'])
 class fields(ew_core.NameList):
     name = ew.InputField(field_type='text',
                          label='Name',
                          validator=formencode.All(
                             fev.UnicodeString(not_empty=True, max=40),
                             V.MaxBytesValidator(max=40)),
                          attrs=dict(maxlength=40,
                                     title="This is the publicly viewable name of the project, and will appear on project listings. It should be what you want to see as the project title in search listing."))
     summary = ew.InputField(field_type="text", label='Short Summary',
                             validator=formencode.All(
                                fev.UnicodeString(max=70),
                                V.MaxBytesValidator(max=70)),
                             attrs=dict(maxlength=70))
     short_description = ew.TextArea(label='Full Description',
                                     validator=formencode.All(
                                         fev.UnicodeString(max=1000),
                                         V.MaxBytesValidator(max=1000)),
                                     attrs=dict(title="Add a few paragraphs describing your project to new users."))
     icon = ew.FileField(label='Icon')
     external_homepage = ew.InputField(field_type="text", label='Homepage')
     support_page = ew.InputField(field_type="text", label='Support Page')
     support_page_url = ew.InputField(field_type="text", label='Support Page URL')
     removal = ew.InputField(field_type="text", label='Removal')
     moved_to_url = ew.InputField(field_type="text", label='Moved Project to URL')
     export_controlled = ew.InputField(field_type="text", label='Export Control')
     delete = ew.InputField(field_type="hidden", label='Delete')
     delete_icon = ew.InputField(field_type="hidden", label='Delete Icon')
     undelete = ew.InputField(field_type="hidden", label='Undelete')
     tracking_id = ew.InputField(field_type="text", label="Analytics Tracking ID")
 class fields(ew_core.NameList):
     name = ew.InputField(label='Name')
Exemple #17
0
 def fields(self):
     fields = super(NewTopicPost, self).fields
     fields.append(ew.InputField(name='attachment', label='Attachment', field_type='file',
                                 attrs={'multiple': 'True'},
                                 validator=fev.FieldStorageUploadConverter(if_missing=None)))
     return fields
Exemple #18
0
 class fields(ew_core.NameList):
     name = ew.InputField(
         field_type='text',
         label='Name',
         validator=formencode.All(fev.UnicodeString(not_empty=True, max=40),
                                  V.MaxBytesValidator(max=40)),
         attrs={
             'maxlength': 40,
             'title':
             "This is the publicly viewable name of the project, and will appear on project listings. It should be what you want to see as the project title in search listing.",
             'class': 'tooltip',
         })
     summary = ew.InputField(
         field_type="text",
         label='Short Summary',
         validator=formencode.All(fev.UnicodeString(max=70),
                                  V.MaxBytesValidator(max=70)),
         attrs={
             'maxlength': 70,
             'title':
             'Briefly state what your project is and what it does without repeating the project name. This summary appears in Google search results beneath the project name.',
             'class': 'tooltip',
         })
     short_description = ew.TextArea(
         label='Full Description',
         validator=formencode.All(fev.UnicodeString(max=1000),
                                  V.MaxBytesValidator(max=1000)),
         attrs={
             'title':
             'Describe the full functionality of your project using related keywords. The first sentence has the most impact on search. Provide unique content that calls out keywords and describes the merits of your project.',
             'class': 'tooltip'
         })
     # Apparently, child field must be CompoundField with custom template
     # for SortableRepeatedField to work properly, that's why FeaturesField
     # is not just ew.TextField
     features = ffw.SortableRepeatedField(
         label='Features',
         show_msg=False,
         show_button=False,
         append_to='bottom',
         extra_field_on_focus_name='feature',
         field=FeaturesField())
     icon = ew.FileField(label='Icon',
                         attrs={'accept': 'image/*'},
                         validator=V.IconValidator())
     external_homepage = ew.InputField(field_type="text",
                                       label='Homepage',
                                       validator=fev.URL(add_http=True))
     video_url = ew.InputField(field_type="text",
                               label="Video (YouTube)",
                               validator=V.YouTubeConverter())
     support_page = ew.InputField(field_type="text", label='Support Page')
     support_page_url = ew.InputField(field_type="text",
                                      label='Support Page URL',
                                      validator=fev.URL(add_http=True,
                                                        if_empty=''))
     removal = ew.InputField(field_type="text", label='Removal')
     moved_to_url = ew.InputField(field_type="text",
                                  label='Moved Project to URL',
                                  validator=fev.URL(add_http=True,
                                                    if_empty=''))
     export_controlled = ew.InputField(field_type="text",
                                       label='Export Control')
     export_control_type = ew.InputField(field_type="text",
                                         label='Export Control Type')
     delete = ew.InputField(field_type="hidden", label='Delete')
     delete_icon = ew.InputField(field_type="hidden", label='Delete Icon')
     undelete = ew.InputField(field_type="hidden", label='Undelete')
     tracking_id = ew.InputField(field_type="text",
                                 label="Google Analytics ID",
                                 attrs=(dict(placeholder='UA-123456-0',
                                             pattern='UA-[0-9]+-[0-9]+')))
     twitter_handle = ew.InputField(field_type="text",
                                    label='Twitter Handle')
     facebook_page = ew.InputField(field_type="text",
                                   label='Facebook page',
                                   validator=fev.URL(add_http=True))