Ejemplo n.º 1
0
class BaseResourceForm(ModelForm):
    title = fields.StringField(_('Title'), [validators.DataRequired()])
    description = fields.MarkdownField(_('Description'))
    filetype = fields.RadioField(
        _('File type'), [validators.DataRequired()],
        choices=list(RESOURCE_FILETYPES.items()),
        default='file',
        description=_('Whether the resource is an uploaded file, '
                      'a remote file or an API'))
    type = fields.RadioField(
        _('Type'), [validators.DataRequired()],
        choices=list(RESOURCE_TYPES.items()),
        default='other',
        description=_('Resource type (documentation, API...)'))
    url = fields.UploadableURLField(
        _('URL'), [validators.DataRequired(), enforce_filetype_file],
        storage=resources)
    format = fields.StringField(
        _('Format'),
        filters=[normalize_format],
    )
    checksum = fields.FormField(ChecksumForm)
    mime = fields.StringField(_('Mime type'),
                              description=_(
                                  'The mime type associated to the extension. '
                                  '(ex: text/plain)'))
    filesize = fields.IntegerField(_('Size'), [validators.optional()],
                                   description=_('The file size in bytes'))
    published = fields.DateTimeField(
        _('Publication date'),
        description=_('The publication date of the resource'))
    extras = fields.ExtrasField()
Ejemplo n.º 2
0
class BaseResourceForm(ModelForm):
    title = fields.StringField(_('Title'), [validators.required()])
    description = fields.MarkdownField(_('Description'))
    filetype = fields.RadioField(
        _('Type'), [validators.required()],
        choices=RESOURCE_TYPES.items(),
        default='file',
        description=_('Whether the resource is an uploaded file, '
                      'a remote file or an API'))
    url = fields.UploadableURLField(_('URL'), [validators.required()],
                                    storage=resources)
    format = fields.StringField(_('Format'),
                                widget=widgets.FormatAutocompleter())
    checksum = fields.FormField(ChecksumForm)
    mime = fields.StringField(_('Mime type'),
                              description=_(
                                  'The mime type associated to the extension. '
                                  '(ex: text/plain)'))
    filesize = fields.IntegerField(_('Size'), [validators.optional()],
                                   description=_('The file size in bytes'))
    published = fields.DateTimeField(
        _('Publication date'),
        description=_('The publication date of the resource'))
Ejemplo n.º 3
0
class NestedFormWithSub(NestedFormWithId):
    sub = fields.FormField(SubNestedForm)
Ejemplo n.º 4
0
class IntervalTaskForm(PeriodicTaskForm):
    interval = fields.FormField(IntervalForm)
Ejemplo n.º 5
0
class CrontabTaskForm(PeriodicTaskForm):
    crontab = fields.FormField(CrontabForm)
Ejemplo n.º 6
0
 class FakeForm(ModelForm):
     model_class = Fake
     name = fields.StringField()
     nested = fields.FormField(nested_form, **kwargs)