Skip to content
Snippets Groups Projects
Commit 55e9b247 authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

Use abstract ModelWithImageFields for Host model

this renames the fields
- `ppoi` -> `image_ppoi`
- `width` -> `image_width`
- `height` -> `image_height`
and adds the fields `image_credits` and `image_alt_text`.
parent 068cf20f
No related branches found
No related tags found
No related merge requests found
......@@ -175,22 +175,11 @@ class Language(models.Model):
return self.name
class Host(models.Model):
class Host(ModelWithImageFields):
name = models.CharField(max_length=128)
is_active = models.BooleanField(default=True)
email = models.EmailField(blank=True)
biography = models.TextField(blank=True, null=True)
ppoi = PPOIField()
height = models.PositiveIntegerField(blank=True, null=True, editable=False)
width = models.PositiveIntegerField(blank=True, null=True, editable=False)
image = VersatileImageField(
blank=True,
null=True,
upload_to="host_images",
width_field="width",
height_field="height",
ppoi_field="ppoi",
)
class Meta:
ordering = ("name",)
......@@ -198,14 +187,6 @@ class Host(models.Model):
def __str__(self):
return self.name
def save(self, *args, **kwargs):
super(Host, self).save(*args, **kwargs)
# Generate thumbnails
if self.image.name and THUMBNAIL_SIZES:
for size in THUMBNAIL_SIZES:
self.image.thumbnail = self.image.crop[size].name
class Link(models.Model):
description = models.CharField(max_length=16)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment