Esempio n. 1
0
class AddTaskForm(Form):
    task_name = StringField('', [data_required(), length(min=1, max=50)])
    task_type = IntegerField('', [data_required(), number_range(min=1, max=5)])

    hours = StringField('', [data_required(), length(1, 36)])
    minutes = StringField('', [data_required(), length(1, 36)])
    seconds = StringField('', [optional(), length(1, 36)])
    day_of_week = StringField('', [optional(), length(1, 36)])
    day_of_month = StringField('', [optional(), length(1, 36)])

    alarm_mode = IntegerField(
        '', [data_required(), number_range(min=0, max=5)], default=1)
    task_priority = IntegerField(
        '', [data_required(), number_range(min=0, max=5)])
    task_start_date = DateField('', [optional()])
    task_end_date = DateField('', [optional()])
    task_desc = StringField('', [optional(), length(0, 200)])

    groups = FieldList(StringField('', [optional(), Length(min=32, max=32)]))
    organizations = FieldList(
        StringField('', [optional(), Length(min=32, max=32)]))

    # items = StringField('',[required])
    items = FormField(Item)
    channels = FieldList(FormField(Channel))

    # user_id = StringField('', [optional()])
    # user_name = StringField('', [optional()])
    system_id = StringField('', [optional(), Length(min=36, max=36)])
Esempio n. 2
0
class EffortGradingForm(BaseForm):
    full_credit = DecimalField(
        'Full Credit (in points)',
        validators=[
            validators.required(),
            validators.number_range(min=0,
                                    message="Points cannot be negative.")
        ],
        description=
        "Points received for showing sufficient effort on an assignment.")
    required_questions = IntegerField(
        'Required Questions',
        validators=[
            validators.number_range(min=0,
                                    message="Questions cannot be negative.")
        ],
        description="Number of required questions on the assignment.")
    late_multiplier = DecimalField(
        'Late Multiplier (as a decimal)',
        validators=[
            validators.number_range(
                min=0, max=1, message="Multiplier must be between 0 and 1")
        ],
        default=0.0,
        description=
        "Decimal ratio that is multiplied to the final score of a late submission."
    )
Esempio n. 3
0
class KeyStoreForm(Form):
    alias = TextField(
        "KeyStore Alias", [validators.length(max=10)],
        id='alias', default='vault'
    )
    storetype = SelectField(
        "StoreType",
        choices=[('jceks', 'jceks'), ('pkcs12', 'pkcs12')]
    )
    keyalg = TextField('KeyStore Algorithm', id="keyalg", default="AES")
    keysize = IntegerField(
        'KeyStore Size', [validators.number_range(min=128)],
        id="keysize", default='128'
    )
    storepass = PasswordField('Store Password', [validators.length(min=8)])
    keypass = PasswordField('Key Password', [validators.length(min=8)])
    validity = IntegerField(
        'validity Time', [validators.number_range(min=360)],
        id='validity', default='730'
    )
    keystore = TextField(
        'KeyStore File name', id='keystore',
        default='vault.keystore'
    )
    createks = SubmitField('Create KeyStore')
Esempio n. 4
0
class VehicleForm(FlaskForm):
    """
    Register a new vehicle.
    """
    vehicle_type = SelectField(label='Type', choices=[('scooter', 'Scooter')])
    longitude = DecimalField(
        label='Longitude',
        validators=[
            input_required(),
            number_range(min=-180,
                         max=180,
                         message="Longitude must be between -180 and 180.")
        ])
    latitude = DecimalField(
        label='Latitude',
        validators=[
            input_required(),
            number_range(min=-90,
                         max=90,
                         message="Latitude must be between -90 and 90.")
        ])
    battery = IntegerField(
        label='Battery (percent)',
        validators=[
            input_required(),
            number_range(
                min=0,
                max=100,
                message="Battery (percent) must be between 0 and 100.")
        ])
    submit = SubmitField('Add vehicle')
