diff --git a/infoscreen/admin.py b/infoscreen/admin.py
index 19d3413..ac777b3 100644
--- a/infoscreen/admin.py
+++ b/infoscreen/admin.py
@@ -1,6 +1,6 @@
from django.contrib import admin
from infoscreen.models import Rotation, InfoItem, InfoInstance, ImageInfoItem, ExternalImageInfoItem, ABBInfoItem
-from infoscreen.models import CoffeeInfoItem
+from infoscreen.models import ExternalWebsiteInfoItem
# Register your models here.
admin.site.register(Rotation)
@@ -9,4 +9,4 @@ admin.site.register(ImageInfoItem)
admin.site.register(ExternalImageInfoItem)
admin.site.register(ABBInfoItem)
admin.site.register(InfoInstance)
-admin.site.register(CoffeeInfoItem)
\ No newline at end of file
+admin.site.register(ExternalWebsiteInfoItem)
\ No newline at end of file
diff --git a/infoscreen/models.py b/infoscreen/models.py
index 7304b56..8927c6d 100644
--- a/infoscreen/models.py
+++ b/infoscreen/models.py
@@ -80,14 +80,52 @@ class ABBInfoItem(InfoItem):
def get_create_template_url():
return "/static/html/abb_create.html"
-class CoffeeInfoItem(InfoItem):
- display_name = _("Coffee display")
+
+class ExternalWebsiteInfoItem(InfoItem):
+ display_name = _("External website")
+ url = models.TextField()
def get_template_url(self):
- return "/static/html/coffee.html"
+ return "/static/html/external_website.html?url={}".format(self.name)
@staticmethod
def get_create_template_url():
- return "/static/html/coffee_create.html"
+ return "/static/html/external_website_create.html"
+
+ def get_dict(self):
+ d = super().get_dict()
+ d["options"] = {'url': self.url}
+ return d
+
+ @classmethod
+ def create_from_dict(cls, d):
+ item = cls()
+ item.update_from_dict(d)
+ return item
+
+ def get_list(self):
+ return {
+ 'id':self.id,
+ 'name':self.name,
+ 'url': self.url,
+ }
+
+ def update_from_dict(self, d):
+ try:
+ expire_date = d.pop('expire_date', None)
+ self.expire_date = datetime.strptime(expire_date, "%Y-%m-%d %H:%M:%S")
+ except:
+ pass
+
+ dmap = {
+ 'name': 'name',
+ 'url': 'url',
+ }
+ for k, v in d.items():
+ try:
+ self.__setattr__(dmap[k], v)
+ except KeyError:
+ pass
+ self.save()
class SossoInfoItem(InfoItem):
display_name = _("Sössö articles")
diff --git a/infoscreen/static/css/coffee.css b/infoscreen/static/css/external_website.css
similarity index 100%
rename from infoscreen/static/css/coffee.css
rename to infoscreen/static/css/external_website.css
diff --git a/infoscreen/static/html/coffee.html b/infoscreen/static/html/coffee.html
deleted file mode 100644
index 8119306..0000000
--- a/infoscreen/static/html/coffee.html
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
\ No newline at end of file
diff --git a/infoscreen/static/html/coffee_create.html b/infoscreen/static/html/coffee_create.html
deleted file mode 100644
index 02fb704..0000000
--- a/infoscreen/static/html/coffee_create.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
- Create new item to show coffee website. Name is used only as identifier
-
-
-
-
-
-
-
diff --git a/infoscreen/static/html/external_website.html b/infoscreen/static/html/external_website.html
new file mode 100644
index 0000000..d51f353
--- /dev/null
+++ b/infoscreen/static/html/external_website.html
@@ -0,0 +1,4 @@
+
+
diff --git a/infoscreen/static/html/external_website_create.html b/infoscreen/static/html/external_website_create.html
new file mode 100644
index 0000000..6f58c8f
--- /dev/null
+++ b/infoscreen/static/html/external_website_create.html
@@ -0,0 +1,14 @@
+
diff --git a/infoscreen/static/js/infoadmin_controllers.js b/infoscreen/static/js/infoadmin_controllers.js
index 670b1d7..9a49e0d 100644
--- a/infoscreen/static/js/infoadmin_controllers.js
+++ b/infoscreen/static/js/infoadmin_controllers.js
@@ -1,4 +1,4 @@
-var app = angular.module('infoAdmin',['ngFileUpload']);
+ var app = angular.module('infoAdmin',['ngFileUpload']);
app.config(['$httpProvider', function ($httpProvider) {
$httpProvider.defaults.xsrfCookieName = 'csrftoken';
@@ -147,10 +147,10 @@ app.controller('infoadmin_hslitem_create', function($scope, $http,ItemList){
$http.post("/infoscreen/create_hslitem", $scope.item).then(ItemList.loadItems)
}
});
-app.controller('infoadmin_coffeeitem_create', function($scope, $http,ItemList){
+app.controller('infoadmin_websiteitem_create', function($scope, $http,ItemList){
$scope.item = {}
$scope.send = function(){
- $http.post("/infoscreen/create_coffeeitem", $scope.item).then(ItemList.loadItems)
+ $http.post("/infoscreen/create_websiteitem", $scope.item).then(ItemList.loadItems)
}
});
diff --git a/infoscreen/static/js/infoscreen_controllers.js b/infoscreen/static/js/infoscreen_controllers.js
index 48427e2..a499fda 100644
--- a/infoscreen/static/js/infoscreen_controllers.js
+++ b/infoscreen/static/js/infoscreen_controllers.js
@@ -37,6 +37,14 @@ app.controller('infoscreen_main', function($scope,$http,$timeout){
$timeout($scope.next, temp.duration * 1000);
}
});
+
+//Doing this the ugly way because Angular likes to be the special priviledged child
+app.filter('trusted_url', ['$sce', function ($sce) {
+ return function(url) {
+ return $sce.trustAsResourceUrl(url);
+ };
+}]);
+
app.controller('ABBController', function($scope, $http){
$scope.jobs = [];
var min_date = moment().subtract(30,'days').format("YYYY-MM-DD%20HH:mm:ss");
diff --git a/infoscreen/views.py b/infoscreen/views.py
index 7ec3ee0..6f0ab36 100644
--- a/infoscreen/views.py
+++ b/infoscreen/views.py
@@ -7,7 +7,7 @@ from django.contrib.auth.decorators import permission_required
from infoscreen.models import Rotation, InfoItem, InfoInstance
from infoscreen.models import ABBInfoItem, ExternalImageInfoItem, ImageInfoItem, SossoInfoItem, HslInfoItem
-from infoscreen.models import CoffeeInfoItem
+from infoscreen.models import ExternalWebsiteInfoItem
from infoscreen.models import ImageUploadForm
from infoscreen.models import HSLDataModel
from infoscreen.hsl_fetcher import HSLFetcher
@@ -206,10 +206,12 @@ def CurrentHSLView(request, *args, **kwargs):
return HttpResponse(data[len(data) - 1].data, status=200)
+
+
createInstance = create_item_generator(InfoInstance)
deleteInstance = delete_item_generator(InfoInstance)
createABBItem = create_item_generator(ABBInfoItem)
createSossoItem = create_item_generator(SossoInfoItem)
createHslItem = create_item_generator(HslInfoItem)
createExternalImageInfoItem = create_item_generator(ExternalImageInfoItem)
-createCoffeeItem = create_item_generator(CoffeeInfoItem)
+createExternalWebsiteItem = create_item_generator(ExternalWebsiteInfoItem)
diff --git a/sikweb/urls.py b/sikweb/urls.py
index 7672381..b8a544a 100644
--- a/sikweb/urls.py
+++ b/sikweb/urls.py
@@ -62,7 +62,7 @@ from infoscreen.views import create_image_item
from infoscreen.views import createABBItem
from infoscreen.views import createSossoItem
from infoscreen.views import createHslItem
-from infoscreen.views import createCoffeeItem
+from infoscreen.views import createExternalWebsiteItem
from infoscreen.views import create_rotation
from infoscreen.views import delete_rotation
from infoscreen.views import CurrentHSLView
@@ -124,7 +124,7 @@ urlpatterns = [
url(r'^infoscreen/create_abbitem$', createABBItem),
url(r'^infoscreen/create_sossoitem$', createSossoItem),
url(r'^infoscreen/create_hslitem$', createHslItem),
- url(r'^infoscreen/create_coffeeitem$', createCoffeeItem),
+ url(r'^infoscreen/create_websiteitem$', createExternalWebsiteItem),
url(r'^infoscreen/admin$', infoscreen_admin),
url(r'^infoscreen/create_rotation$', create_rotation),
url(r'^infoscreen/delete_rotation/(?P\d+)$', delete_rotation),