diff --git a/core/migrations/0006_contentblock_page.py b/core/migrations/0006_contentblock_page.py new file mode 100644 index 0000000..b1a9020 --- /dev/null +++ b/core/migrations/0006_contentblock_page.py @@ -0,0 +1,18 @@ +# Generated by Django 4.0.6 on 2022-07-13 14:48 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0005_contentblock_image1_contentblock_image2_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='contentblock', + name='page', + field=models.CharField(blank=True, max_length=255, null=True), + ), + ] diff --git a/core/models.py b/core/models.py index 1d4ad20..603b1f8 100644 --- a/core/models.py +++ b/core/models.py @@ -72,6 +72,7 @@ class Session(models.Model): class ContentBlock(models.Model): user = models.ForeignKey(User, on_delete=models.PROTECT) position = models.IntegerField() + page = models.CharField(max_length=255, null=True, blank=True) title = models.CharField(max_length=255, null=True, blank=True) column1 = models.TextField(null=True, blank=True) column2 = models.TextField(null=True, blank=True) @@ -80,15 +81,24 @@ class ContentBlock(models.Model): image2 = models.CharField(max_length=255, null=True, blank=True) image3 = models.CharField(max_length=255, null=True, blank=True) + def __str__(self): + return f"[{self.position}] {self.page} {self.title}" + def save(self, *args, **kwargs): """ Override the save function to blank fields. """ - if self.column1 == "NONE": + if self.column1 == "": self.column1 = None - if self.column2 == "NONE": + if self.column2 == "": self.column2 = None - if self.column3 == "NONE": + if self.column3 == "": self.column3 = None + if self.image1 == "": + self.image1 = None + if self.image2 == "": + self.image2 = None + if self.image3 == "": + self.image3 = None super().save(*args, **kwargs) diff --git a/core/templates/index.html b/core/templates/index.html index f0c1333..edb4add 100644 --- a/core/templates/index.html +++ b/core/templates/index.html @@ -7,52 +7,43 @@ {% if block.title is not None %}