Ejemplo n.º 1
0
class TrainingObjectiveSetterForm(FlaskForm):

    dateNotValid = 'Not a valid date'
    endNotValid = 'Cannot be before Start Date'
    kmNotValid = 'You need to run at least a meter'

    def kmFilter(value):
        if value is not None:
            return float('%.3f' % float(value))
        else:
            return value

    start_date = f.DateField(
        'Start Date',
        validators=[DataRequired(message=dateNotValid),
                    fc.NotLessThenToday()],
        widget=f.widgets.Input(input_type='date'))
    end_date = f.DateField('End Date',
                           validators=[
                               DataRequired(message=dateNotValid),
                               fc.NotLessThan('start_date',
                                              message=endNotValid),
                               fc.NotLessThenToday()
                           ],
                           widget=f.widgets.Input(input_type='date'))
    km_to_run = f.FloatField('Km to run',
                             validators=[
                                 DataRequired(kmNotValid),
                                 NumberRange(min=0.001, message=kmNotValid)
                             ],
                             widget=fc.FloatInput(step='any', min_='0'),
                             filters=[kmFilter])

    display = ['start_date', 'end_date', 'km_to_run']
Ejemplo n.º 2
0
class HoursWorkedReportFormBase(wtf.Form):
    date_range = wtf.SelectField(_(u'Report for'),
                                 validators=[],
                                 choices=[('0', u'date range'),
                                          ('1', u'current quarter'),
                                          ('2', u'previous quarter'),
                                          ('3', u'current year'),
                                          ('4', u'previous year')],
                                 default='0')
    start_date = wtf.DateField(_(u'Start'),
                               validators=[DataValidator(format='%d/%m/%Y')],
                               format='%d/%m/%Y',
                               default=datetime.date(today().year,
                                                     today().month, 1))
    end_date = wtf.DateField(_(u'End'),
                             validators=[DataValidator(format='%d/%m/%Y')],
                             format='%d/%m/%Y',
                             default=end_month)
    user_id = wtf.SelectMultipleField(_(u'Employees'),
                                      validators=[],
                                      choices=EmployeeChoices(inactive=True))
    only_fully_employed = wtf.BooleanField(_(u'Full time employees only'),
                                           default=True)
    only_red = wtf.BooleanField(_(u'Red only'), default=True)
    group_by_month = wtf.BooleanField(_(u'Group by month'), default=True)
Ejemplo n.º 3
0
class ObjectiveForm(FlaskForm):
    name = f.StringField(
        'Name', validators=[DataRequired("Insert the objective name")])
    start_date = f.DateField(
        'Start date',
        format='%Y-%m-%d',
        validators=[DataRequired("Insert when to start the objective")])
    end_date = f.DateField(
        'End Date',
        format='%Y-%m-%d',
        validators=[DataRequired("Insert when to end the objective")])
    target_distance = f.FloatField(
        'Target Distance',
        validators=[DataRequired("Insert the target distance")])

    display = ['name', 'start_date', 'end_date', 'target_distance']

    def validate(self):
        if not FlaskForm.validate(self):
            return False
        result = True

        # Check start_date < end_date
        if self.start_date.data > self.end_date.data:
            result = False

        return result
Ejemplo n.º 4
0
class BulkOperationForm(ReactorForm):
    applications = wtforms.SelectField('Applications')
    start_date = wtforms.DateField('Start Date',
                                   default=lambda: datetime.datetime.utcnow() -
                                   datetime.timedelta(days=90))
    end_date = wtforms.DateField('End Date')
    confirm = wtforms.BooleanField(
        'Confirm operation', validators=[wtforms.validators.DataRequired()])
