Exemplo n.º 1
0
class SimulationForm(BaseForm):
    name = fields.StringField(_('Name'),[validators.Required(), validators.Length(min=3, max=FIELD_MAXLENGTH), validators.regexp(utils.ALPHANUMERIC_REGEXP, message=_('Invalid name.'))])
    description = fields.TextAreaField(_('Description'),[validators.Optional(), validators.Length(min=10,max=512)])
    map = fields.FileField(_('Map Layer'),[validators.Optional()])
    series = fields.FileField(_('Time Series'),[validators.Optional()])
    epg = fields.FileField(_('Epg file'),[validators.Optional()])
    network = fields.FileField(_('Network file'),[validators.Optional()])
    spread = fields.FileField(_('Spread tree file'),[validators.Optional()])
    model = fields.TextAreaField(_('Model Source'),[validators.Length(min=10,max=10000)])
Exemplo n.º 2
0
class TestCaseForm(FlaskForm):
    input_string = fields.TextAreaField("Input Text")
    input_file = fields.FileField("Input File")
    is_inputfile = fields.BooleanField("Is Input File", default=False)

    output_string = fields.TextAreaField("Output Text")
    output_file = fields.FileField("Output File")
    is_outputfile = fields.BooleanField("Is Output File", default=False)

    public = fields.BooleanField("Public", default=False)
Exemplo n.º 3
0
class TeamForm(BaseForm):
  importfile = fields.FileField(('Excel/CSV'))
  name = fields.StringField(('Team Name'), [validators.Required(), validators.Length(max=FIELD_MAXLENGTH, message=(
                                                  "Field cannot be longer than %(max)d characters."))])
  sport = fields.SelectField(u'Sport', choices=[(key, value) for key, value in constants.SPORTS_LIST.items()], default='others')
  logo = fields.FileField('Logo')
  category = fields.SelectField(u'Category', choices=[(key, value) for key, value in constants.CATEGORY_DICT.items()], default='open')  
  new_player = fields.FieldList(fields.FormField(PlayerForm), min_entries=1)  
  #players = fields.FieldList(fields.FormField(MyForm))  
  pass
Exemplo n.º 4
0
class RunForm(Form):
    data_url = fields.StringField(**data_url_args)
    data_file = fields.FileField(**data_file_args)
    format = fields.SelectField(**format_args)
    schema_url = fields.StringField(**schema_url_args)
    schema_file = fields.FileField(**schema_file_args)
    schema_eg = fields.SelectField(**schema_eg_args)
    fail_fast = fields.BooleanField(default=False, **fail_fast_args)
    encoding = fields.SelectField(**encoding_args)
    report_type = fields.HiddenField(**report_type_args)
    ignore_empty_rows = fields.BooleanField(default=False,
                                            **ignore_empty_rows_args)
    ignore_duplicate_rows = fields.BooleanField(default=False,
                                                **ignore_duplicate_rows_args)
Exemplo n.º 5
0
class UploadForm(form.Form):
    choices = MultiCheckboxField('Assigned', choices=switches)
    file = fields.FileField(render_kw={"multiple": True})
    analyzertimeout = fields.SelectField('analyzertimeout',
                                         choices=[
                                             (30, '30sec analyzing timeout'),
                                             (60, '1min analyzing timeout'),
                                             (120, '2min analyzing timeout')
                                         ],
                                         default=(analyzer_timeout),
                                         coerce=int)
    functiontimeout = fields.SelectField('functiontimeout',
                                         choices=[(10, '10sec logic timeout'),
                                                  (20, '20sec logic timeout'),
                                                  (30, '30sec logic timeout'),
                                                  (40, '40sec logic timeout'),
                                                  (50, '50sec logic timeout'),
                                                  (60, '1min logic timeout'),
                                                  (100,
                                                   '1:40min logic timeout')],
                                         default=(function_timeout),
                                         coerce=int)
    submit = fields.SubmitField(render_kw={"class": "btn"})
    submitandwait = fields.SubmitField('Submit And Wait',
                                       render_kw={"class": "btn"})
    __order = ('file', 'choices', 'analyzertimeout', 'functiontimeout',
               'submit', 'submitandwait')

    def __iter__(self):
        fields = list(super(UploadForm, self).__iter__())
        get_field = lambda fid: next((f for f in fields if f.id == fid))
        return (get_field(fid) for fid in self.__order)
