fix: restored badges handlers feat: remove FE code for badges fix: resolved failing tests fix: removed test case for badges app fix: unused import error fix: Response Field Count fix: shareable account response length fix: resolved PR comments fix: revert settings override feat!: Removed Badges App fix: restored badges handlers feat: remove FE code for badges fix: resolved failing tests fix: removed test case for badges app fix: unused import error fix: Response Field Count fix: shareable account response length fix: revert subscription badge
26 lines
702 B
Python
26 lines
702 B
Python
"""
|
|
Database models for the badges app
|
|
"""
|
|
|
|
|
|
from django.core.exceptions import ValidationError
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
|
|
def validate_badge_image(image):
|
|
"""
|
|
Validates that a particular image is small enough to be a badge and square.
|
|
"""
|
|
if image.width != image.height:
|
|
raise ValidationError(_("The badge image must be square."))
|
|
if not image.size < (250 * 1024):
|
|
raise ValidationError(_("The badge image file size must be less than 250KB."))
|
|
|
|
|
|
def validate_lowercase(string):
|
|
"""
|
|
Validates that a string is lowercase.
|
|
"""
|
|
if not string.islower():
|
|
raise ValidationError(_("This value must be all lowercase."))
|