From 10bdf75cf069ee23bf045ac9212bb89be9b0c35f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Bedna=C5=99=C3=ADk?= <jan.bednarik@gmail.com>
Date: Wed, 25 Nov 2020 23:07:19 +0100
Subject: [PATCH] uniweb: Move content into shareable mixin

---
 uniweb/models.py | 38 ++++++++++----------------------------
 1 file changed, 10 insertions(+), 28 deletions(-)

diff --git a/uniweb/models.py b/uniweb/models.py
index 867bdce5..ae201d1d 100644
--- a/uniweb/models.py
+++ b/uniweb/models.py
@@ -72,9 +72,7 @@ class SubpageMixin:
         return self.search_image or self.root_page.get_meta_image()
 
 
-class UniwebHomePage(MetadataPageMixin, Page):
-    ### FIELDS
-
+class UniwebContentMixin(models.Model):
     content = StreamField(
         [
             ("title", blocks.CharBlock(label="nadpis", icon="title")),
@@ -98,6 +96,14 @@ class UniwebHomePage(MetadataPageMixin, Page):
         verbose_name="obsah stránky",
         blank=True,
     )
+
+    class Meta:
+        abstract = True
+
+
+class UniwebHomePage(Page, UniwebContentMixin, MetadataPageMixin):
+    ### FIELDS
+
     # settings
     matomo_id = models.IntegerField(
         "Matomo ID pro sledování návštěvnosti", blank=True, null=True
@@ -147,33 +153,9 @@ class UniwebHomePage(MetadataPageMixin, Page):
         return self
 
 
-class UniwebFlexiblePage(Page, SubpageMixin, MetadataPageMixin):
+class UniwebFlexiblePage(Page, UniwebContentMixin, SubpageMixin, MetadataPageMixin):
     ### FIELDS
 
-    content = StreamField(
-        [
-            ("title", blocks.CharBlock(label="nadpis", icon="title")),
-            ("text", blocks.RichTextBlock(label="text", features=RICH_TEXT_FEATURES)),
-            ("text_columns", ColumnsTextBlock()),
-            (
-                "gallery",
-                blocks.ListBlock(
-                    ImageChooserBlock(label="obrázek"), label="galerie", icon="image"
-                ),
-            ),
-            (
-                "table",
-                TableBlock(
-                    label="tabulka",
-                    template="uniweb/snippet_table.html",
-                ),
-            ),
-            ("jupyter", DocumentChooserBlock(label="Jupyter notebook")),
-        ],
-        verbose_name="obsah stránky",
-        blank=True,
-    )
-
     ### PANELS
 
     promote_panels = [
-- 
GitLab