Exemplo n.º 6
0
class BusinessForm(BaseForm):
  name = fields.StringField(('Name'), [validators.Required(), validators.Length(max=FIELD_MAXLENGTH, message=(
                                                  "Field cannot be longer than %(max)d characters."))])
  description = fields.TextAreaField('Description')
  logo = fields.FileField('Logo')
  contact_info = fields.FormField(ContactInfo)
  pass
Exemplo n.º 7
0
Arquivo: forms.py Projeto: zjjott/html
class MethodActionForm(TornadoForm):
    dataset = fields.SelectField(coerce=int,
                                 validators=[validators.Optional()])
    action = fields.SelectField(choices=[
        ("train", "train"),
        ("predict", "predict"),
    ])
    sync = fields.BooleanField()
    file = fields.FileField(validators=[validators.Optional()])
    data = fields.StringField(validators=[validators.Optional()])

    def __init__(self, *args, **kwargs):
        super(MethodActionForm, self).__init__(*args, **kwargs)
        self.dataset.choices = [
            (id, id) for (id, ) in DatasetModel.query(DatasetModel.id)
        ]

    @classmethod
    def validate_action(cls, form, field):
        data = form.data
        if data.get("action") == "train" and not data.get("dataset"):
            raise ValidationError("需要提供训练的数据集")

    @property
    def data(self):
        data = super(MethodActionForm, self).data
        for key, value in data.iteritems():
            if isinstance(value, HTTPFile):
                data[key] = StringIO(value.body)
        return data
Exemplo n.º 8
0
 def postprocess_form(self, form_class):
     # add a field for handling the file upload
     form_class.upload = fields.FileField('Upload a file')
     form_class.file.kwargs['validators'] = []
     form_class.file.kwargs['allow_blank'] = True
     form_class.title = fields.TextField('Title')
     return form_class
Exemplo n.º 9
0
 class MyForm(super_form):
     nbfile = wtfields.FileField(
         'Notebook file',
         description=
         'Jupyter notebook to be executed. Must be formatted in the Pinyon '
         'file style (see examples). Leave this blank to keep current notebook',
         render_kw={'class': 'form-control-file'})
Exemplo n.º 10
0
class UploadForm(FlaskForm):
    image = fields.FileField(
        'Ladda upp ny bild',
        validators=[FileAllowed(util.image_uploads, 'Endast bilder!')])
    portrait = fields.BooleanField(
        'Porträttläge',
        description="Bilden hamnar till höger om texten istället för ovanför")
Exemplo n.º 11
0
class ImageUploadForm(BaseForm):
    image = fields.FileField('Image Path')

    def validate_image(form, field):
        print field.data
        if str(field.data) == '':
            raise ValidationError(u'field required')

    pass
Exemplo n.º 12
0
class RegisterForm(Form):
    email = fields.StringField('Email', [validators.InputRequired(), validators.Email()])
    password = fields.PasswordField('Password', [validators.Length(min=6, max=16), validators.EqualTo('confirm', 'Passwords do not match')])
    confirm = fields.PasswordField('Re-type Password')
    image_upload = fields.FileField('Image File')

    def validate_email(form, field):
        if RegisteredUsers.select(fn.Count(RegisteredUsers.email)).where(RegisteredUsers.email==field.data).scalar() > 0:
            raise validators.ValidationError('User Already Exists')
