| 74 | raise ValidationError(_("A team with this slug already exists.")) |
| 75 | |
| 76 | def validate_avatar(self, field): |
| 77 | if field.data: |
| 78 | if field.data.content_type not in [ |
| 79 | "image/jpeg", |
| 80 | "image/png", |
| 81 | "image/gif", |
| 82 | "image/webp", |
| 83 | ]: |
| 84 | raise ValidationError( |
| 85 | _( |
| 86 | "Invalid file type. Only JPEG, PNG, GIF and WebP images are allowed." |
| 87 | ) |
| 88 | ) |
| 89 | if field.data.size > 10 * 1024 * 1024: # 10MB |
| 90 | raise ValidationError( |
| 91 | _("File size exceeds the maximum allowed (10MB).") |
| 92 | ) |
| 93 | |
| 94 | |
| 95 | class TeamDeleteForm(StarletteForm): |