Example #1
0
class ProfileForm(ProfileFormBase):
    multipart = True
    next = HiddenField()
    name = TextField(u'Name', [Required()])
    email = EmailField(u'Email', [Required(), Email()])
    #role_code = RadioField(_("Role")) #, [AnyOf([str(val) for val in USER_ROLE.keys()])], choices=[(str(val), label) for val, label in role_codes().items()])
    # Don't use the same name as model because we are going to use populate_obj().
    avatar_file = FileField(u"Avatar", [Optional()])
    gender_code = RadioField(u"Gender",
                             [AnyOf([str(val) for val in GENDER_TYPE.keys()])],
                             choices=[(str(val), label)
                                      for val, label in GENDER_TYPE.items()])
    age = IntegerField(u'Age', [Optional(), NumberRange(AGE_MIN, AGE_MAX)])
    phone = TelField(u'Phone', [Length(max=64)])
    url = URLField(u'URL', [Optional(), URL()])
    location = TextField(u'Location', [Length(max=64)])
    bio = TextAreaField(u'Bio', [Length(max=1024)])
    submit = SubmitField(u'Save')

    def get_role_codes(self, role_code):
        if role_code == 0:
            roles = USER_ROLE
        elif role_code == 3:
            roles = {k: v for k, v in USER_ROLE.items() if k in ('2', '3')}
        elif role_code == 1:
            roles = USER_ROLE[1:2]
        self.role_code = RadioField(
            _("Role"), [AnyOf([str(val) for val in roles.keys()])],
            choices=[(str(val), label) for val, label in roles.items()])

    def validate_avatar_file(form, field):
        if field.data and not allowed_file(field.data.filename):
            raise ValidationError("Please upload files with extensions: %s" %
                                  "/".join(ALLOWED_AVATAR_EXTENSIONS))
Example #2
0
class ProfileForm(Form):
    multipart = True
    next = HiddenField()
    email = EmailField(_('Email'), [Required(), Email()])
    # Don't use the same name as model because we are going to use populate_obj().
    avatar_file = FileField(_("Avatar"), [Optional()])
    receive_station_notifications = BooleanField(
        _('Receive Program Notifications'))
    gender_code = RadioField(_("Gender"),
                             [AnyOf([str(val) for val in GENDER_TYPE.keys()])],
                             choices=[(str(val), label)
                                      for val, label in GENDER_TYPE.items()])
    age = IntegerField(_('Age'), [Optional(), NumberRange(AGE_MIN, AGE_MAX)])
    phone = TelField(_('Phone'), [Length(max=64)])
    url = URLField(_('URL'), [Optional(), URL()])
    location = TextField(_('Location'), [Length(max=64)])
    bio = TextAreaField(_('Bio'), [Length(max=1024)])
    submit = SubmitField(_('Save'))

    def validate_name(form, field):
        user = User.get_by_id(current_user.id)
        if not user.check_name(field.data):
            raise ValidationError(_("Please pick another name."))

    def validate_avatar_file(form, field):
        if field.data and not allowed_file(field.data.filename):
            raise ValidationError(
                _("Please upload files with extensions: %s" %
                  "/".join(ALLOWED_AVATAR_EXTENSIONS)))