Esempio n. 5
0
class SimpleTestForm(Form):
    _schema = OrderedDict([('type', 'object'),
                           ('properties',
                            OrderedDict([
                                ('first_name', {
                                    'type': 'string',
                                    'title': 'First Name',
                                    'maxLength': 255
                                }),
                                ('nick_name', {
                                    'type': 'string',
                                    'title': 'Nickname',
                                    'maxLength': 255
                                }),
                                ('age', {
                                    'type': 'integer',
                                    'title': 'Age',
                                    'minimum': 0,
                                    'maximum': 10
                                }),
                                ('description', {
                                    'type': 'string',
                                    'title': 'Description'
                                }),
                                ('average', {
                                    'type': 'number',
                                    'title': 'Average',
                                    'minimum': 10,
                                    'maximum': 1000
                                }),
                                ('gender', {
                                    'type': 'string',
                                    'title': 'Gender',
                                    'enum':
                                    ['Male', 'Female', 'Alien', 'Other']
                                }),
                                ('some_field', {
                                    'type': 'integer',
                                    'title': 'Bla',
                                    'enum': [1, 2, 3]
                                }),
                                ('some_field2', {
                                    'type': 'number',
                                    'title': 'Bla',
                                    'enum': [1.5, 2.2, 3]
                                }),
                            ])), ('required', ['first_name', 'age'])])
    first_name = StringField('First Name', validators=[validators.required()])
    nick_name = StringField('Nickname')
    age = IntegerField(
        'Age',
        validators=[validators.number_range(0, 10),
                    validators.required()])
    description = TextAreaField('Description')
    average = DecimalField('Average',
                           validators=[validators.number_range(10, 1000)])
    gender = SelectField("Gender",
                         choices=['Male', 'Female', 'Alien', 'Other'])
    some_field = SelectField("Bla", choices=[1, 2, 3])
    some_field2 = SelectField("Bla", choices=[1.5, 2.2, 3])
Esempio n. 6
0
class AddMessageForm(Form):
    message_type = SelectField('Message Type',
                               validators=[validators.data_required()],
                               choices=[('best_practices',
                                         'Reminder: Best Practices'),
                                        ('deadline', 'Reminder: Deadline'),
                                        ('instruction', 'Instruction: How-to'),
                                        ('informational',
                                         'Informational: Awareness')])
    topic = StringField('Topic', [validators.data_required()])
    linkitems = StringField('Title Link')
    send_day = IntegerField(
        'Send Day',
        [validators.number_range(min=1, max=31, message='Must be valid day.')],
        default=1)
    send_time = IntegerField('Send Hour', [
        validators.number_range(
            min=0, max=23, message='Must be valid hour (0 - 23).')
    ],
                             default=9)
    send_date = StringField('Send Date')
    send_once = BooleanField('Specific Date', default=False)
    text = TextAreaField('Message Body')
    country = SelectMultipleField('Country',
                                  validators=[validators.data_required()],
                                  choices=country_choices)
    tagitems = StringField('Tags')
    location = SelectMultipleField('Office Location',
                                   validators=[validators.data_required()],
                                   choices=location_choices)
    emp_type = SelectMultipleField('Employee Type',
                                   validators=[validators.data_required()],
                                   choices=employee_type_choices)
Esempio n. 7
0
class EndRideForm(FlaskForm):
    """
    End ride form for the user to fill out.
    """
    longitude = DecimalField(
        label='Longitude',
        validators=[
            input_required(),
            number_range(min=-180,
                         max=180,
                         message="Longitude must be between -180 and 180.")
        ])
    latitude = DecimalField(
        label='Latitude',
        validators=[
            input_required(),
            number_range(min=-90,
                         max=90,
                         message="Latitude must be between -90 and 90.")
        ])
    battery = IntegerField(
        label='Battery (percent)',
        validators=[
            input_required(),
            number_range(
                min=0,
                max=100,
                message="Battery (percent) must be between 0 and 100.")
        ])
    submit = SubmitField('End ride')
Esempio n. 8
0
class CitiesValidationForm(Form):
    country_name = StringField(validators=[validators.optional()])
    per_page = IntegerField(
        validators=[validators.optional(),
                    validators.number_range(min=1)])
    page = IntegerField(
        validators=[validators.optional(),
                    validators.number_range(min=1)])
 class TracksValidationForm(Form):
     artist = StringField(validators=[validators.optional()])
     per_page = IntegerField(
         validators=[validators.optional(),
                     validators.number_range(min=1)])
     page = IntegerField(
         validators=[validators.optional(),
                     validators.number_range(min=1)])
