예제 #1
0
class LoginForm(FlaskForm):
    email = StringField('Your email', validators=[DataRequired(), Email()])
    password = PasswordField('Your password', validators=[DataRequired()])
    remember_me = BooleanField('Keep me logged in')
    submit = SubmitField('Login')
예제 #2
0
class LoginForm(Form):
    username = StringField('Username',
                           [InputRequired(message="Please enter your name.")])
    password = PasswordField(
        'Password', validators=[DataRequired(message="enter password")])
    submit = SubmitField('login')
예제 #3
0
파일: forms.py 프로젝트: koufounak/indico
class EventDatesForm(IndicoForm):
    _main_fields = ('start_dt', 'end_dt', 'timezone', 'update_timetable')
    _override_date_fields = ('start_dt_override', 'end_dt_override')

    timezone = IndicoTimezoneSelectField(_('Timezone'), [DataRequired()])
    start_dt = IndicoDateTimeField(_("Start"), [InputRequired()], allow_clear=False)
    end_dt = IndicoDateTimeField(_("End"), [InputRequired(), LinkedDateTime('start_dt', not_equal=True)],
                                 allow_clear=False)
    update_timetable = BooleanField(_('Update timetable'), widget=SwitchWidget(),
                                    description=_("Move sessions/contributions/breaks in the timetable according "
                                                  "to the new event start time."))
    start_dt_override = IndicoDateTimeField(_("Start"), [Optional()], allow_clear=True,
                                            description=_("Specifying this date overrides the start date displayed "
                                                          "on the main conference page."))
    end_dt_override = IndicoDateTimeField(_("End"), [Optional(), LinkedDateTime('start_dt_override', not_equal=True)],
                                          allow_clear=True,
                                          description=_("Specifying this date overrides the end date displayed "
                                                        "on the main conference page."))

    def __init__(self, *args, **kwargs):
        self.event = kwargs.pop('event')
        super(EventDatesForm, self).__init__(*args, **kwargs)
        # timetable synchronization
        self.check_timetable_boundaries = (self.event.type_ != EventType.lecture)
        if self.check_timetable_boundaries:
            self.toplevel_timetable_entries = get_top_level_entries(self.event)
            if not self.toplevel_timetable_entries:
                self.check_timetable_boundaries = False
        if not self.check_timetable_boundaries:
            del self.update_timetable
        # displayed dates
        self.has_displayed_dates = (self.event.type_ == EventType.conference)
        if self.has_displayed_dates:
            start_dt = self.start_dt.data or self.start_dt.object_data
            end_dt = self.end_dt.data or self.end_dt.object_data
            self.start_dt_override.default_time = start_dt.astimezone(timezone(self.timezone.data)).time()
            self.end_dt_override.default_time = end_dt.astimezone(timezone(self.timezone.data)).time()
        else:
            del self.start_dt_override
            del self.end_dt_override

    def validate_start_dt(self, field):
        if not self.check_timetable_boundaries or self.update_timetable.data or field.object_data == field.data:
            return
        if field.data > min(self.toplevel_timetable_entries, key=attrgetter('start_dt')).start_dt:
            raise ValidationError(_("To use this start date the timetable must be updated."))

    def validate_end_dt(self, field):
        if not self.check_timetable_boundaries:
            return
        if self.update_timetable.data:
            # if we move timetable entries according to the start date
            # change, check that there's enough time at the end.
            start_dt_offset = self.start_dt.data - self.start_dt.object_data
            end_buffer = field.data - max(self.toplevel_timetable_entries, key=attrgetter('end_dt')).end_dt
            delta = max(timedelta(), start_dt_offset - end_buffer)
            if delta:
                delta_str = format_human_timedelta(delta, 'minutes', True)
                raise ValidationError(_("The event is too short to fit all timetable entries. "
                                        "It must be at least {} longer.").format(delta_str))
        else:
            # if we do not update timetable entries, only check that
            # the event does not end before its last timetable entry;
            # a similar check for the start time is done above in that
            # field's validation method.
            max_end_dt = max(self.toplevel_timetable_entries, key=attrgetter('end_dt')).end_dt
            if field.data < max_end_dt:
                raise ValidationError(_("The event cannot end before its last timetable entry, which is at {}.")
                                      .format(to_unicode(format_datetime(max_end_dt, timezone=self.event.tzinfo))))
예제 #4
0
class ResetPasswordForm(FlaskForm):
    password = PasswordField('Password', validators=[DataRequired()])
    confirm_password = PasswordField('Confirm Password',
                                     validators=[DataRequired(), EqualTo('password')])
    submit = SubmitField('Reset Password')