Ejemplo n.º 5
0
class ProposalSpaceForm(Form):
    name = wtforms.TextField(__("URL name"),
                             validators=[
                                 wtforms.validators.Required(),
                                 ValidName(),
                                 AvailableName()
                             ])
    title = wtforms.TextField(__("Title"),
                              validators=[wtforms.validators.Required()])
    datelocation = wtforms.TextField(
        __("Date and Location"), validators=[wtforms.validators.Required()])
    date = wtforms.DateField(
        __("Start date (for sorting)"),
        validators=[
            wtforms.validators.Required(
                __("Enter a valid date in YYYY-MM-DD format"))
        ],
        description=__("In YYYY-MM-DD format"))
    date_upto = wtforms.DateField(
        __("End date (for sorting)"),
        validators=[
            wtforms.validators.Required(
                __("Enter a valid date in YYYY-MM-DD format"))
        ],
        description=__("In YYYY-MM-DD format"))
    tagline = wtforms.TextField(
        __("Tagline"),
        validators=[wtforms.validators.Required()],
        description=__("This is displayed on the card on the homepage"))
    description = MarkdownField(__("Description"),
                                validators=[wtforms.validators.Required()],
                                description=__("About Event"))
    content = wtforms.fields.FormField(Content)
    timezone = wtforms.SelectField(
        __("Timezone"),
        description=__("The timezone in which this event occurs"),
        validators=[wtforms.validators.Required()],
        choices=sorted_timezones(),
        default=u'UTC')
    status = wtforms.SelectField(
        __("Status"),
        coerce=int,
        choices=[
            (0, __("Draft")),
            (1, __("Open")),
            (2, __("Voting")),
            (3, __("Jury selection")),
            (4, __("Feedback")),
            (5, __("Closed")),
            (6, __("Withdrawn")),
        ],
        description=__(u"Proposals can only be submitted in the “Open” state. "
                       u"“Closed” and “Withdrawn” are hidden from homepage"))

    def validate_date_upto(self, date_upto):
        if self.date_upto.data < self.date.data:
            raise wtforms.ValidationError(
                _("End date cannot be before Start date"))
Ejemplo n.º 6
0
class SprintForm(wtf.Form):
    name = wtf.TextField(_(u"Sprint name"), validators=[validators.Required()])
    bugs_project_ids = SprintProjectsField(_(u"Bugs projects"), choices=ScrumBugsProjectChoices(skip_inactive=True), validators=[validators.Required()])
    project_id = wtf.SelectField(_(u"Project"), choices=ScrumProjectChoices(skip_inactive=True), validators=[validators.Required()])
    team_id = wtf.SelectField(_(u"Team"), choices=TeamChoices())
    start  = wtf.DateField(_(u"Start date"), format='%d/%m/%Y', validators=[])
    end  = wtf.DateField(_(u"End date"), format='%d/%m/%Y', validators=[])
    goal = wtf.TextAreaField(_(u'Goal'), validators=[])
    retrospective_note = wtf.TextAreaField(_(u'Retrospective note'), validators=[])