Exemplo n.º 13
0
class UploadForm(form.Form):
    choices = MultiCheckboxField('Assigned', choices=switches)
    file = fields.FileField(render_kw={"multiple": True})
    analyzertimeout = fields.TextField(render_kw={"placeholder": "Individual task timeout Sec e.g. 60, default {}".format(json_settings["analyzer_timeout"])})
    functiontimeout = fields.TextField(render_kw={"placeholder": "Individual logic timeout Sec e.g 30, default {}".format(json_settings["function_timeout"])})
    __order = ('file', 'choices', 'analyzertimeout','functiontimeout')
    def __iter__(self):
        fields = list(super(UploadForm, self).__iter__())
        get_field = lambda fid: next((f for f in fields if f.id == fid))
        return (get_field(fid) for fid in self.__order)
Exemplo n.º 14
0
class ArtifactSubmit(Form):
    """
    """
    cves = fields.StringField('CVE(s)', validators=[
        validators.Regexp(
            '^CVE-\d+-\d+(\s*,\s*CVE-\d+-\d+)*$',
            message='Invalid CVE. Multiple CVEs can seperated with commas.'
        ),
        validators.required(),
    ])
    archive = fields.FileField('Archive')
Exemplo n.º 15
0
 class MyForm(super_form):
     entry_key = wtfields.StringField('Entry Key',
                                      default=self.entry_key,
                                      description='Name of column containing names that uniquely define each entry')
     html_template = wtfields.FileField('HTML Template',
                                        description='Jinja2 template used to render the decision form.',
                                        render_kw={'class': 'form-control-file'}
                                        )
     column_names = wtfields.StringField('Columns',
                                         default=", ".join(self.columns),
                                         description='Names of columns to be added, separated by commas')
Exemplo n.º 16
0
class TestForm(BaseForm):

    msg = fields.StringField(validators=[
        validators.Length(min=2, max=40, message=u'无效商户名'), is_has_space
    ])

    #
    # passwd = fields.StringField(
    #     validators=[validators.Length(min=2, max=40, message=u'无效商户名0011'),is_has_space])

    img = fields.FileField('imgCardFront', validators=[File])
Exemplo n.º 17
0
class NewPlayerForm(BaseForm):
  importfile = fields.FileField(('Excel/CSV'))
  name = fields.StringField(('Player Name'), [validators.Required(), validators.Length(max=FIELD_MAXLENGTH*2, message=(
                                                  "Field cannot be longer than %(max)d characters."))])
  email = fields.StringField(('Player Email'), [validators.Required(), validators.Length(max=FIELD_MAXLENGTH*2, message=(
                                                  "Field cannot be longer than %(max)d characters."))])
  phone = fields.StringField(('Player Phone'), [validators.Required(), validators.Length(max=FIELD_MAXLENGTH, message=(
                                                  "Field cannot be longer than %(max)d characters."))])
  sport = fields.SelectField(u'Sport', choices=[(key, value) for key, value in constants.SPORTS_LIST.items()], default='others')
  teamName = fields.StringField(('Team Name'), [validators.Optional()])
  pass
Exemplo n.º 18
0
class MatchForm(BaseForm):
  importfile = fields.FileField(('Excel/CSV'))
  name = fields.StringField(('Name'), [validators.Required(), validators.Length(max=FIELD_MAXLENGTH, message=(
                                                  "Field cannot be longer than %(max)d characters."))])
  sport = fields.SelectField(u'Sport', choices=[(key, value) for key, value in constants.SPORTS_LIST.items()], default='others')  
  event_id = fields.HiddenField()
  start_datetime = fields.DateTimeField('Start Date Time', [validators.Required()])
  end_datetime = fields.DateTimeField('End Date Time', [validators.Required()])
  result = fields.TextAreaField('Result')
  summary = fields.TextAreaField('Summary')
  participant_type = fields.SelectField('Participant Type', [validators.Required()], choices=[('team','Teams'),('player','Players')])
  #participants = fields.FieldList(fields.FormField(TeamDetails))
  pass
