Add display names to info items for readability

This commit is contained in:
Jan Tuomi
2017-02-22 22:41:44 +02:00
parent b081102f43
commit 72231f1912
6 changed files with 136 additions and 80 deletions
+9 -1
View File
@@ -4,14 +4,16 @@ from django.utils import timezone
from datetime import datetime
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.utils.translation import ugettext as _
class InfoItem(models.Model):
class __meta__:
abstract = True
name = models.CharField(max_length=255)
expire_date = models.DateTimeField(blank=True, null=True) # None means never expiring item
display_name = "Default item"
def get_template_url(self):
raise NotImplementedError("inheriting classes must implement get_template_url")
@@ -69,6 +71,7 @@ class InfoItem(models.Model):
class ABBInfoItem(InfoItem):
display_name = _("ABB jobs")
def get_template_url(self):
return "/static/html/abb.html"
@@ -77,6 +80,7 @@ class ABBInfoItem(InfoItem):
return "/static/html/abb_create.html"
class CoffeeInfoItem(InfoItem):
display_name = _("Coffee display")
def get_template_url(self):
return "/static/html/coffee.html"
@@ -85,6 +89,7 @@ class CoffeeInfoItem(InfoItem):
return "/static/html/coffee_create.html"
class SossoInfoItem(InfoItem):
display_name = _("Sössö articles")
def get_template_url(self):
return "/static/html/sosso.html"
@@ -94,6 +99,7 @@ class SossoInfoItem(InfoItem):
class ImageInfoItem(InfoItem):
display_name = _("Image upload")
img = models.ImageField(upload_to="infoimages/")
def get_template_url(self):
@@ -111,6 +117,7 @@ class ImageInfoItem(InfoItem):
class HslInfoItem(InfoItem):
display_name = _("HSL timetables")
def get_template_url(self):
return "/static/html/hsl.html"
@@ -120,6 +127,7 @@ class HslInfoItem(InfoItem):
class ExternalImageInfoItem(InfoItem):
display_name = _("External image")
url = models.TextField()
def get_template_url(self):