From 5e6b4153e66520cfbc0810c394320a0f8236d352 Mon Sep 17 00:00:00 2001 From: Lavikainen Joel Date: Sun, 19 Nov 2017 17:40:04 +0200 Subject: [PATCH] Add data endpoint and create infoscreen view for coffee stats --- infoscreen/admin.py | 2 ++ .../migrations/0007_coffeestatsinfoitem.py | 23 +++++++++++++++++++ infoscreen/models.py | 15 ++++++++++++ infoscreen/static/html/coffee_stats.html | 9 ++++++++ .../static/html/coffee_stats_create.html | 11 +++++++++ infoscreen/static/js/infoadmin_controllers.js | 1 + .../static/js/infoscreen_controllers.js | 16 ++++++++++++- infoscreen/urls.py | 4 ++++ infoscreen/views/admin_views.py | 2 ++ infoscreen/views/public_views.py | 15 ++++++++++++ package.json | 5 +++- 11 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 infoscreen/migrations/0007_coffeestatsinfoitem.py create mode 100644 infoscreen/static/html/coffee_stats.html create mode 100644 infoscreen/static/html/coffee_stats_create.html diff --git a/infoscreen/admin.py b/infoscreen/admin.py index d7b314c..a03205c 100644 --- a/infoscreen/admin.py +++ b/infoscreen/admin.py @@ -5,6 +5,7 @@ from infoscreen.models import Rotation, InfoItem, InfoInstance from infoscreen.models import ImageInfoItem, ExternalImageInfoItem, ABBInfoItem from infoscreen.models import ExternalWebsiteInfoItem from infoscreen.models import VideoInfoItem +from infoscreen.models import CoffeeStatsInfoItem # Register your models here. admin.site.register(Rotation) @@ -15,3 +16,4 @@ admin.site.register(ABBInfoItem) admin.site.register(InfoInstance) admin.site.register(ExternalWebsiteInfoItem) admin.site.register(VideoInfoItem) +admin.site.register(CoffeeStatsInfoItem) diff --git a/infoscreen/migrations/0007_coffeestatsinfoitem.py b/infoscreen/migrations/0007_coffeestatsinfoitem.py new file mode 100644 index 0000000..c7fb36d --- /dev/null +++ b/infoscreen/migrations/0007_coffeestatsinfoitem.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11 on 2017-11-19 14:41 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('infoscreen', '0006_delete_hsldatamodel'), + ] + + operations = [ + migrations.CreateModel( + name='CoffeeStatsInfoItem', + fields=[ + ('infoitem_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='infoscreen.InfoItem')), + ], + bases=('infoscreen.infoitem',), + ), + ] diff --git a/infoscreen/models.py b/infoscreen/models.py index ff1613d..6188aa2 100644 --- a/infoscreen/models.py +++ b/infoscreen/models.py @@ -269,6 +269,21 @@ class HslInfoItem(InfoItem): return "/static/html/hsl_create.html" +class CoffeeStatsInfoItem(InfoItem): + """Class for Coffee statistics Infoscreen item.""" + + display_name = _("Coffee statistics") + + def get_template_url(self): + """Return HSL infoitem template url.""" + return "/static/html/coffee_stats.html" + + @staticmethod + def get_create_template_url(): + """Call create HSL infoitem template url command.""" + return "/static/html/coffee_stats_create.html" + + class ExternalImageInfoItem(InfoItem): """Class for External Image Infoscreen item.""" diff --git a/infoscreen/static/html/coffee_stats.html b/infoscreen/static/html/coffee_stats.html new file mode 100644 index 0000000..cb95201 --- /dev/null +++ b/infoscreen/static/html/coffee_stats.html @@ -0,0 +1,9 @@ + + + + + + +
+
+
diff --git a/infoscreen/static/html/coffee_stats_create.html b/infoscreen/static/html/coffee_stats_create.html new file mode 100644 index 0000000..3a16e54 --- /dev/null +++ b/infoscreen/static/html/coffee_stats_create.html @@ -0,0 +1,11 @@ +
+
+ Create new item to show coffee statistics. Name is used only as identifier +
+
+ + +
+ +
+