Exemplo n.º 19
0
class InputForm(FlaskForm):

    contents = fields.TextAreaField('Paste a file:', render_kw={'rows': 15})
    uploaded = fields.FileField('Or upload your file here:')
    submit = fields.SubmitField()

    def validate_contents(self, field):
        if not self.contents.data and not self.uploaded.data:
            raise validators.ValidationError("Either paste or upload a file")

    def validate_uploaded(self, field):
        if self.uploaded.data and not utils.secure_filename(
                self.uploaded.data.filename):
            raise validators.ValidationError("Invalid filename")
Exemplo n.º 20
0
class UploadForm(form.Form):
    choices = fields.SelectMultipleField('Assigned', choices=switches)
    file = fields.FileField(render_kw={"multiple": True})
    analyzertimeout = fields.TextField(
        render_kw={
            "placeholder":
            "Individual task timeout Sec e.g. 60, default {}".format(
                json_settings["analyzer_timeout"])
        })
    functiontimeout = fields.TextField(
        render_kw={
            "placeholder":
            "Individual logic timeout Sec e.g 30, default {}".format(
                json_settings["function_timeout"])
        })
Exemplo n.º 21
0
class EditProfileForm(FlaskForm):
    username = StringField(
        label =u'用户名',
        validators = [
        validators.DataRequired(message='用户名不能为空'),
        validators.length(min=4, max=16, message='用户名长度必须大于%(min)d且小于%(max)d')]
        )
    nickname = StringField(
        label =u'昵称',
        validators = [
        validators.DataRequired(message='昵称不能为空'),
        validators.length(min=4, max=32, message='昵称长度必须大于%(min)d且小于%(max)d')]
        )
    avatar_file = fields.FileField(u'Avatar')
    about_me = fields.TextAreaField('关于我', validators=[validators.Length(min=0, max=140,message='自我介绍不能超过%(max)d')])
    submit = SubmitField('提交')
Exemplo n.º 22
0
class UserProfileForm(BaseForm):
  name = fields.StringField(('Name'), [validators.Required(), validators.Length(max=FIELD_MAXLENGTH, message=(
                                                  "Field cannot be longer than %(max)d characters."))])  
  email = fields.StringField(('Email'), [validators.Required(), validators.Length(max=FIELD_MAXLENGTH*2, message=(
                                                  "Field cannot be longer than %(max)d characters."))])
  image = fields.FileField('Image')
  dob = fields.DateField('Date of Birth', [validators.Required()])
  gender = fields.SelectField(u'Gender', choices=[(key, value) for key, value in constants.GENDER_DICT.items()], default='male')  
  profession = fields.SelectField(u'Profession', choices=[(key, value) for key, value in constants.PROFESSION_DICT.items()], default='')
  phone = fields.StringField(('Phone'), [validators.Length(max=FIELD_MAXLENGTH, message=(
                                                  "Field cannot be longer than %(max)d characters."))])  
  locality = fields.StringField(('Area/Locality'), [validators.Length(max=NAME_FILED_MAXLENGTH, message=(
                                                  "Field cannot be longer than %(max)d characters."))])
  locality_id = fields.HiddenField()
  i_want = fields.SelectField(u'I want to', choices=[(key, value) for key, value in constants.WANT_DICT.items()], default='train')
  sport = fields.SelectField(u'Favorite Sport', choices=[(key, value) for key, value in constants.SPORTS_LIST.items()], default='cricket')
  #sport = fields.StringField(('Favorite Sport'), [validators.Optional()])
  pass
Exemplo n.º 23
0
        class UploadForm(self.form_base_class):
            """
                File upload form. Works with FileAdmin instance to check if it
                is allowed to upload file with given extension.
            """
            upload = fields.FileField(lazy_gettext('File to upload'))

            def __init__(self, *args, **kwargs):
                super(UploadForm, self).__init__(*args, **kwargs)
                self.admin = kwargs['admin']

            def validate_upload(self, field):
                if not self.upload.data:
                    raise validators.ValidationError(gettext('File required.'))

                filename = self.upload.data.filename

                if not self.admin.is_file_allowed(filename):
                    raise validators.ValidationError(gettext('Invalid file type.'))