Esempio n. 10
0
class FeedbackGenTextValidation(Form):

    seed = StringField('data[seed]', [validators.length(min=1, max=11)])
    length = IntegerField('data[length]', [validators.number_range(min=1, max=MAX_TEXT_GEN_OUTPUT)])
    method = StringField('data[method]', [validators.AnyOf(GENERATION_METHOD.keys())])
    output = StringField('data[output]', [validators.Length(min=1,max=MAX_TEXT_GEN_OUTPUT)])
    ranking = IntegerField('data[ranking]', [ validators.number_range(min=0,max=5)])
    def validate(self):
        return True;
Esempio n. 11
0
class InterpolSearchForm(FlaskForm):
    forename = StringField('Имя:')
    name = StringField('Фамилия:', validators=[DataRequired(message='Поле не может быть пустым')])
    nationality = SelectField('Гражданство:', choices=[('RU', 'Russia'), ('US', 'United States')])
    sexId = SelectField('Пол:', choices=[('M', 'Male'), ('F', 'Female')])
    ageMin = IntegerField('Возраст от (мин. 20):', validators=[DataRequired(message='Поле не может быть пустым'),
                                                               number_range(min=20, max=120)])
    ageMax = IntegerField('Возраст до (макс. 120):', validators=[DataRequired(message='Поле не может быть пустым'),
                                                                 number_range(min=20, max=120)])
    submit = SubmitField('Искать!')
Esempio n. 12
0
class HouseForm(FlaskForm):
    build_num = IntegerField(
        "Building number:",
        [validators.number_range(1, 16, "Value should be from 1 to 16")])
    adress = StringField("Adress:")
    floors = IntegerField("Floor_num:")
    years = IntegerField(
        "Year of build:",
        [validators.number_range(1980, None, "Value should be from 1980")])

    submit = SubmitField("Save")
Esempio n. 13
0
class RegistrationForm(Form):
    name = StringField('Name:', [validators.Length(min=4, max=25)])
    age = IntegerField('Age:', [validators.number_range(min=6, max=100)])
    gender = SelectField('Gender:', choices=[('f', 'Female'), ('m', 'Male')])
    height = IntegerField('Height (in cm):',
                          [validators.number_range(min=100, max=250)])
    weight = IntegerField('Weight (in kg):',
                          [validators.number_range(min=20, max=300)])
    diet = SelectField('Diet:',
                       choices=[('balanced', 'Balanced'),
                                ('slight', 'Slightly Unhealthy'),
                                ('unhealthy', 'Unhealthy')])
Esempio n. 14
0
class AddGameForm(FlaskForm):
    game_title = StringField('Title of game:', validators=[DataRequired()])
    game_alias = StringField('Alias of game:')
    player_rate = FloatField('Player rate:', [validators.number_range(0, 10), validators.DataRequired()])
    bgg_rate = FloatField('BGG rate:', [validators.number_range(0, 10), validators.DataRequired()])
    player_min = IntegerField('Value of player minimum:', [validators.number_range(1, 20), validators.DataRequired()])
    player_max = IntegerField('Value of player maximum:', [validators.number_range(1, 20), validators.DataRequired()])
    language = StringField('Language of game:', validators=[DataRequired()])
    game_type = StringField('Type of game:')
    img_name = FileField()

    submit = SubmitField('Add game')
Esempio n. 15
0
class CalcForm(FlaskForm):
    balance = IntegerField('Current balance',
                           validators=[DataRequired(),
                                       validators.number_range(max=10000000)], default=100000)
    interest = DecimalField('Interest',
                            validators=[DataRequired(message='Field must be decimal! '
                                                             'Make sure that dot is used instead of comma'),
                                        validators.number_range(max=10)], default=0.10)
    years = IntegerField('Amount of years',
                         validators=[DataRequired(),
                                     validators.number_range(max=10)], default=10)
    submit = SubmitField('Calculate')