Example #3
0
class EditProfileForm(Form):
    multipart = True
    next = HiddenField()
    networks = QuerySelectMultipleField(
        query_factory=lambda: current_user.networks)
    email = EmailField(u'Email', [Required(), Email()])
    # Don't use the same name as model because we are going to use populate_obj().
    avatar_file = FileField(u"Avatar", [Optional()])
    gender_code = RadioField(u"Gender",
                             [AnyOf([str(val) for val in GENDER_TYPE.keys()])],
                             choices=[(str(val), label)
                                      for val, label in GENDER_TYPE.items()])
    age = IntegerField(u'Age', [Optional(), NumberRange(AGE_MIN, AGE_MAX)])
    phone = TelField(u'Phone', [Length(max=64)])
    url = URLField(u'URL', [Optional(), URL()])
    location = TextField(u'Location', [Length(max=64)])
    bio = TextAreaField(u'Bio', [Length(max=1024)])
    submit = SubmitField(u'Save')

    def set_networks(self, networks):
        #self.networks.choices = networks
        pass

    def validate_name(form, field):
        user = User.get_by_id(current_user.id)
        if not user.check_name(field.data):
            raise ValidationError("Please pick another name.")

    def validate_avatar_file(form, field):
        if field.data and not allowed_file(field.data.filename):
            raise ValidationError("Please upload files with extensions: %s" %
                                  "/".join(ALLOWED_AVATAR_EXTENSIONS))
Example #4
0
class ProfileCreateForm(Form):
    multipart = True
    next = HiddenField()
    email = EmailField(u'Email', [Required(), Email()])
    name = TextField(u'Name', [Required(), Length(max=100)])
    password = PasswordField(u'Password', [Required(), Length(max=100)])
    password1 = PasswordField(u'Retype-password',
                              [Required(), Length(max=100)])
    # Don't use the same name as model because we are going to use populate_obj().
    avatar_file = FileField(u"Avatar", [Optional()])
    gender_code = RadioField(u"Gender",
                             [AnyOf([str(val) for val in GENDER_TYPE.keys()])],
                             choices=[(str(val), label)
                                      for val, label in GENDER_TYPE.items()])
    age = IntegerField(u'Age', [Optional(), NumberRange(AGE_MIN, AGE_MAX)])
    phone = TelField(u'Phone', [Length(max=64)])
    url = URLField(u'URL', [Optional(), URL()])
    location = TextField(u'Location', [Length(max=64)])
    bio = TextAreaField(u'Bio', [Length(max=1024)])
    submit = SubmitField(u'Save')

    def validate_avatar_file(form, field):
        if field.data and not allowed_file(field.data.filename):
            raise ValidationError("Please upload files with extensions: %s" %
                                  "/".join(ALLOWED_AVATAR_EXTENSIONS))

    def validate_password(self, field):
        if field.data != self.password1.data:
            raise ValidationError("The Passwords Don't Match")
Example #5
0
class ContactForm(Form):
    '''
    Form class for WTForms usage.
    '''
    name = StringField('name', validators=[DataRequired(), Length(min=3)])
    phone = TelField('phone',
                     validators=[DataRequired(),
                                 Regexp("^[0-9]{10}$")])
    email = EmailField('email', validators=[DataRequired()])
    message = TextAreaField('message')
Example #6
0
class UserCreateForm(Form):
    uid = StringField(u"Login", validators=[DataRequired()])
    givenName = StringField(u"Vorname", validators=[DataRequired()])
    sn = StringField(u"Nachname", validators=[DataRequired()])
    userPassword = PasswordField(u"Passwort",
                                 validators=[DataRequired(),
                                             Length(min=8)])
    userPassword_confirmation = PasswordField(
        u"Passwort bestätigen",
        validators=[DataRequired(), EqualTo('userPassword')])
    mail = EmailField(u"E-Mail", validators=[DataRequired(), Email()])
    mobile = TelField(u"Handy")