예제 #5
0
파일: manage.py 프로젝트: lafant/zsky
class SearchForm(FlaskForm):
    search = StringField(validators = [DataRequired(message= '请输入关键字')],render_kw={"placeholder":"搜索电影,软件,图片,资料,番号...."})
    submit = SubmitField('搜索')
예제 #6
0
파일: forms.py 프로젝트: lmukund/Telemetry
class Edit(FlaskForm):
    access=PasswordField('Access Code',validators=[DataRequired()])
    information_block = StringField('Information Block',validators=[DataRequired()])
    attribute = StringField('Attribute', validators=[DataRequired()])
    description = StringField('Description', validators=[DataRequired()])
    submit = SubmitField('Submit')
예제 #7
0
파일: forms.py 프로젝트: henrycchi/Assign2
class LoginForm(FlaskForm):
    username = StringField('Username', validators=[DataRequired()], id='uname')
    password = PasswordField('Password', validators=[DataRequired()], id='pword')
    twofa = StringField('2FA - ENTER YOUR CELL NUMBER', validators=[DataRequired()], id='2fa')
    remember_me = BooleanField('Remember Me')
    submit = SubmitField('Sign In')
예제 #8
0
파일: forms.py 프로젝트: mmoyer35/MyBlog
class RegisterForm(FlaskForm):
    email =  StringField("Email", validators=[DataRequired()])
    password =  StringField("Password", validators=[DataRequired()])
    name = StringField("Name", validators=[DataRequired()])
    submit = SubmitField("Register")
예제 #9
0
파일: forms.py 프로젝트: mmoyer35/MyBlog
class LoginForm(FlaskForm):
    email =  StringField("Email", validators=[DataRequired()])
    password =  StringField("Password", validators=[DataRequired()])
    submit = SubmitField("Login")
예제 #10
0
파일: forms.py 프로젝트: Buffi79/samplemod
class ConfigForm(FlaskForm):
    level = StringField('loglevel', validators=[DataRequired()])
    format = StringField('format', validators=[DataRequired()])
    telsearchkey = StringField('telsearch', validators=[DataRequired()])
    submit = SubmitField('Save')
예제 #11
0
class ClothForm(FlaskForm):
    color_name = StringField("颜色名称", validators=[DataRequired(),])
    supplier = StringField("供应商", validators=[DataRequired(),])
    width = FloatField('门幅宽度', validators=[DataRequired(),])
    fibre = SelectField('材质', choices=('全棉', '棉绸', '雪纺'))
    submit = SubmitField('添加')
예제 #12
0
파일: forms.py 프로젝트: Buffi79/samplemod
class EditentryForm(FlaskForm):
    name = StringField('name', validators=[DataRequired()])
    description = StringField('description', validators=[DataRequired()])
    submit = SubmitField('Save')
예제 #13
0
파일: forms.py 프로젝트: ahayah/ludolatin
class PasswordResetForm(FlaskForm):
    password = PasswordField('Password',
                             validators=[DataRequired(),
                                         Length(8, 128)])
    submit = SubmitField('Reset password')
예제 #14
0
파일: forms.py 프로젝트: ahayah/ludolatin
class PasswordResetRequestForm(FlaskForm):
    email = StringField('Email',
                        validators=[DataRequired(),
                                    Length(1, 64),
                                    Email()])
    submit = SubmitField('Reset password')
예제 #15
0
class LoginForm(FlaskForm):
    username = StringField('Username', validators=[DataRequired()])
    password = PasswordField('Password', validators=[DataRequired()])
    remember_me = BooleanField('Remember Me')
    submit = SubmitField('Sign In')
예제 #16
0
파일: forms.py 프로젝트: mmoyer35/MyBlog
class CommentForm(FlaskForm):
    comment = CKEditorField("Enter your comments here", validators=[DataRequired()])
    submit = SubmitField("Leave a comment!")
예제 #17
0
class NameForm(Form):
    name = StringField('What is your name?', validators=[DataRequired()])
    submit = SubmitField('Submit')
예제 #18
0
파일: forms.py 프로젝트: mmoyer35/MyBlog
class CreatePostForm(FlaskForm):
    title = StringField("Blog Post Title", validators=[DataRequired()])
    subtitle = StringField("Subtitle", validators=[DataRequired()])
    img_url = StringField("Blog Image URL", validators=[DataRequired(), URL()])
    body = CKEditorField("Blog Content", validators=[DataRequired()])
    submit = SubmitField("Submit Post")