Ejemplo n.º 7
0
class PlaylistForm(Form):
    title = wtforms.TextField(u"Title",
                              validators=[wtforms.validators.Required()],
                              description=u"The name of your playlist")
    name = wtforms.TextField(
        u"URL Name",
        validators=[wtforms.validators.Optional()],
        description=u"Optional. Will be automatically generated if left blank")
    description = TinyMce4Field(u"Description")
    recorded_date = wtforms.DateField(
        u"Recorded date",
        validators=[wtforms.validators.Optional()],
        description=
        u"Date on which the videos in this playlist were recorded, if applicable"
    )
    published_date = wtforms.DateField(
        u"Published date",
        validators=[wtforms.validators.Required()],
        description=u"Date on which this playlist was created or made public")
    public = wtforms.BooleanField(u"This playlist is public", default=True)
    banner_image = wtforms.FileField(
        u"Playlist banner ad",
        description="Optional - Ad will be displayed in playlist page",
        validators=[wtforms.validators.Optional()])
    banner_ad_url = wtforms.fields.html5.URLField(
        u"Banner Ad URL",
        description="URL to which user should be redirected to",
        validators=[wtforms.validators.Optional()])
    delete_banner_ad = wtforms.BooleanField(u"Delete existing ad?")

    def validate_name(self, field):
        if invalid_name.search(field.data):
            raise wtforms.validators.ValidationError(
                "The name cannot have spaces or non-alphanumeric characters")
        existing = Playlist.query.filter_by(channel=self.channel,
                                            name=field.data).first()
        if existing and existing.id != self.edit_id:
            raise wtforms.validators.ValidationError(
                "That name is already in use")

    def validate_banner_ad(self, field):
        if field.data and 'banner_ad' in request.files:
            requestfile = request.files['banner_ad']
            fileext = requestfile.filename.split('.')[-1].lower()
            if fileext not in [u'png', u'jpg', u'jpeg']:
                raise UploadNotAllowed(
                    u"Unsupported file format. Only PNG and JPG are supported")
            img = Image.open(requestfile)
            img.load()
            if not img.size == BANNER_AD_ALLOWED_SIZE:
                raise UploadNotAllowed(
                    u"Banner size should be %sx%s" %
                    (BANNER_AD_ALLOWED_SIZE[0], BANNER_AD_ALLOWED_SIZE[1]))

    def validate_banner_ad_url(self, field):
        if not field.data:
            raise UploadNotAllowed(u"Banner Ad URL is required")
Ejemplo n.º 8
0
class SprintForm(wtf.Form):
    name = wtf.TextField(_(u"Sprint name"), validators=[validators.Required()])
    project_id = wtf.SelectField(_(u"Projects"),
                                 choices=ProjectChoices(),
                                 validators=[validators.Required()])
    start = wtf.DateField(_(u"Start date"), format='%d/%m/%Y', validators=[])
    end = wtf.DateField(_(u"End date"), format='%d/%m/%Y', validators=[])
    goal = wtf.TextAreaField(_(u'Goal'), validators=[])
    retrospective_note = wtf.TextAreaField(_(u'Retrospective note'),
                                           validators=[])
Ejemplo n.º 9
0
class DateForm(flask_wtf.Form):
    start_date = wtforms.DateField(
        'Start Date',
        format='%m/%d/%Y',
        validators=[wtforms.validators.DataRequired()])
    end_date = wtforms.DateField(
        'End Date',
        format='%m/%d/%Y',
        validators=[wtforms.validators.DataRequired()])
    submit = wtforms.SubmitField('Generate Report')
Ejemplo n.º 10
0
class StoryFilter(FlaskForm):
    init_date = f.DateField('init_date')
    end_date = f.DateField('end_date')
    display = ['init_date', 'end_date']

    def validate_on_submit(self):
        result = super(StoryFilter, self).validate()
        try:
            result = result and (self.init_date.data <= self.end_date.data)
        except TypeError:
            result = False
        return result
Ejemplo n.º 11
0
class TrainingObjectiveVisualizerForm(FlaskForm):
    start_date = f.DateField('Start Date')
    end_date = f.DateField('End Date')
    km_to_run = f.FloatField('Km to Run')
    traveled_kilometers = f.FloatField('Traveled Km')
    status = f.StringField('Status')
    description = f.StringField('Description')

    display = [
        'start_date', 'end_date', 'km_to_run', 'traveled_kilometers', 'status',
        'description'
    ]
Ejemplo n.º 12
0
class FilterForm(wtf.Form):
    DEFAULT_LIMIT = 50
    date_start = wtf.DateField(_(u'Start'),
                               validators=[validators.Required()],
                               format='%d-%m-%Y')
    date_end = wtf.DateField(_(u'End'),
                             validators=[validators.Required()],
                             format='%d-%m-%Y')
    user_id = wtf.SelectField(_(u'Employee'),
                              validators=[],
                              choices=EmployeeChoices(first_empty=True))
    limit = wtf.IntegerField(_(u'Limit'), validators=[], default=DEFAULT_LIMIT)