Example #7
0
class ProfileCreateForm(ProfileCreateFormBase):
    multipart = True
    next = HiddenField()
    networks = QuerySelectMultipleField(
        query_factory=lambda: current_user.networks)
    email = EmailField(u'Email', [Required(), Email()])
    name = TextField(u'Name', [Required(), Length(max=100)])
    password = PasswordField(u'Password', [Required(), Length(max=100)])
    password1 = PasswordField(u'Retype-password',
                              [Required(), Length(max=100)])
    role_code = RadioField(_("Role"),
                           [AnyOf([str(val) for val in USER_ROLE.keys()])],
                           choices=[])
    # Don't use the same name as model because we are going to use populate_obj().
    avatar_file = FileField(u"Avatar", [Optional()])
    gender_code = RadioField(u"Gender",
                             [AnyOf([str(val) for val in GENDER_TYPE.keys()])],
                             choices=[(str(val), label)
                                      for val, label in GENDER_TYPE.items()])
    age = IntegerField(u'Age', [Optional(), NumberRange(AGE_MIN, AGE_MAX)])
    phone = TelField(u'Phone', [Length(max=64)])
    url = URLField(u'URL', [Optional(), URL()])
    location = TextField(u'Location', [Length(max=64)])
    bio = TextAreaField(u'Bio', [Length(max=1024)])
    submit = SubmitField(u'Save')

    def get_role_codes(self, role_code):
        if role_code == 0:
            return [(str(k), v) for k, v in USER_ROLE.items()]
        elif role_code == 3:
            return [(str(k), v) for k, v in USER_ROLE.items() if k in (3, 4)]
        elif role_code == 1:
            return [(str(k), v) for k, v in USER_ROLE.items()
                    if k in (1, 2, 3, 4)]

    def validate_avatar_file(form, field):
        if field.data and not allowed_file(field.data.filename):
            raise ValidationError("Please upload files with extensions: %s" %
                                  "/".join(ALLOWED_AVATAR_EXTENSIONS))

    def validate_password(self, field):
        if field.data != self.password1.data:
            raise ValidationError("The Passwords Don't Match")

    def validate_name(self, field):
        if User.query.filter_by(name=field.data).first() is not None:
            raise ValidationError(_('This username is already registered'))

    def validate_email(self, field):
        if User.query.filter_by(email=field.data).first() is not None:
            raise ValidationError(_('This email is already registered'))
Example #8
0
class ContactForm(Form):
    name = StringField("Name", [validators.Required()],
                       render_kw={"placeholder": "Name"})
    company = StringField("Company", [validators.Required()],
                          render_kw={"placeholder": "Company"})
    email = EmailField(
        "Email",
        [validators.Required(), validators.Email()],
        render_kw={"placeholder": "Email"})
    phone = TelField("Phone", [validators.Required()],
                     render_kw={"placeholder": "Phone"})
    message = TextAreaField("Message", [validators.Required()],
                            render_kw={"placeholder": "Message"})
    submit = SubmitField("Submit")
class ProfileForm(Form):
    email = EmailField('Email', [DataRequired(), Email()])
    # Don't use the same name as model because we are going to use populate_obj().
    # avatar_file = FileField("Avatar", [Optional()])
    phone = TelField('Phone', [DataRequired(), Length(max=64)])
    url = URLField('URL', [Optional(), URL()])
    location = StringField('Location', [Optional(), Length(max=64)])
    bio = TextAreaField('Bio', [Optional(), Length(max=1024)],
                        description=BIO_TIP)
    submit = SubmitField('Update profile',
                         render_kw={"class": "btn btn-success"})

    def validate_name(form, field):
        user = User.get_by_id(current_user.id)
        if not user.check_name(field.data):
            raise ValidationError("Please pick another name.")

    def validate_avatar_file(form, field):
        if field.data and not allowed_file(field.data.filename):
            raise ValidationError("Please upload files with extensions: %s" %
                                  "/".join(ALLOWED_AVATAR_EXTENSIONS))