예제 #19
0
파일: forms.py 프로젝트: henrycchi/Assign2
class SpellForm(FlaskForm):
    inputtext = StringField('CheckText', id='inputtext', validators=[DataRequired()])
    submit = SubmitField('Submit')
예제 #20
0
class RegisterForm(FlaskForm):
    account = StringField(
        description='账号',
        validators=[
            DataRequired('账号不能为空')
        ],
        render_kw={
            'class' : 'form-control',
            'placeholder' : '请输入账户'
        }
    )
    pwd = PasswordField(
        description='密码',
        validators=[
            DataRequired('密码不能为空')
        ],
        render_kw={
            'class' : 'form-control',
            'placeholder' : '请输入密码'
        }
    )
    re_pwd = PasswordField(
        description='确认密码',
        validators=[
            DataRequired('确认密码不能为空'),
            EqualTo('pwd',message='两次密码不一致')
        ],
        render_kw={
            'class' : 'form-control',
            'placeholder' : '请输入确认密码'
        }
    )
    captcha = StringField(
        description='验证码',
        validators=[
            DataRequired('验证码不能为空'),
        ],
        render_kw={
            'class' : 'form-control',
            'placeholder' : '请输入验证码'
        }
    )
    submit = SubmitField(
        description='注册',
        render_kw={
            'class' : 'btn btn-primary'
        }
    )

    # 验证用户是否存在
    def validate_account(self,field):
        account = field.data
        user = User.query.filter_by(account=account).count()
        if user > 0: # 用户已经存在
            # 抛出异常
            raise ValidationError('账户已经存在')

    # 验证码校验
    def validate_captcha(self,field):
        # 获取用户输入的验证码
        captcha = field.data

        if not session['captcha']:
            raise ValidationError('非法操作')
        if session['captcha'].lower() != captcha.lower():
            raise ValidationError('验证码错误')
예제 #21
0
class LoginForm(FlaskForm):
    email = StringField('Email',
                        validators=[DataRequired(), Email()])
    password = PasswordField('Password', validators=[DataRequired()])
    remember = BooleanField('Remember Me')
    submit = SubmitField('Login')
예제 #22
0
파일: forms.py 프로젝트: psv-git/labs
class ForumCreateForm(FlaskForm):
    forum_name_field = StringField(
        "Forum name", validators=[DataRequired(),
                                  Length(min=2, max=50)])
    forum_create_submit = SubmitField("Create forum")
예제 #23
0
파일: manage.py 프로젝트: lafant/zsky
class LoginForm(FlaskForm):
    name=StringField('用户名',validators=[DataRequired(),Length(1,32)])
    password=PasswordField('密码',validators=[DataRequired(),Length(1,20)])
    def get_user(self):
        return db.session.query(User).filter_by(name=self.name.data).first()
예제 #24
0
class EditUserRoleForm(FlaskForm):
    id = IntegerField('id', validators=[DataRequired(), Exists(User, User.id)])
    role_id = IntegerField('id',
                           validators=[DataRequired(),
                                       Exists(Role, Role.id)])
예제 #25
0
class LoginForm(FlaskForm):
    email = StringField('Email', validators=[DataRequired(), Email()])
    password = PasswordField('Password', validators=[DataRequired()])
    submit = SubmitField('Log In')
예제 #26
0
class CommentForm(FlaskForm):
	content = TextAreaField('Content', validators=[DataRequired()])
	submit = SubmitField('Comment')
	
예제 #27
0
class PostForm(FlaskForm):
    title = StringField('Title',
                        validators=[DataRequired(),
                                    Length(min=3, max=20)])
    content = TextAreaField('Content', validators=[DataRequired()])
    submit = SubmitField('Post')
예제 #28
0
class PostForm(FlaskForm):
    post = TextAreaField('Say something',
                         validators=[DataRequired(),
                                     Length(min=1, max=140)])
    submit = SubmitField('Submit')
예제 #29
0
파일: forms.py 프로젝트: koufounak/indico
class CloneRepeatPatternForm(CloneRepeatUntilFormBase):
    week_day = IndicoWeekDayRepetitionField(_('Every'))
    num_months = IntegerField(_('Months'), [DataRequired(), NumberRange(min=1)], default=1,
                              description=_("Number of months between repetitions"))
예제 #30
0
class RegistrationForm(IndicoForm):
    first_name = StringField(_('First name'), [DataRequired()])
    last_name = StringField(_('Family name'), [DataRequired()])
    affiliation = StringField(_('Affiliation'))