Esempio n. 16
0
class RequestForm(FlaskForm):
    # object data
    obj_name = fields.StringField('Object Name', [validators.input_required()])
    obj_ra = fields.StringField('RA', [validators.Optional()])
    obj_dec = fields.StringField('DEC', [validators.Optional()])
    typedesig = fields.SelectField('object type',
                                   [validators.input_required()],
                                   coerce=str,
                                   choices=[('f', 'fixed'),
                                            ('v', 'periodic fixed'),
                                            ('e', 'heliocentric elliptical'),
                                            ('h', 'heliocentric hyperbolic'),
                                            ('p', 'heliocentric parabolic'),
                                            ('E', 'geocentric elliptical')])
    # required and optional fields for requests
    allocation = fields.SelectField('allocation', [validators.data_required()],
                                    coerce=int,
                                    choices=[])
    priority = fields.FloatField('priority', [validators.input_required()])
    filters_op = fields.SelectField('filters', [validators.input_required()],
                                    coerce=str,
                                    choices=[(' 1, 1, 1, 1}', 'u-g-r-i'),
                                             (' 0, 1, 1, 1}', "g-r-i")])
    seq_repeats = fields.IntegerField('# of repeats', default=1)
    ifu = fields.BooleanField('IFU image', [validators.Optional()])
    ab = fields.BooleanField('A B pair', [validators.Optional()])
    cadence = fields.FloatField('cadence',
                                default=None,
                                validators=(validators.Optional(), ))
    min_moon_dist = fields.FloatField(
        'minimum moon distance (degrees)',
        validators=(validators.Optional(), validators.number_range(0., 180.)))
    max_moon_illum = fields.FloatField(
        'maximum moon illumination (fractional)',
        validators=(validators.Optional(), validators.number_range(0., 1.)))
    max_cloud_cover = fields.FloatField(
        'maximum cloud cover (fractional)',
        validators=(validators.Optional(), validators.number_range(0., 1.)))
    phasesamples = fields.FloatField('samples per period',
                                     default=None,
                                     validators=(validators.Optional(), ))
    inidate = fields.DateField('start date (Y-m-d)',
                               validators=[validators.input_required()],
                               format='%Y-%m-%d')
    enddate = fields.DateField('end date (Y-m-d)',
                               validators=[validators.input_required()],
                               format='%Y-%m-%d')
    #elliptical = fields.FormField(HeliocentricEllipticalForm, validators=(validators.Optional(),))
    #hyperbolic = fields.FormField(HeliocentricHyperbolicForm, validators=(validators.Optional(),))
    #parabolic = fields.FormField(HeliocentricParabolicForm, validators=(validators.Optional(),))
    #satellite = fields.FormField(EarthSatelliteForm, validators=(validators.Optional(),))
    submit_req = fields.SubmitField('submit request')
Esempio n. 17
0
class RegistrationForm(FlaskForm):
    username = StringField('Username',
                           validators=[DataRequired(),
                                       length(min=2, max=10)])

    email = StringField('Email', validators=[DataRequired(), Email()])

    password = PasswordField(
        'Password', validators=[DataRequired(),
                                length(min=3, max=10)])

    confirm_password = PasswordField(
        'Confirm Password', validators=[DataRequired(),
                                        EqualTo('password')])

    state = SelectField('state',
                        choices=[('Victoria', 'Victoria'),
                                 ('New South Wales', 'New South Wales'),
                                 ('Western Astralia', 'Western Australia'),
                                 ('Queensland', 'Queensland'),
                                 ('South Australia', 'South Australia'),
                                 ('Tasmina', 'Tasmina'),
                                 ('Astralia Capital Territory',
                                  'Australia Capital Territory')])

    age = IntegerField(
        'Age', validators=[DataRequired(),
                           number_range(min=18, max=99)])

    height = IntegerField(
        'Height', validators=[DataRequired(),
                              number_range(min=100, max=300)])

    gender = SelectField('gender',
                         choices=[('Male', 'Male'), ('Female', 'Female')])

    education = SelectField('Education',
                            choices=[('Highschool', 'Highschool'),
                                     ('Tertiary degree', 'Tertiary degree'),
                                     ('Master/phd', 'Master/phd')])

    submit = SubmitField('Sign Up')

    def validate_username(self, username):
        user = User.query.filter_by(username=username.data).first()
        if user:
            raise ValidationError('that username is taken. please try again')

    def validate_email(self, email):
        user = User.query.filter_by(email=email.data).first()
        if user:
            raise ValidationError('that email is taken. please try again')