Example #10
0
class ProfileCreateForm(Form):
    user_id = None
    multipart = True
    next = HiddenField()
    networks = QuerySelectMultipleField(
        query_factory=lambda: current_user.networks) # networks = (current_user.name,[Required()])
    email = EmailField(_('Email'), [Required(), Email()])
    name = TextField(_('Name'), [Required(), Length(max=100)])
    password = PasswordField(_('Password'), [Required(), Length(max=100)])
    password1 = PasswordField(_('Retype-password'), [Required(), Length(max=100)])

    # Don't use the same name as model because we are going to use populate_obj().
    avatar_file = FileField(_("Avatar"), [Optional()])
    receive_station_notifications = BooleanField(_('Receive Program Notifications'))
    gender_code = RadioField(_("Gender"), [AnyOf([str(val) for val in GENDER_TYPE.keys()])],
                             choices=[(str(val), label) for val, label in GENDER_TYPE.items()])
    age = IntegerField(_('Age'), [Optional(), NumberRange(AGE_MIN, AGE_MAX)])
    phone = TelField(_('Phone'), [Length(max=64)])
    url = URLField(_('URL'), [Optional(), URL()])
    location = TextField(_('Location'), [Length(max=64)])
    bio = TextAreaField(_('Bio'), [Length(max=1024)])
    submit = SubmitField(_('Save'))

    def validate_avatar_file(form, field):
        if field.data and not allowed_file(field.data.filename):
            raise ValidationError(_("Please upload files with extensions: %s" % "/".join(ALLOWED_AVATAR_EXTENSIONS)))

    def validate_password(self, field):
        if field.data != self.password1.data:
            raise ValidationError(_("The Passwords Don't Match"))

    def validate_name(self, field):
        if User.query.filter(User.name==field.data).filter(User.id != self.user_id).first() is not None:
            raise ValidationError(_('This username is already registered'))

    def validate_email(self, field):
        if User.query.filter(User.email==field.data).filter(User.id != self.user_id).first() is not None:
            raise ValidationError(_('This email is already registered'))
Example #11
0
class SignUpForm(Form):
    first_name = TextField('first name', validators=[DataRequired()])
    last_name = TextField('last name', validators=[DataRequired()])
    phone_number = TelField('phone number', validators=[DataRequired()])
    email = EmailField('email', validators=[DataRequired()])
    password = PasswordField('password', [validators.Required(),
                             validators.EqualTo('confirm',
                             message='Passwords must match')])
    confirm = PasswordField('confirm password', [validators.Required()])

    def validate_phone_number(self, field):
        error_message = "Invalid phone number. Example: +5599999999"
        try:
            data = phonenumbers.parse(field.data)
        except:
            raise validators.ValidationError(error_message)
        if not phonenumbers.is_possible_number(data):
            raise validators.ValidationError(error_message)

    @property
    def as_dict(self):
        data = self.data
        del data['confirm']
        return data
Example #12
0
class UserDetailsForm(Form):
    givenName = StringField(u"Vorname", validators=[DataRequired()])
    sn = StringField(u"Nachname", validators=[DataRequired()])
    mail = EmailField(u"E-Mail", validators=[DataRequired(), Email()])
    mobile = TelField(u"Handy")
