Ejemplo n.º 1
0
 def test_positive(self):
     with open(join(self.datadir, 'validimage.jpg')) as image:
         buf = image.buffer.read()
     self.assertTrue(AllowedMime.validate(
         buf=buf,
         mimes=self.mimes,
     ))
Ejemplo n.º 2
0
 def test_negative(self):
     with open(join(self.datadir, 'textfile.jpg')) as image:
         buf = image.buffer.read()
     self.assertFalse(AllowedMime.validate(
         buf=buf,
         mimes=self.mimes,
     ))
Ejemplo n.º 3
0
 def test_negative(self):
     with open(join(self.datadir, 'textfile.jpg')) as image:
         buf = image.buffer.read()
     self.assertFalse(AllowedMime.validate(
         buf=buf,
         mimes=self.mimes,
     ))
Ejemplo n.º 4
0
 def test_positive(self):
     with open(join(self.datadir, 'validimage.jpg')) as image:
         buf = image.buffer.read()
     self.assertTrue(AllowedMime.validate(
         buf=buf,
         mimes=self.mimes,
     ))
Ejemplo n.º 5
0
 class ImageUploadForm(Form):
     title = StringField(
         label='Название',
         validators=[
             Length(
                 max=32,
                 message='Must not exceed 32 symbols',
             )
         ],
     )
     description = TextAreaField(
         label='Описание (замещающий текст)',
         validators=[
             Length(
                 max=128,
                 message='Must not exceed 128 symbols',
             )
         ],
     )
     if not is_update:
         image = FileField(
             label='Картинка',
             validators=[
                 AllowedMime(config['IMG_MIMES']),
                 DataRequired(),
             ]
         )
     else:
         delete = BooleanField(
             label='Удалить',
             description='Эта картинка будет удалена навсегда'
                         ' (очень надолго!)',
         )
Ejemplo n.º 6
0
 class ApplyForm(Form):
     name = StringField(
         label='Имя',
         validators=[DataRequired('Введите пожалуйста ваши имя и фамилию')])
     email = StringField(label='Email',
                         validators=[
                             Email('Неверный e-mail адрес'),
                             DataRequired('Введите пожалуйста e-mail')
                         ])
     phone = PhoneNumberField(
         label='Телефон',
         country_code='UA',
         validators=[DataRequired('Введите пожалуйста телефон')])
     comment = TextAreaField(label='Коментарий')
     attachment = FileField(label='Резюме (макс. 15 Мб)',
                            validators=[
                                AllowedMime(
                                    config['DOC_MIMES'],
                                    message='Недопустимое расширение файла')
                            ])
Ejemplo n.º 7
0
 class ImageUploadForm(Form):
     if not is_update:
         img_category = SelectField(
             label='Категория',
             choices=[
                 (UploadedImage.IMG_CATEGORY.other.value, 'Разное'),
                 (UploadedImage.IMG_CATEGORY.gallery.value, 'Галерея'),
             ],
             coerce=lambda x: UploadedImage.IMG_CATEGORY(int(x)),
             default=UploadedImage.IMG_CATEGORY.other,
         )
     title = StringField(
         label='Название',
         validators=[
             Length(
                 max=32,
                 message='Must not exceed 32 symbols',
             )
         ],
     )
     description = TextAreaField(
         label='Описание (замещающий текст)',
         validators=[
             Length(
                 max=128,
                 message='Must not exceed 128 symbols',
             )
         ],
     )
     if not is_update:
         image = FileField(
             label='Картинка',
             validators=[
                 AllowedMime(config['IMG_MIMES']),
                 DataRequired(),
             ]
         )