Esempio n. 18
0
class PostForm(FlaskForm):
    title = TextAreaField('Title of project',
                          validators=[DataRequired(),
                                      Length(min=1, max=100)])
    details = TextAreaField(
        'project details',
        validators=[DataRequired(), Length(min=1, max=1000)])
    start_time = DateTimeField('expected date of project', format='%d/%m/%Y')
    max_participant = IntegerField(
        'No of participants',
        validators=[DataRequired(number_range(min=1, max=100))])
    socialHours = IntegerField('Number of Social Hours',
                               validators=[number_range(min=1, max=100)])
    image = FileField('image')
    submit = SubmitField('Post')
Esempio n. 19
0
class ProfilePresentationForm(Form):
    presentation_year = IntegerField('Year', [
        validators.DataRequired(),
        validators.number_range(min=1900, max=date.today().year)
    ])
    title = StringField(
        'Title of Presentation',
        [validators.DataRequired(),
         validators.Length(min=2, max=20)])
    evt_type = StringField(
        'Event Type',
        [validators.DataRequired(),
         validators.Length(min=2, max=20)])
    org_body = StringField(
        'Organising Body',
        [validators.DataRequired(),
         validators.Length(min=2, max=30)])
    location = StringField(
        'Location',
        [validators.DataRequired(),
         validators.Length(min=2, max=50)])
    grant_no = StringField(
        'Primary Attribution',
        [validators.DataRequired(),
         validators.Length(min=1, max=18)])
Esempio n. 20
0
class AddTransactionForm(FlaskForm):

    amount = IntegerField('Amount',
                          validators=[DataRequired(),
                                      number_range(min=0)])
    comments = TextAreaField('Comments')
    add = SubmitField('Add')
class AddRoomForm(FlaskForm):
    r_type = StringField(
        'Room Type',
        [validators.Length(min=1, max=45),
         validators.DataRequired()])
    price = FloatField(
        'Price', [validators.number_range(min=200),
                  validators.DataRequired()])
    num_window = IntegerField(
        'Number of windows',
        [validators.NumberRange(min=0, max=5),
         validators.DataRequired()])
    allow_smoke = StringField(
        'Allow smoke',
        [validators.Length(min=1, max=5),
         validators.DataRequired()])
    num_bed = IntegerField(
        'Number of beds',
        [validators.NumberRange(min=1, max=5),
         validators.DataRequired()])
    bathtub = StringField(
        'bathtub',
        [validators.Length(min=1, max=45),
         validators.DataRequired()])
    num_rooms = IntegerField(
        'Number of Rooms',
        [validators.NumberRange(min=1),
         validators.DataRequired()])

    class Meta:
        csrf = False
Esempio n. 22
0
class ProfileForm(FlaskForm):
	gender=SelectField('Gender', validators=[DataRequired(), Optional()], choices=[('','-------------'),('Male','Male'), ('Female', 'Female')])
	religion=SelectField('Religion', validators=[DataRequired(), Optional()], choices=[('','-------------'),('Hindu','Hindu'), ('Muslim', 'Muslim'), ('Christian', 'Christian'), ('Sikh', 'Sikh'), ('Athiest', 'Athiest')])
	maritial_status=SelectField('Maritial Status', validators=[DataRequired()], choices=[('Single','Single'), ('Widow', 'Widow'), ('Divorced', 'Divorced')])
	date_of_birth=DateTimeField('Date of Birth',  validators=[DataRequired(), number_range(maax, miin, message='you should be older then 18 year or younger then 60 year.')] ,format='%Y-%m-%d %H:%M', render_kw={"placeholder":"YYYY-MM-DD HH:MM"})
	picture=FileField('Image', validators=[FileAllowed(['jpg' , 'png'])])
	submit=SubmitField('Create Profile')
