From 8e23a75b67867b7375230c2a7c7b015589f10ae6 Mon Sep 17 00:00:00 2001
From: Ernesto Rico Schmidt <ernesto@helsinki.at>
Date: Wed, 3 Aug 2022 17:35:49 -0400
Subject: [PATCH] Use abstract ModelWithImageFields for Note model

this renames the fields
- `ppoi` -> `image_ppoi`
- `width` -> `image_width`
- `height` -> `image_height`
and adds the fields `image_credits` and `image_alt_text`.
---
 program/models.py | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/program/models.py b/program/models.py
index ea31cd4d..147e076c 100644
--- a/program/models.py
+++ b/program/models.py
@@ -1158,7 +1158,7 @@ class TimeSlot(models.Model):
         return str("".join(s for s in string if s.isdigit()))
 
 
-class Note(models.Model):
+class Note(ModelWithImageFields):
     timeslot = models.OneToOneField(TimeSlot, on_delete=models.CASCADE, unique=True)
     contributors = models.ManyToManyField(Host, related_name="contributions")
     owner = models.ForeignKey(
@@ -1168,17 +1168,6 @@ class Note(models.Model):
     slug = models.SlugField(max_length=32, unique=True)
     summary = models.TextField(blank=True)
     content = models.TextField()
-    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="note_images",
-        width_field="width",
-        height_field="height",
-        ppoi_field="ppoi",
-    )
     cba_id = models.IntegerField(blank=True, null=True)
     tags = models.TextField(blank=True, null=True)
 
@@ -1195,11 +1184,6 @@ class Note(models.Model):
 
         super(Note, 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 NoteLink(Link):
     note = models.ForeignKey(Note, on_delete=models.CASCADE, related_name="links")
-- 
GitLab