add Topik object, wrapper around Page
[django-panik-combo.git] / panikombo / models.py
index fd71709..4f9baeb 100644 (file)
@@ -1,4 +1,5 @@
 from datetime import date
+import os
 
 from django import template
 from django.db import models
@@ -102,6 +103,10 @@ class EpisodeAutoSelectionCell(CellBase):
         from .forms import EpisodeAutoSelectionCellForm
         return EpisodeAutoSelectionCellForm
 
+    def get_additional_label(self):
+        if self.title:
+            return self.title
+        return ''
 
 @register_cell_class
 class NewsItemAutoSelectionCell(CellBase):
@@ -128,3 +133,22 @@ class NewsItemAutoSelectionCell(CellBase):
     def get_default_form_class(self):
         from .forms import NewsItemAutoSelectionCellForm
         return NewsItemAutoSelectionCellForm
+
+    def get_additional_label(self):
+        if self.title:
+            return self.title
+        return ''
+
+
+def get_topik_image_path(instance, filename):
+    return os.path.join('images', 'topik', instance.page.slug,
+            os.path.basename(filename))
+
+class Topik(models.Model):
+    page = models.ForeignKey('data.Page')
+    image = models.ImageField(_('Image'),
+            upload_to=get_topik_image_path, max_length=250, null=True, blank=True)
+
+    # denormalized from Focus
+    got_focus = models.DateTimeField(default=None, null=True, blank=True)
+    has_focus = models.BooleanField(default=False)