Ejemplo n.º 13
0
class TimeExportForm(wtf.Form):
    start_date = wtf.DateField(u"Start date",
                               format='%d.%m.%Y',
                               validators=[validators.Required()])
    end_date = wtf.DateField(u"End date",
                             format='%d.%m.%Y',
                             validators=[validators.Required()])
    project = wtf.SelectField(
        u"Project",
        choices=EntityChoices(Project,
                              lambda project: u'%s / %s' %
                              (project.client.name, project.name),
                              empty=True))
Ejemplo n.º 14
0
class AbsentApplicationForm(wtf.Form):
    popup_date_start = wtf.DateField(_(u'Start'),
                                     validators=[validators.Required()],
                                     format='%d/%m/%Y',
                                     default=datetime.date.today())
    popup_date_end = wtf.DateField(_(u'End'),
                                   validators=[validators.Required()],
                                   format='%d/%m/%Y')
    popup_type = wtf.SelectField(_(u'Type'),
                                 validators=[validators.Required()],
                                 choices=ABSENCE_TYPES)
    popup_remarks = wtf.TextAreaField(_(u'Remarks'),
                                      validators=[validators.Required()])

    def __init__(self, *args, **kwargs):
        self.request = kwargs.pop('request')
        super(AbsentApplicationForm, self).__init__(*args, **kwargs)

    def validate_popup_type(self, field):
        if field.data == u'zadanie' or field.data == u'l4':
            return
        if self.popup_date_start.data and self.popup_date_end.data:
            if self.popup_date_start.data <= datetime.date.today(
            ) or self.popup_date_end.data <= datetime.date.today():
                raise ValidationError(_(u'Choose leave at request'))

    def validate_popup_date_start(self, field):
        if self.popup_date_start.data and self.popup_date_end.data:
            if self.popup_date_start.data > self.popup_date_end.data:
                raise ValidationError(_(u'End < Start'))

    def validate_popup_date_end(self, field):
        if self.popup_date_start.data and self.popup_date_end.data:
            if self.popup_date_start.data > self.popup_date_end.data:
                raise ValidationError(_(u'End < Start'))

    def validate_popup_type(self, field):
        if field.data == u'l4' and not self.request.user.employment_contract:
            raise ValidationError(
                _(u"Only user on employment contract can submit L4 absence."))
        if self.popup_date_start.data and self.popup_date_end.data and field.data not in (
                u'inne', u'okolicznosciowe', u'l4'):
            mandated, used, left = user_leave(self.request,
                                              self.popup_date_start.data.year)
            days = h.get_working_days(self.popup_date_start.data,
                                      self.popup_date_end.data)
            left -= days
            if left < 0:
                raise ValidationError(
                    _(u'There is no leave to use, please choose Absence or conntact with Assistant'
                      ))
Ejemplo n.º 15
0
class RentPeriodItemForm(Form):
    PAYMENT_STATUSES = (('wait', u'Ожидает оплаты'), ('payed', u'Оплачен'))
    begin_date = wtforms.DateField(u'Дата начала месяца',
                                   validators=[DataRequired()],
                                   widget=DatePicker())
    end_date = wtforms.DateField(u'Дата окончания месяца',
                                 validators=[DataRequired()],
                                 widget=DatePicker())
    summ = wtforms.DecimalField(u'Сумма оплаты за месяц',
                                validators=[DataRequired()])
    period_payment_status = wtforms.SelectField(u'Статус оплаты',
                                                validators=[DataRequired()],
                                                choices=PAYMENT_STATUSES,
                                                default='wait')
