Example #1
0
class LibrarianCreateForm(LibrarianForm):
    date_registered = DateField(_l('Registration date'),
                                validators=[required_cust_date()],
                                format=DATE_FORMAT,
                                default=date.today)
    username = StringField(_l('Username'),
                           validators=[
                               required_cust(),
                               length_cust(min=6, max=30),
                               username_cust()
                           ])
    password = PasswordField(_l('Password'),
                             validators=[required_cust(),
                                         length_cust(min=6)])
    confirm_password = PasswordField(
        _l('Confirm password'),
        validators=[required_cust(),
                    equal_to_cust('password')])
    is_administrator = BooleanField(
        _l('This will be library administrator account'))
    submit = SubmitField(_l('Add librarian'))

    def validate_date_registered(self, date_registered):
        if date_registered.data > date.today():
            raise ValidationError(_l('Date can not be set in future') + '.')
        elif date_registered.data < date.today() - timedelta(
                BACKWARD_INPUT_LIMIT):
            raise ValidationError(
                _l('Date cannot be set in past for more than') + ' ' +
                str(BACKWARD_INPUT_LIMIT) + ' ' + _l('days') + '.')
Example #2
0
class LibrarianChangePasswordForm(FlaskForm):
    new_password = PasswordField(
        _l('Password'), validators=[required_cust(),
                                    length_cust(min=6)])
    confirm_password = PasswordField(
        _l('Confirm password'),
        validators=[required_cust(),
                    equal_to_cust('new_password')])
    submit = SubmitField(_l('Update password'))
Example #3
0
class LibrarianBaseForm(FlaskForm):
    first_name = StringField(
        _l('First name'),
        validators=[required_cust(),
                    length_cust(max=20),
                    string_cust()])
    last_name = StringField(
        _l('Last name'),
        validators=[required_cust(),
                    length_cust(max=30),
                    string_cust()])
Example #4
0
class PriceAdd(FlaskForm):
    price_value = DecimalField(_l('Price'),
                               validators=[required_cust_decimal()],
                               places=2)
    currency = StringField(
        _l('Currency'),
        validators=[required_cust(),
                    char_cust(),
                    length_cust(max=3)])
    note = TextAreaField(
        _l('Note'),
        validators=[optional_cust(),
                    string_cust(),
                    length_cust(max=150)])
    submit = SubmitField(_l('Add price'))

    def validate_price_value(self, price_value):
        if price_value.data < 0.0:
            raise ValidationError(_l('Price can not be lower than zero') + '.')
        elif price_value.data > 100.0:
            raise ValidationError(
                _l('Price can not be higher than hundred') + '.')
        else:
            exists = ExtensionPrice.query.filter(
                and_(ExtensionPrice.price_value == price_value.data,
                     ExtensionPrice.currency == self.currency.data)).first()
            if not exists == None:
                raise ValidationError(
                    _l('Price value already exists, please consider activating the existing one'
                       ) + '.')
Example #5
0
class LibrarianRequestChangePasswordForm(LibrarianBaseForm):
    username = StringField(_l('Username'),
                           validators=[
                               required_cust(),
                               length_cust(min=6, max=30),
                               username_cust()
                           ])
    submit = SubmitField(_l('Send request'))
Example #6
0
class LibrarianForm(LibrarianBaseForm):
    email = StringField(
        _l('E-mail address'),
        validators=[optional_cust(),
                    email_cust(),
                    length_cust(max=40)])
    phone = StringField(_l('Phone'),
                        validators=[required_cust(),
                                    phone_cust()])
    address = StringField(
        _l('Address'),
        validators=[required_cust(),
                    length_cust(max=50),
                    string_cust()])

    def validate_username(self, username):
        librarian = Librarian.query.filter_by(username=username.data).first()
        if librarian:
            raise ValidationError(
                _l('That username is taken. Please choose a different one') +
                '.')
Example #7
0
class UserForm(FlaskForm):
    first_name = StringField(_l('First name'), validators=[required_cust(), length_cust(max=20), string_cust()])
    last_name = StringField(_l('Last name'), validators=[required_cust(), length_cust(max=30), string_cust()])
    father_name = StringField(_l('Father name'), validators=[required_cust(), length_cust(max=20), string_cust()])
    profession = StringField(_l('Profession'), validators=[required_cust(), length_cust(max=50), string_cust()])
    email = StringField(_l('E-mail address'), validators=[optional_cust(), email_cust(), length_cust(max=50)])
    phone = StringField(_l('Phone'), validators=[required_cust(), phone_cust()])
    address = StringField(_l('Address'), validators=[required_cust(), length_cust(max=60), string_cust()])
Example #8
0
class BookCUForm(FlaskForm):
    inv_number = StringField(
        _l('Inventory number'),
        validators=[required_cust(),
                    numeric_cust(),
                    length_cust(max=6)])
    signature = StringField(
        _l('Signature'),
        validators=[required_cust(),
                    signature_cust(),
                    length_cust(max=15)])
    title = StringField(
        _l('Title'),
        validators=[required_cust(),
                    string_cust(),
                    length_cust(max=50)])
    author = StringField(
        _l('Author'),
        validators=[required_cust(),
                    string_cust(),
                    length_cust(max=50)])
    has_error = BooleanField(
        _l('Has error') + ' (' +
        _l('book has a problematic inventory number') + ')')
Example #9
0
class LoginForm(FlaskForm):
    username = StringField(_l('Username'),
                           validators=[required_cust(),
                                       username_cust()])
    password = PasswordField(_l('Password'), validators=[required_cust()])
    submit = SubmitField(_l('Login'))
Example #10
0
class LibrarianUpdatePasswordForm(LibrarianChangePasswordForm):
    old_password = PasswordField(
        _l('Old password'), validators=[required_cust(),
                                        length_cust(min=6)])