Esempio n. 23
0
class AddDealForm(FlaskForm):

    buyer_id = SelectField('Select Buyer',
                           default=None,
                           validators=[DataRequired()])
    plot_id = SelectField('Select Plot',
                          default=None,
                          validators=[DataRequired()])
    c_rate = FloatField('Commission Rate',
                        default=0,
                        validators=[number_range(min=0, max=1)])
    CA_id = SelectField('Select Commission Agent', default=None)
    plot_price = IntegerField('Plot Price', default=0)
    first_amount_recieved = IntegerField('First Paid Amount (optional)',
                                         default=0)
    amount_per_installment = IntegerField('Expected Amount per Installment',
                                          default=0,
                                          validators=[DataRequired()])
    installment_frequency = IntegerField(
        'Expected Time between Installments(days)',
        validators=[DataRequired()])
    comments = TextAreaField('Comments')
    attachments = MultipleFileField('Attachments',
                                    validators=[
                                        FileAllowed([
                                            'jpeg', 'png', 'jpg', 'pdf', 'txt',
                                            'doc', 'docx', 'csv', 'xls', 'xlsx'
                                        ], 'File Format Not Allowed')
                                    ])
    submit = SubmitField('Create Deal')
Esempio n. 24
0
class AddEquipmentForm(Form):
    tagno = TextField(
        'USAID Tag',
        [validators.required(),
         validators.number_range(10000, 99999)])
    category = SelectField('Category', validators=[validators.required()])
    model = TextField('Model', [validators.optional()])
Esempio n. 25
0
class MessengerForm(Form):
    __tablename__ = 'messenger'

    Site = StringField("Site: ", [
        validators.DataRequired("Site."),
        validators.Length(10, 240, "Site should be from 10 to 240 symbols")
    ])

    Version = StringField("Version: ", [
        validators.DataRequired("Version."),
        validators.Length(3, 20, "Version should be from 3 to 20 symbols")
    ])

    Country = StringField("Country: ", [
        validators.DataRequired("Country."),
        validators.Length(3, 20, "Country should be from 3 to 20 symbols")
    ])

    Price = IntegerField(
        "Price: ",
        [validators.DataRequired("Price."),
         validators.number_range(0, 100)])

    Username = StringField("Username: "******"Username."),
        validators.Length(0, 100, "Username should be from 3 to 20 symbols")
    ])

    old_name = HiddenField()
    submit = SubmitField("Save")
Esempio n. 26
0
class ProfilePublicationsForm(Form):
    pub_yr = IntegerField('Publication Year', [
        validators.DataRequired(),
        validators.number_range(min=1900, max=date.today().year)
    ])
    pub_type = StringField(
        'Publication Type',
        [validators.DataRequired(),
         validators.Length(min=2, max=26)])
    title = StringField(
        'Title', [validators.DataRequired(),
                  validators.Length(min=2, max=20)])
    journal_name = StringField(
        'Journal/Conference Name',
        [validators.DataRequired(),
         validators.Length(min=2, max=30)])
    pub_status = StringField(
        'Publication Status',
        [validators.DataRequired(),
         validators.Length(min=2, max=9)])
    DOI = StringField(
        'DOI', [validators.DataRequired(),
                validators.Length(min=2, max=20)])
    grant_no = StringField(
        'Primary Attribution',
        [validators.DataRequired(),
         validators.Length(min=1, max=18)])
Esempio n. 27
0
class UserForm(FlaskForm):
    il = HiddenField()
    user_name = StringField("Name: ", [
        validators.DataRequired("Please enter your name."),
        validators.Length(2, 20, "Name should be from 2 to 20 symbols")
    ])
    username = StringField("Login: "******"Please enter your login."),
        validators.Length(2, 255, "Login should be from 2 to 255 symbols")
    ])
    password = PasswordField("Password: "******"Please enter your password."),
        validators.Length(8, 255, "Password should be from 8 to 255 symbols")
    ])
    user_email = StringField("Email: ", [
        validators.DataRequired("Please enter your email."),
        validators.Email("Wrong email format")
    ])
    user_birthday = DateField(
        "Birthday: ", [validators.DataRequired("Please enter your birthday.")])
    user_phone = IntegerField("Phone: ", [
        validators.DataRequired("Please enter your phone."),
        validators.number_range(100000000, 999999999999,
                                "Phone should be from 10 to 12 symbols")
    ])

    submit = SubmitField("Save")
Esempio n. 28
0
class InputForm(Form):
    start = DateTimeField( '',default=datetime.datetime.now(), format= '%Y-%m-%d %H:%M')
    end = DateTimeField('',default=datetime.datetime.now(), format = '%Y-%m-%d %H:%M')
    distance = IntegerField('Distance [km]', [validators.DataRequired()])
    passengers = IntegerField('Number of passengers',
                              [validators.DataRequired(),
                               validators.number_range(0, 7, message="Must be between 0 and 7")])