Ejemplo n.º 16
0
class UserEditForm(wtf.Form):
    """ Admin edits freelancer's profile """
    def process(self, formdata=None, obj=None, **kwargs):
        if isinstance(obj, User):
            kwargs['level'] = obj.levels_list
        super(UserEditForm, self).process(formdata, obj, **kwargs)

    is_active = wtf.BooleanField(_(u"Is active"), validators=[])
    is_programmer = wtf.BooleanField(_(u"Is programmer"), validators=[])
    is_frontend_developer = wtf.BooleanField(_(u"Is frontend developer"),
                                             validators=[])
    is_graphic_designer = wtf.BooleanField(_(u"Is graphic designer"),
                                           validators=[])

    avatar = wtf.HiddenField()
    level = wtf.SelectMultipleField(_(u'Role'), validators=[], choices=levels)

    start_work = wtf.DateField(_(u"Start work"),
                               format='%d/%m/%Y',
                               validators=[])
    start_full_time_work = wtf.DateField(_(u"Start full time work"),
                                         format='%d/%m/%Y',
                                         validators=[validators.Optional()])
    description = wtf.TextField(_(u"Description"),
                                validators=[validators.Optional()])
    location = wtf.SelectField(_(u"Office location"),
                               choices=[('', u'--None--')] +
                               [(k, v[0]) for k, v in User.LOCATIONS.items()])

    availability_link = wtf.TextField(
        _(u"Availability calendar link"),
        validators=[validators.Optional(),
                    validators.URL()])
    tasks_link = wtf.TextField(
        _(u"Tasks calendar link"),
        validators=[validators.Optional(),
                    validators.URL()])
    skype = wtf.TextField(_(u"Skype"), validators=[validators.Optional()])
    phone = wtf.TextField(_(u"Phone"), validators=[validators.Optional()])
    phone_on_desk = wtf.TextField(_(u"Deskphone"),
                                  validators=[validators.Optional()])
    irc = wtf.TextField(_(u"IRC"), validators=[validators.Optional()])

    groups = wtf.SelectMultipleField(_(u'Groups'),
                                     validators=[],
                                     choices=(
                                         ('freelancer', 'freelancer'),
                                         ('user', 'user'),
                                         ('admin', 'admin'),
                                     ))
Ejemplo n.º 17
0
class BookingList(FlaskForm):
    """
    Form to find all the reservations in a specific period
    """
    from_date = f.DateField('From Date', format='%d/%m/%Y')
    from_hr = f.SelectField('Hour', choices=range(0, 24))
    from_min = f.SelectField('Minutes', choices=range(0, 60, 15))
    to_date = f.DateField('To Date', format='%d/%m/%Y')
    to_hr = f.SelectField('Hour', choices=range(0, 24))
    to_min = f.SelectField('Minutes', choices=range(0, 60, 15))

    display = [
        'from_date', 'from_hr', 'from_min', 'to_date', 'to_hr', 'to_min'
    ]
Ejemplo n.º 18
0
class UserEditForm(wtf.Form):
    """ Admin edits freelancer's profile """

    employment_contract = wtf.BooleanField(_(u"Employment contract"),
                                           validators=[])
    is_active = wtf.BooleanField(_(u"Is active"), validators=[])

    avatar = wtf.HiddenField()
    roles = wtf.SelectMultipleField(_(u'Role'),
                                    validators=[],
                                    choices=User.ROLES)

    start_work = wtf.DateField(_(u"Start work"),
                               format='%d/%m/%Y',
                               validators=[])
    start_full_time_work = wtf.DateField(_(u"Start full time work"),
                                         format='%d/%m/%Y',
                                         validators=[validators.Optional()])
    stop_work = wtf.DateField(_(u"Stop work"),
                              format='%d/%m/%Y',
                              validators=[validators.Optional()])
    description = wtf.TextField(_(u"Description"),
                                validators=[validators.Optional()])
    date_of_birth = wtf.DateField(_(u"Date of birth"),
                                  format='%d/%m/%Y',
                                  validators=[validators.Optional()])
    location = wtf.SelectField(_(u"Office location"),
                               choices=[('', u'--None--')] +
                               [(k, v[0]) for k, v in User.LOCATIONS.items()])

    availability_link = wtf.TextField(
        _(u"Availability calendar link"),
        validators=[validators.Optional(),
                    validators.URL()])
    tasks_link = wtf.TextField(
        _(u"Tasks calendar link"),
        validators=[validators.Optional(),
                    validators.URL()])
    skype = wtf.TextField(_(u"Skype"), validators=[validators.Optional()])
    phone = wtf.TextField(_(u"Phone"), validators=[validators.Optional()])
    phone_on_desk = wtf.TextField(_(u"Deskphone"),
                                  validators=[validators.Optional()])
    irc = wtf.TextField(_(u"IRC"), validators=[validators.Optional()])

    groups = wtf.SelectMultipleField(_(u'Groups'),
                                     validators=[],
                                     choices=(('freelancer',
                                               'freelancer'), ('user', 'user'),
                                              ('admin', 'admin'), ('scrum',
                                                                   'scrum')))