Exemplo n.º 24
0
class UploadForm(form.BaseForm):
    """
        File upload form. Works with FileAdmin instance to check if it is allowed
        to upload file with given extension.
    """
    upload = fields.FileField(lazy_gettext('File to upload'))

    def __init__(self, admin):
        self.admin = admin

        super(UploadForm, self).__init__(helpers.get_form_data())

    def validate_upload(self, field):
        if not self.upload.data:
            raise validators.ValidationError(gettext('File required.'))

        filename = self.upload.data.filename

        if not self.admin.is_file_allowed(filename):
            raise validators.ValidationError(gettext('Invalid file type.'))
Exemplo n.º 25
0
class UploadForm(form.Form):
    '''
    needs more check
    '''
    choices = MultiCheckboxField('Assigned', choices=SWITCHES)
    file = fields.FileField(render_kw={"multiple": True})
    analyzertimeout = fields.SelectField('analyzertimeout',
                                         choices=[
                                             (30, '30sec analyzing timeout'),
                                             (60, '1min analyzing timeout'),
                                             (120, '2min analyzing timeout')
                                         ],
                                         default=(ANALYZER_TIMEOUT),
                                         coerce=int)
    functiontimeout = fields.SelectField('functiontimeout',
                                         choices=[(10, '10sec logic timeout'),
                                                  (20, '20sec logic timeout'),
                                                  (30, '30sec logic timeout'),
                                                  (40, '40sec logic timeout'),
                                                  (50, '50sec logic timeout'),
                                                  (60, '1min logic timeout'),
                                                  (100,
                                                   '1:40min logic timeout')],
                                         default=(FUNCTION_TIMEOUT),
                                         coerce=int)
    submit = fields.SubmitField(render_kw={"class": "btn"})
    submitandwait = fields.SubmitField('Submit And Wait',
                                       render_kw={"class": "btn"})
    __order = ('file', 'choices', 'analyzertimeout', 'functiontimeout',
               'submit', 'submitandwait')

    def __iter__(self):
        temp_fields = list(super(UploadForm, self).__iter__())

        def get_field(fid):
            return next((f for f in temp_fields if f.id == fid))

        return (get_field(fid) for fid in self.__order)
Exemplo n.º 26
0
class datasetForm(FlaskForm):
    title = f.StringField('Name of this dataset', [
        v.InputRequired(r('dataset name')),
        v.length(5, 250,
                 'Dataset title must be between 5 and 250 characters long')
    ])
    description = f.TextAreaField('Dataset description', [
        v.length(
            max=65500,
            message='Description can not be longer than 65,500 characters.')
    ])
    files = f.FieldList(f.FileField('Custom dataset file from your computer'),
                        max_entries=100)
    newFile = f.SubmitField('Add a new dataset file from your computer',
                            render_kw=w3Button)
    removeFile = f.SubmitField('Remove the last dataset file entry',
                               render_kw=w3Button)
    URLs = f.FieldList(f5.URLField('URL of dataset of file',
                                   [v.URL('Please enter a valid URL')]),
                       max_entries=100)
    newURL = f.SubmitField('Add a new dataset URL', render_kw=w3Button)
    removeURL = f.SubmitField('Remove the last URL entry', render_kw=w3Button)
    uploadDataset = f.SubmitField('Upload the dataset', render_kw=w3Button)
Exemplo n.º 27
0
def convert_BlobProperty(model, prop, kwargs):
    """Returns a form field for a ``db.BlobProperty``."""
    return f.FileField(**kwargs)
Exemplo n.º 28
0
 def conv_Image(self, model, field, kwargs):
     return f.FileField(**kwargs)
Exemplo n.º 29
0
class UploadForm(Form):
    file = fields.FileField('file upload')
    name = fields.StringField()
    submit = fields.SubmitField('submit')
Exemplo n.º 30
0
class MediaForm(Form):
  name = fields.StringField('Name')
  media = fields.FileField('Photo/Video')
  status = fields.BooleanField('Active/Inactive')
  primary = fields.BooleanField('Is Primary')