Esempio n. 29
0
class PriceForm(Form):

    # interdiction de mettre des montant negatifs
    minPrice = IntegerField('Prix minimum', [
        validators.optional(),
        validators.number_range(min=0, message='le montant doit etre positif')
    ],
                            widget=widgets.Input(input_type="number"))
    maxPrice = IntegerField('Prix maximum', [
        validators.optional(),
        validators.number_range(min=0, message='le montant doit etre positif')
    ],
                            widget=widgets.Input(input_type="number"))
    priceOrder = SelectField('Ordre de tri des prix',
                             choices=[('ASC', 'Croissant'),
                                      ('DESC', 'Decroissant')])
Esempio n. 30
0
class WorkstudySearchForm(Form):
    student_id = IntegerField('studentID', validators=[validators.optional()])
    faculty_id = StringField(
        'facultyID',
        validators=[validators.optional(),
                    validators.regexp('[A-Za-z]{2}')])
    term_season = StringField(
        'semesterTerm',
        validators=[
            validators.optional(),
            validators.regexp('(?i)^fall|spring|summer|winter$')
        ])
    term_year = IntegerField('termYear',
                             validators=[
                                 validators.optional(),
                                 validators.number_range(1950, 2100)
                             ])
    status = StringField(
        'applicationDecision',
        validators=[
            validators.optional(),
            validators.regexp('(?i)^accepted|pending|refused|revoked$')
        ])

    #This method MUST ONLY be called after verification.
    def get_search_form_data(self):
        # Dictionary, whose keys have non-empty (or filled) values
        filled_dict = {
            k: v
            for k, v in self.data.iteritems()
            if not (v == "" or v == "None" or v is None)
        }
        return filled_dict
Esempio n. 31
0
File: app.py Progetto: andyzt/tceh
from flask import Flask, request, render_template
from flask.ext.wtf import Form
from wtforms import StringField, IntegerField, validators, ValidationError
import wtforms_json

import config

import os


app = Flask(__name__, template_folder='templates')
app.config.from_object(config)

API_validators = [{'client.name': [validators.Length(min=1),],
                  'order.count': [validators.number_range(min=1,max=5),],
                  'order.product_name': [validators.any_of(['potatoes','apples','cherries']),],
                  'client.full_address': [validators.Length(min=1),],
                   },
                  {'client.name': [validators.Length(min=1),],
                  'order.count': [validators.number_range(min=1,max=10),],
                  'order.product_name': [validators.any_of(['potatoes','apples','cherries']),],
                  'client.address.full_address': [validators.Length(min=1),],
                  'client.email': [validators.Length(min=1),validators.Email(),]
                   }
                  ]


def flatten_dict(dd, separator='.', prefix=''):
        return { prefix + separator + k if prefix else k : v
                 for kk, vv in dd.items()
Esempio n. 32
0
 def NumberRange(cls, lmin=None, lmax=None, message=None):
     ''' Validates that a number is of a minimum and/or maximum value '''
     return validators.number_range(lmin, lmax, message)
Esempio n. 33
0
from flask.ext.wtf import PasswordField, TextField, Form
from wtforms.ext.sqlalchemy.orm import model_form
from wtforms import validators
from models import *

item_form_validators = {
    'stock': { 'validators': [validators.number_range(min=0)] },
    'price_buy': { 'validators': [validators.number_range(min=0)] },
    'price_sell': { 'validators': [validators.number_range(min=0)] }
}

purchase_invoice_detail_validators = {
    'quantity': { 'validators': [validators.number_range(min=0)] }
}

sales_invoice_validators = {
    'discount': { 'validators': [validators.number_range(min=0, max=100)] }
}

UserForm = model_form(User,
                db_session=db.session,
                base_class=Form)

SupplierForm = model_form(Supplier, db_session=db.session,
                                    base_class=Form,
                                    exclude=['items'])

CustomerForm = model_form(Customer, db_session=db.session,
                                    base_class=Form,
                                    exclude=['sales_invoices'])