Ejemplo n.º 19
0
class AnalyticForm(wtf.FlaskForm):
    """
    Analytics request web form.
    """

    ticker = wtforms.StringField(validators=[wtfv.DataRequired()])
    date_from = wtforms.DateField(validators=[wtfv.DataRequired()])
    date_to = wtforms.DateField(validators=[wtfv.DataRequired()])
    submit = wtforms.SubmitField()

    def validate_ticker(self, ticker):
        stock = models.Stock.query.filter_by(ticker=ticker.data).first()
        if stock is None:
            raise wtfv.ValidationError("Акция не найдена")
Ejemplo n.º 20
0
class AdminAddClass(FlaskForm):
    choose_course = wtforms.SelectField("Course to Associate with your Class")
    name = wtforms.StringField("Class Name")
    start = wtforms.DateField("Class Start Date", format='%m/%d/%Y')
    end = wtforms.DateField("Class End Date", format='%m/%d/%Y')
    gender = wtforms.SelectField("Gender the Class is Intended For",
                                 choices=[("0", "Women/Girls"),
                                          ("1", "Men/Boys")])
    type = wtforms.SelectField("Type of Class",
                               choices=[("virtual", "virtual"),
                                        ("on-site", "on-site")])
    days = wtforms.StringField("Days")
    hours = wtforms.StringField("Hours")
    submit = wtforms.SubmitField("Add Class")
Ejemplo n.º 21
0
class TaskForm(FlaskForm):
    name = wtforms.StringField(
        label="name",
        render_kw={
            "class": "form-control",
            "placeholder": "任务名称"
        },
        validators=[
            validators.DataRequired("姓名不可以为空"),
            # validators.length(max=8,min=6), #6-8位
            keywords_valid
            # validators.Email("必须符合邮箱格式"),
        ])
    description = wtforms.TextField(
        label="description",
        render_kw={
            "class": "form-control",
            "placeholder": "任务描述"
        },
        validators=[
            validators.EqualTo("name")  # name和description的内容是否一样
        ])
    time = wtforms.DateField(label="time",
                             render_kw={
                                 "class": "form-control",
                                 "placeholder": "任务时间"
                             })
    public = wtforms.StringField(label="public",
                                 render_kw={
                                     "class": "form-control",
                                     "placeholder": "公布任务人"
                                 })
Ejemplo n.º 22
0
class DeleteMeetingForm(i18nforms.Form):
    """ Form used to delete a meeting. """
    confirm_delete = wtforms.BooleanField(
        _('Yes I want to delete this meeting'))
    confirm_futher_delete = wtforms.BooleanField(
        _('Yes, I want to delete all futher meetings.'))
    from_date = wtforms.DateField(_('Date from which to remove the meeting'))
