Exemplo n.º 1
0
class SessionForm(Form):
    """Session Form class"""
    title = StringField('Title', [DataRequired()])
    subtitle = StringField('Subtitle')
    abstract = TextAreaField('Abstract')
    description = TextAreaField('Description', [DataRequired()])
    start_time = DateTimeField(
        'Start Time',
        [DataRequired(), CustomDateSessionValidate()])
    end_time = DateTimeField(
        'End Time',
        [DataRequired(), CustomDateSessionValidate()])
    level = QuerySelectField(label='Level',
                             query_factory=DataGetter.get_levels,
                             allow_blank=True)
    format = QuerySelectField(label='Format',
                              query_factory=DataGetter.get_formats,
                              allow_blank=True)
    language = QuerySelectField(label='Language',
                                query_factory=DataGetter.get_languages,
                                allow_blank=True)
    speakers = QuerySelectMultipleField(query_factory=get_speakers,
                                        allow_blank=True)
    microlocation = QuerySelectField(
        label='Microlocation',
        query_factory=DataGetter.get_microlocations_by_event_id,
        allow_blank=True)
Exemplo n.º 2
0
class EventForm(Form):
    """Event Form class"""
    name = StringField('Name', [DataRequired()])
    latitude = FloatField('Latitude')
    longitude = FloatField('Longitude')
    location_name = StringField('Location name')
    color = ColorField('Color')
    start_time = DateTimeField(
        'Start Time',
        [DataRequired(), CustomDateEventValidate()])
    end_time = DateTimeField(
        'End Time', [DataRequired(), CustomDateEventValidate()])
    logo = StringField('Logo')
    email = StringField('Email', [Optional(), Email()])
    slogan = StringField('Slogan')
    url = StringField('Url')
Exemplo n.º 3
0
class TodoForm(FlaskForm):
    """
    待办表单
    """

    content = StringField("内容")
    tododue = DateTimeField("截止日期", format="%Y-%m-%d %H:%M")
Exemplo n.º 4
0
class CreateNewPartyFrom(FlaskForm):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        if request.method == "GET":
            self.party_start_datetime.data = datetime.now()\
                .replace(tzinfo=timezone.utc, hour=23, minute=0, second=0, microsecond=0)
            self.party_end_datetime.data = datetime.now()\
                .replace(tzinfo=timezone.utc, hour=4, minute=0, second=0, microsecond=0) + timedelta(days=1)
            self.club_owner_commission.data = g.config.default_club_owner_commission
        self.club_owner.choices = [(0, f"Select a {CLUB_OWNER}")] + \
                                  [(u.user_id, u.username) for u in
                                   User.query.filter(User.access == ACCESS[CLUB_OWNER], User.is_active.is_(True)).all()
                                   if u.code is None]

    club_owner = SelectField('', validators=[NumberRange(1)], coerce=int)

    title = StringField(
        '',
        validators=[DataRequired("A title for the party is required.")],
        render_kw={"placeholder": "Party title"})
    party_start_datetime = DateTimeField('Party start')
    party_end_datetime = DateTimeField('Party end')
    num_available_tickets = IntegerField('',
                                         render_kw={
                                             "type": "number",
                                             "min": 0,
                                             "step": 1,
                                             "placeholder": "Number of tickets"
                                         })
    club_owner_commission = IntegerField('',
                                         render_kw={
                                             "type": "number",
                                             "min": 0,
                                             "step": 1,
                                             "placeholder":
                                             "Club owner commission"
                                         })
    ticket_price = FloatField('',
                              render_kw={
                                  "type": "number",
                                  "min": 0,
                                  "step": 0.01,
                                  "placeholder": "Ticket price"
                              })
    logo = FileField("Logo", validators=[DataRequired()])
    image = FileField("Image", validators=[DataRequired()])
    submit = SubmitField('Create new party')
Exemplo n.º 5
0
class EventForm(Form):
    """Event Form class"""
    name = StringField('Name', [DataRequired()])
    latitude = FloatField('Latitude')
    longitude = FloatField('Longitude')
    location_name = StringField('Location name')
    color = ColorField('Color')
    start_time = DateTimeField(
        'Start Time',
        [DataRequired(), CustomDateEventValidate()])
    end_time = DateTimeField(
        'End Time', [DataRequired(), CustomDateEventValidate()])
    logo = SelectField('Logo', coerce=str)
    # logo = QuerySelectField(query_factory=DataGetter.get_all_owner_files, allow_blank=True)
    email = StringField('Email')
    slogan = StringField('Slogan')
    url = StringField('Url')
Exemplo n.º 6
0
class QuizEditorForm(EditorForm):
    name = wtf.StringField(_l('Name'),
                           validators=[wtf.validators.DataRequired()])
    start_time = DateTimeField(_l('Start Time'),
                               validators=[wtf.validators.Optional()])
    public = wtf.BooleanField(_l('Public'),
                              validators=[wtf.validators.Optional()])
    submit = wtf.SubmitField(_l('Save'),
                             render_kw={'class_': 'btn btn-success'})

    def __init__(self, quiz: model.Quiz = None, *args, **kwargs):
        if quiz is None:
            quiz = model.Quiz()
        super().__init__(quiz, *args, **kwargs)
Exemplo n.º 7
0
    def scaffold_form(self):
        class WigoModelForm(Form):
            pass

        for field in self.model.fields.values():
            validators = [DataRequired() if field.required else Optional()]
            if field.name == 'id':
                continue
            if 'group_id' == field.name:
                setattr(WigoModelForm, 'group', AjaxSelectField(
                    WigoAjaxModelLoader('group', {'model': Group}), 'group', validators=validators))
            elif 'owner_id' == field.name:
                setattr(WigoModelForm, 'owner', AjaxSelectField(
                    WigoAjaxModelLoader('owner', {'model': User}), 'owner', validators=validators))
            elif isinstance(field, DateTimeType):
                setattr(WigoModelForm, field.name,
                        DateTimeField(field.name, default=field.default, validators=validators))
            elif isinstance(field, FloatType):
                setattr(WigoModelForm, field.name, FloatField(field.name, default=field.default, validators=validators))
            elif isinstance(field, NumberType):
                setattr(WigoModelForm, field.name,
                        IntegerField(field.name, default=field.default, validators=validators))
            elif isinstance(field, StringType):
                if field.choices:
                    setattr(WigoModelForm, field.name,
                            SelectField(field.name, choices=[(val, val) for val in field.choices],
                                        default=field.default))
                else:
                    setattr(WigoModelForm, field.name,
                            StringField(field.name, default=field.default, validators=validators))
            elif isinstance(field, BooleanType):
                setattr(WigoModelForm, field.name, BooleanField(field.name))
            elif isinstance(field, JsonType):
                setattr(WigoModelForm, field.name, JSONField(field.name, validators=validators))
            elif isinstance(field, ListType):
                setattr(WigoModelForm, field.name, Select2TagsField(field.name, validators=validators, save_as_list=True))

        return WigoModelForm
Exemplo n.º 8
0
class THCResultForm1(form.Form):
    team = QuerySelectField("Team", [InputRequired()])
    session_name = StringField("Session Name", [InputRequired()])
    date = DateTimeField("Session Date", [InputRequired()])
    deck = Select2Field("Question Deck", [InputRequired()])
    form_step = HiddenField(default=1)