aboutsummaryrefslogtreecommitdiffstats
path: root/pyblackbird_cc/resources/models.py
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-05-26 20:47:03 +0100
committerMatthew Lemon <y@yulqen.org>2024-05-26 20:47:03 +0100
commitd421e56e0924487861e6cf5300f462c9e66fd376 (patch)
tree5340955b351772dfc9ec38c7a80035b5781cc93a /pyblackbird_cc/resources/models.py
parent610177be35ec791edae9577f104d0132f2a28364 (diff)
Correctly handles the unique constraint on feature_slot
Diffstat (limited to 'pyblackbird_cc/resources/models.py')
-rw-r--r--pyblackbird_cc/resources/models.py22
1 files changed, 4 insertions, 18 deletions
diff --git a/pyblackbird_cc/resources/models.py b/pyblackbird_cc/resources/models.py
index 0d1bbe3..33fd678 100644
--- a/pyblackbird_cc/resources/models.py
+++ b/pyblackbird_cc/resources/models.py
@@ -60,7 +60,8 @@ class Resource(models.Model):
max_length=1000,
blank=True,
default="",
- help_text="If you enter text here, it will be used in the 'card' description box on the home page. Max 1000 characters.",
+ help_text=("If you enter text here, it will be used in the 'card' "
+ "description box on the home page. Max 1000 characters."),
)
age_range = models.CharField(
max_length=20,
@@ -80,7 +81,7 @@ class Resource(models.Model):
],
)
feature_slot = models.IntegerField(
- choices=((0, 0), (1, 1), (2, 2), (3, 3)), unique=True, null=True, blank=True, default=0,
+ choices=((1, 1), (2, 2), (3, 3)), unique=True, null=True, blank=True, default=0,
)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
@@ -94,8 +95,7 @@ class Resource(models.Model):
def get_pdf_snapshot_file_names(self):
rs = self.pdf_resources.all()
sh = [sh for sh in rs.values_list("pdf_page_snapshots__file_name", flat=True)]
- out = [s for s in sh if s]
- return out
+ return [s for s in sh if s]
class ResourceType(models.Model):
@@ -151,17 +151,3 @@ class PDFPageSnapshot(models.Model):
def __str__(self):
return self.name
-
-
-# class FeatureResource(models.Model):
-# resource = models.ForeignKey(
-# "Resource",
-# on_delete=models.CASCADE,
-# null=False,
-# related_name="feature_resources",
-# )
-# slot = models.IntegerField(null=False, choices=[(1, 1), (2, 2), (3, 3)])
-# description = models.CharField(max_length=255, null=False)
-#
-# def __str__(self):
-# return f"{self.resource.name} as a feature in slot {self.slot}"