Ejemplo n.º 23
0
class TaskForm(FlaskForm):
    name=wtforms.StringField(
        render_kw={
            "class":"form-control",
            "placeholder":"任务名称"
        },
        validators=[
          validators.DataRequired("姓名不可以为空"),
          keywords_valid
        ]
    )
    description=wtforms.TextField(
        render_kw={
            "class":"form-control",
            "placeholder":"任务描述"
        },
        validators=[
            validators.EqualTo("name")
        ]
    )
    time=wtforms.DateField(
        render_kw={
            "class":"form-control",
            "placeholder":"任务时间"
        },

    )
    public=wtforms.StringField(
        render_kw={
            "class":"form-control",
            "placeholder":"公布任务人"
        }
    )
Ejemplo n.º 24
0
class TaskForm(FlaskForm):
    name = wtforms.StringField(
        render_kw={
            "class": "form-control",
            "placeholder": "任务名称"
        },
        validators=[validators.DataRequired("姓名不可以为空"), keywords_valid])

    description = wtforms.TextField(render_kw={
        "class": "form-control",
        "placeholder": "任务描述"
    },
                                    validators=[
                                        validators.DataRequired("描述不可以为空"),
                                        validators.Length(min=5,
                                                          message='长度必须大于5')
                                    ])

    time = wtforms.DateField(render_kw={
        "class": "form-control",
        "placeholder": "任务时间"
    })

    public = wtforms.StringField(render_kw={
        "class": "form-control",
        "placeholder": "公布任务人"
    },
                                 validators=[
                                     validators.DataRequired("不可以为空"),
                                 ])
Ejemplo n.º 25
0
class OperatorForm(FlaskForm):
    """
    Form to insert a operator's data (profile)
    """
    email = EmailField('Email', validators=[DataRequired(), Email()])
    firstname = f.StringField('Firstname', validators=[DataRequired()])
    lastname = f.StringField('Lastname', validators=[DataRequired()])
    password = f.PasswordField('Password', validators=[DataRequired()])
    password_repeat = f.PasswordField('Repeat Password',
                                      validators=[DataRequired()])
    telephone = f.StringField('Telephone', validators=[DataRequired()])
    dateofbirth = f.DateField('Date Of Birth', format='%d/%m/%Y')

    restaurant_name = f.StringField('Restaurant Name',
                                    validators=[DataRequired()])
    restaurant_phone = f.StringField('Restaurant Phone',
                                     validators=[DataRequired()])
    restaurant_latitude = f.FloatField('Restaurant latitude',
                                       validators=[InputRequired()])
    restaurant_longitude = f.FloatField('Restaurant Longitude',
                                        validators=[InputRequired()])

    display = [
        'email', 'firstname', 'lastname', 'password', 'password_repeat',
        'telephone', 'dateofbirth', 'restaurant_name', 'restaurant_phone',
        'restaurant_latitude', 'restaurant_longitude'
    ]
Ejemplo n.º 26
0
class FanForm(wtf.Form):

    Radar = wtf.SelectField(label='Radar',
                            validators=[wtf.validators.InputRequired()],
                            choices=[('Rankin Inlet','rkn'),
                                     ('Clyde River', 'cly'),
                                     ('Saskatoon','sas'),
                                     ('Prince George','pgr'),
                                     ('Inuvet','inv')])

    duration_time = wtf.FloatField(label='duration time (hr)',
                                   default=24,
                                   description="seconds",
                                   validators=[wtf.validators.InputRequired()])

    date = wtf.DateField(label='Date',
                         format="%Y%m%d",
                         description="YYYYMMDD",
                         validators=[wtf.validators.InputRequired()])

    start_time = wtf.StringField(label='Start time',
                                 description="HH:MM",
                                 validators=[wtf.validators.InputRequired()])

    ground_scatter = wtf.BooleanField(default=True,
                                      label="Ground Scatter")
    plot = wtf.SubmitField(label='Plot',validators=[wtf.validators.InputRequired()])