Example #13
0
class BaseForm(Form):
    # Personal data
    species = RadioButtonField('Species',
                               validators=[InputRequired()],
                               choices=[('man', u'Vīrietis'),
                                        ('woman', u'Sieviete')],
                               default='')
    name = TextField('Name', validators=[InputRequired(), Length(max=255)])
    surname = TextField('Surname',
                        validators=[InputRequired(),
                                    Length(max=255)])
    nickname = TextField('Nickname', validators=[Length(max=255)])
    pcode = TextField('ID code', validators=[Length(max=255)])
    contract_nr = TextField('Passport nr.', validators=[Length(max=255)])
    birthdate = DateField('Birthdate')
    play_age_from = TextField('Play age from', validators=[Length(max=2)])
    play_age_to = TextField('Play age to', validators=[Length(max=2)])

    # Family
    mother_phone_code = TextField('Mother phone code',
                                  validators=[Length(max=255)])
    mother_phone = TextField('Mother phone', validators=[Length(max=255)])
    mother_name = TextField('Mother name', validators=[Length(max=255)])
    father_phone_code = TextField('Father phone code',
                                  validators=[Length(max=255)])
    father_phone = TextField('Father phone', validators=[Length(max=255)])
    father_name = TextField('Father name', validators=[Length(max=255)])

    #Contact information
    my_phone_code = TelField('Phone code', validators=[Length(max=255)])
    my_phone = TelField('Phone', validators=[InputRequired(), Length(max=255)])
    email = TextField('E-mail', validators=[InputRequired(), Length(max=255)])
    other_phone_code = TextField('Other phone code',
                                 validators=[Length(max=255)])
    other_phone = TextField('Other phone', validators=[Length(max=255)])
    home_address = TextField('Home address',
                             validators=[InputRequired(),
                                         Length(max=255)])
    city = SelectField('Nearest city', choices=[])

    #Personal carecteristics
    height = TextField('Height', validators=[Length(max=3)])
    foot_size = SelectFieldNoValidate('Foot size', choices=[])
    cloth_size = SelectFieldNoValidate('Cloth size', choices=[])
    voice = SelectFieldNoValidate('Voice', choices=[])
    haircolor = SelectField('Hair color', choices=[])
    eyecolor = SelectField('Eye color', choices=[])

    #Who you are?
    speciality = RadioButtonField('Speciality',
                                  validators=[InputRequired()],
                                  choices=[('actor', u'Aktieris'),
                                           ('professional', u'Profesionālis'),
                                           ('talent', u'Talants')])
    subspeciality = SelectMultipleFieldNoValidate('Subspeciality', choices=[])
    experience = TextAreaField('Experience', validators=[Length(max=1000)])
    cv = FileField('CV')
    #actor = TextField('Actor')
    #professional = TextField('Professional')
    #talent = TextField('Talent')

    #Skills
    #danceskill = TextField('Dance skill')
    danceskill = SelectMultipleFieldNoValidate('Dance skill', choices=[])
    singskill = SelectMultipleFieldNoValidate('Sing skill', choices=[])
    musicskill = SelectMultipleFieldNoValidate('Music skill', choices=[])
    sportskill = SelectMultipleFieldNoValidate('Sport skill', choices=[])
    swimskill = SelectMultipleFieldNoValidate('Swim skill', choices=[])
    driveskill = SelectMultipleFieldNoValidate('Drive skill', choices=[])
    languageskill = SelectMultipleFieldNoValidate('Language skill', choices=[])
    otherskill = SelectMultipleFieldNoValidate('Other skill', choices=[])

    #Work and Education
    educational_institution = SelectMultipleFieldNoValidate(
        'Educational institution', choices=[])
    learned_profession = SelectMultipleFieldNoValidate('Learned profession',
                                                       choices=[])
    degree = SelectMultipleFieldNoValidate('Level of education', choices=[])
    current_occupation = SelectFieldNoValidate('Current occupation',
                                               choices=[])
    workplace = TextField('Workplace', validators=[Length(max=255)])

    #My whishes
    want_participate = SelectMultipleFieldNoValidate('Want to participate',
                                                     choices=[])
    dont_want_participate = SelectMultipleFieldNoValidate(
        'Don`t want to participate', choices=[])
    interested_in = SelectMultipleFieldNoValidate('Interested in', choices=[])

    #Notes for consideration
    #contact_lenses = TextField('Contact Lenses')
    contact_lenses = BooleanField('Contact Lenses')
    be_dressed = BooleanField('Don`t want to be undressed')
    tattoo = SelectMultipleFieldNoValidate('Tattoos', choices=[])
    piercing = SelectMultipleFieldNoValidate('Piercings', choices=[])
    afraidof = SelectMultipleFieldNoValidate('I`am afraid of', choices=[])
    religion = SelectMultipleFieldNoValidate('Religion beliefs', choices=[])

    image1 = FileField('Image No.1')
    image2 = FileField('Image No.2')
    profile_image = FileField('Profile image')

    cb_tags = SelectMultipleFieldNoValidate('Casting bridge tags', choices=[])
    family_notes = SelectMultipleFieldNoValidate('Family notes', choices=[])

    video = FileField('Video')
    audio = FileField('Audio')