From 21963b4654737d403070dabfb2cf5b0521c522f4 Mon Sep 17 00:00:00 2001
From: Christian Franke
Date: Mon, 23 Jan 2012 23:24:43 +0100
Subject: Improve tasks for images
---
sublab_project/matekarte/tasks.py | 10 +++++-----
sublab_project/sublab_monitor/tasks.py | 33 +++++++++++++++++++++++++++++----
sublab_project/templates/base.html | 5 +++--
3 files changed, 37 insertions(+), 11 deletions(-)
(limited to 'sublab_project')
diff --git a/sublab_project/matekarte/tasks.py b/sublab_project/matekarte/tasks.py
index bc1018b..5ba8fbd 100644
--- a/sublab_project/matekarte/tasks.py
+++ b/sublab_project/matekarte/tasks.py
@@ -42,8 +42,8 @@ class OSMFetcher(object):
os.rename(fn_new, fn)
-#class MateFetcher(OSMFetcher, PeriodicTask):
-# run_every = crontab(minute=0, hour=3)
-# bbox = (55.26, 46.52, 15.26, 5.22)
-# store_name = 'mate.xml'
-# tag = 'drink:club-mate'
+class MateFetcher(OSMFetcher, PeriodicTask):
+ run_every = crontab(minute=0, hour=3)
+ bbox = (55.26, 46.52, 15.26, 5.22)
+ store_name = 'mate.xml'
+ tag = 'drink:club-mate'
diff --git a/sublab_project/sublab_monitor/tasks.py b/sublab_project/sublab_monitor/tasks.py
index 681ce5f..982b0a3 100644
--- a/sublab_project/sublab_monitor/tasks.py
+++ b/sublab_project/sublab_monitor/tasks.py
@@ -4,10 +4,12 @@ from datetime import timedelta
from celery.task import PeriodicTask
import subprocess
import urllib2
+import urlparse
from PIL import Image, ImageOps
from StringIO import StringIO
from django.conf import settings
import os
+import re
import sublab_monitor
@@ -73,6 +75,13 @@ class ImageFetcher(object):
"""
raise NotImplementedError
+ def replace_file(self, filename, save):
+ fn = os.path.join(settings.MEDIA_ROOT, filename)
+ fn_new = os.path.join(settings.MEDIA_ROOT, 'new-%s' % filename)
+
+ save(fn_new)
+ os.rename(fn_new ,fn)
+
def run(self, **kwargs):
upstream = urllib2.urlopen(self.fetch_url).read()
image = Image.open(StringIO(upstream))
@@ -82,12 +91,16 @@ class ImageFetcher(object):
except NotImplementedError:
pass
- fn = os.path.join(settings.MEDIA_ROOT, self.store_name)
- fn_new = os.path.join(settings.MEDIA_ROOT, 'new-%s' % self.store_name)
+ self.replace_file(self.store_name, image.save)
+
+ if image.mode.upper() == 'RGBA':
+ image = Image.composite(image, Image.new("RGB", image.size, (255,255,255)), image)
+ image.convert("RGB")
- image.save(fn_new)
- os.rename(fn_new, fn)
+ image.thumbnail((180, 180), Image.ANTIALIAS)
+ self.replace_file('thumb_' + self.store_name, image.save)
+ return 'Done.'
class EnhancingImageFetcher(ImageFetcher):
def process_image(self, image):
@@ -107,3 +120,15 @@ class TempGraphFetcher(ImageFetcher, PeriodicTask):
run_every = timedelta(minutes=5)
fetch_url = 'http://taifun.local.sublab.org/temperature/temp-2hour.png'
store_name = 'tempgraph.png'
+
+class ReeknerSprookTempFetcher(ImageFetcher, PeriodicTask):
+ run_every = timedelta(minutes=5)
+ store_name = 'reeknersprook.png'
+
+ @property
+ def fetch_url(self):
+ url = 'http://reeknersprook.de/sublog/graph-small'
+ buf = urllib2.urlopen(url).read()
+ rel = re.search(r'src="(.*?)"', buf).group(1)
+
+ return urlparse.urljoin(url, rel)
diff --git a/sublab_project/templates/base.html b/sublab_project/templates/base.html
index 9a4bbca..8e609ab 100644
--- a/sublab_project/templates/base.html
+++ b/sublab_project/templates/base.html
@@ -107,10 +107,11 @@
{% flatblock "motd" %}
-
+
-
+
+
Mitglied werden
--
cgit v1.2.1
From f36fbca5ea08a47db35b087704c29b0039e0cf2f Mon Sep 17 00:00:00 2001
From: Christian Franke
Date: Tue, 24 Jan 2012 00:12:21 +0100
Subject: Fixup event descriptions
---
sublab_project/calendarium/tasks.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'sublab_project')
diff --git a/sublab_project/calendarium/tasks.py b/sublab_project/calendarium/tasks.py
index ee35e45..a2639dc 100644
--- a/sublab_project/calendarium/tasks.py
+++ b/sublab_project/calendarium/tasks.py
@@ -46,7 +46,7 @@ class CalendariumImport(PeriodicTask):
event_info = {}
for fieldinfo in event_fields:
try:
- event_info[fieldinfo[0]] = str(event[fieldinfo[1]])
+ event_info[fieldinfo[0]] = event[fieldinfo[1]].format()
except KeyError:
event_info[fieldinfo[0]] = fieldinfo[2]
start = icalendar.vDatetime.from_ical(event['dtstart'].ical())
--
cgit v1.2.1
From ef367be161e91cb111ac17e046ef4f1c8706b161 Mon Sep 17 00:00:00 2001
From: Christian Franke
Date: Tue, 24 Jan 2012 00:16:50 +0100
Subject: Calendarium: don't show empty "other events" list
---
sublab_project/calendarium/templates/calendarium/list_events.html | 2 ++
1 file changed, 2 insertions(+)
(limited to 'sublab_project')
diff --git a/sublab_project/calendarium/templates/calendarium/list_events.html b/sublab_project/calendarium/templates/calendarium/list_events.html
index 6e0b4d4..b70b830 100644
--- a/sublab_project/calendarium/templates/calendarium/list_events.html
+++ b/sublab_project/calendarium/templates/calendarium/list_events.html
@@ -11,10 +11,12 @@
{{ event.start|date:"l, j. F Y H:i" }} bis {{ event.end|date:"H:i" }} Uhr - {{ event.name }}
{{ event.description }}
{% endfor %}
+ {% if events_source_admin %}
Was sonst noch los ist
{% for event in events_source_admin %}
- {{ event.start|date:"l, j. F Y H:i" }} bis {{ event.end|date:"l, j. F Y H:i" }} Uhr - {{ event.name }}
{{ event.description }}
{% endfor %}
+ {% endif %}
{% endblock content %}
--
cgit v1.2.1
From 639f6bee335e0f68ed6ce08bbb9934b182cc46fe Mon Sep 17 00:00:00 2001
From: Christian Franke
Date: Tue, 24 Jan 2012 00:29:44 +0100
Subject: Fixup event descriptions (again :S )
---
sublab_project/calendarium/tasks.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'sublab_project')
diff --git a/sublab_project/calendarium/tasks.py b/sublab_project/calendarium/tasks.py
index a2639dc..d0ab16d 100644
--- a/sublab_project/calendarium/tasks.py
+++ b/sublab_project/calendarium/tasks.py
@@ -46,7 +46,8 @@ class CalendariumImport(PeriodicTask):
event_info = {}
for fieldinfo in event_fields:
try:
- event_info[fieldinfo[0]] = event[fieldinfo[1]].format()
+ event_info[fieldinfo[0]] = event[fieldinfo[1]].format().encode("utf-8")
+ event_info[fieldinfo[0]] = event_info[fieldinfo[0]].decode("string-escape")
except KeyError:
event_info[fieldinfo[0]] = fieldinfo[2]
start = icalendar.vDatetime.from_ical(event['dtstart'].ical())
--
cgit v1.2.1
From 48b4ce88c6940eb76a20c2df7acbc0b1200b3984 Mon Sep 17 00:00:00 2001
From: Christian Franke
Date: Tue, 24 Jan 2012 01:31:40 +0100
Subject: Nicen up eventlist/calendarium
---
.../templates/calendarium/list_events.html | 26 +-
sublab_project/static/css/sublab.css | 13 +
sublab_project/static/js/jquery-1.7.1.js | 9266 ++++++++++++++++++++
sublab_project/templates/base.html | 3 +
4 files changed, 9302 insertions(+), 6 deletions(-)
create mode 100644 sublab_project/static/js/jquery-1.7.1.js
(limited to 'sublab_project')
diff --git a/sublab_project/calendarium/templates/calendarium/list_events.html b/sublab_project/calendarium/templates/calendarium/list_events.html
index b70b830..4ccecfc 100644
--- a/sublab_project/calendarium/templates/calendarium/list_events.html
+++ b/sublab_project/calendarium/templates/calendarium/list_events.html
@@ -1,22 +1,36 @@
{% extends 'base.html' %}
{% block title %}Termine{% endblock %}
+{% block header %}
+
+
+{% endblock %}
{%block content %}
Termine
Hier findest du Veranstaltungen, die im sublab und dessen Umgebung stattfinden.
Veranstaltungen im sublab
-