Ejemplo n.º 27
0
class ProjectForm(wtforms.Form):
    name = wtforms.StringField(validators=[wtforms.validators.InputRequired()])
    committee = custom_fields.SelectField(label='Primary Committee',
                                          choices=data_models.committee_labels)
    multi_committee = wtforms.BooleanField()
    fund = custom_fields.SelectField(coerce=data_models.create_key)
    partner = custom_fields.SelectField(coerce=data_models.create_key)
    size = custom_fields.SelectField(label='Project Size',
                                     coerce=int,
                                     choices=size_labels)
    grant_agreement_start = wtforms.DateField(
        label='Grant Agreement start date',
        widget=widgets.MonthInput(),
        format='%Y-%m',
        validators=[wtforms.validators.Optional()])
    description = wtforms.TextAreaField()

    def validate_partner(form, field):
        fund_key = form._fields['fund'].data
        if fund_key is None:
            return
        fund = fund_key.get()
        if fund.partner_required and not field.data:
            raise wtforms.ValidationError(
                'A partner must be specified with fund - %s' % fund.name)
Ejemplo n.º 28
0
class TaskForm(FlaskForm):
    ## 属性
    name = wtforms.StringField(
        render_kw={
            "class": "form-control",
            "placeholder": "任务的名字"
        },
        validators=[
            validators.DataRequired("任务的名字不能为空"),
            # validators.Email("必须符合邮箱格式"),
            # validators.length(max=8,min=6),
            keywords_valid
        ])
    description = wtforms.TextField(
        render_kw={
            "class": "form-control",
            "placeholder": "任务的描述"
        },
        # validators=[
        #     validators.EqualTo("name"),    ### 描述和name值一样
        # ]
    )
    time = wtforms.DateField(render_kw={
        "class": "form-control",
        "placeholder": "任务的时间"
    })
    public = wtforms.StringField(render_kw={
        "class": "form-control",
        "placeholder": "任务的发布人"
    })
Ejemplo n.º 29
0
class TaskFrom(FlaskForm):
    name=wtforms.StringField(
        render_kw={
            'class':'form-control',
            'placeholder':'任务名称'
        },
        validators=[
            validators.data_required('不可以为空'),
            keywords_vaild
        ]
    )
    description=wtforms.StringField(
        render_kw={
            'class': 'form-control',
            'placeholder': '任务描述'
        }
    )
    time=wtforms.DateField(
        render_kw={
            'class': 'form-control',
            'placeholder': '任务时间'
        }
    )
    public=wtforms.StringField(
        render_kw={
            'class': 'form-control',
            'placeholder': '任务发布人'
        }
    )
Ejemplo n.º 30
0
class OrderItemForm(FlaskForm):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        specs = kwargs.get('specs', [])
        self.item_id.choices = [
            (s.id, '{} | {} | Catálogo: {} | {} unidades/produto'.format(
                s.product.name, s.manufacturer, s.catalog_number, s.units))
            for s in specs
        ]

    item_id = wtf.SelectField('Reativo',
                              coerce=int,
                              validators=[InputRequired()])
    amount = wtf.IntegerField(
        'Quantidade',
        widget=widgets.NumberInput(),
        render_kw={"autocomplete": "off"},
        validators=[
            InputRequired(),
            NumberRange(min=1,
                        max=None,
                        message='Quantidade deve ser maior que zero!')
        ])
    lot_number = wtf.StringField('Lote',
                                 render_kw={"autocomplete": "off"},
                                 validators=[InputRequired()])
    expiration_date = wtf.DateField('Data de Validade',
                                    widget=widgets.DateInput(),
                                    validators=[InputRequired()])
    add_product = wtf.SubmitField('Adicionar produto ao carrinho')
    finish_order = wtf.SubmitField('Ir para checkout')
    cancel = wtf.SubmitField('Limpar o carrinho')