This commit is contained in:
Tobias Brunner 2025-01-27 15:14:58 +01:00
parent 4c6732f9d0
commit 79a8c6f280
No known key found for this signature in database
13 changed files with 169 additions and 47 deletions

View file

@ -1,9 +1,22 @@
from django.db import models
from django.core.exceptions import ValidationError
def validate_image_size(value):
filesize = value.size
if filesize > 1 * 1024 * 1024: # 1MB
raise ValidationError("Maximum file size is 1MB")
class CloudProvider(models.Model):
name = models.CharField(max_length=100)
description = models.TextField(blank=True)
logo = models.ImageField(
upload_to="cloud_provider_logos/",
validators=[validate_image_size],
null=True,
blank=True,
)
def __str__(self):
return self.name
@ -37,6 +50,12 @@ class Service(models.Model):
countries = models.ManyToManyField(Country)
price = models.DecimalField(max_digits=10, decimal_places=2)
features = models.TextField()
logo = models.ImageField(
upload_to="service_logos/",
validators=[validate_image_size],
null=True,
blank=True,
)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)