From 71fdb6f8aaadc9ad4aaf5ec0cc464135a7926f42 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 10 Jun 2012 11:05:48 +0200 Subject: [PATCH] trigger done with better info if upload fails, dont fail if screen/window are not defined in init --- pandora/settings.py | 1 + pandora/user/models.py | 4 ++-- static/js/pandora/upload.js | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pandora/settings.py b/pandora/settings.py index dfa35d19..c81b3135 100644 --- a/pandora/settings.py +++ b/pandora/settings.py @@ -77,6 +77,7 @@ MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', 'ox.django.middleware.ExceptionMiddleware', 'ox.django.middleware.ChromeFrameMiddleware', ) diff --git a/pandora/user/models.py b/pandora/user/models.py index 0b64f3c5..4a486d79 100644 --- a/pandora/user/models.py +++ b/pandora/user/models.py @@ -107,10 +107,10 @@ class SessionData(models.Model): data.useragent = request.META['HTTP_USER_AGENT'] data.info = json.loads(request.POST.get('data', '{}')) screen = data.info.get('screen', {}) - if 'height' in screen and 'width' in screen: + if screen and 'height' in screen and 'width' in screen: data.screensize = '%sx%s' % (screen['width'], screen['height']) window = data.info.get('window', {}) - if 'outerHeight' in window and 'outerWidth' in window: + if window 'outerHeight' in window and 'outerWidth' in window: data.windowsize = '%sx%s' % (window['outerWidth'], window['outerHeight']) if not data.timesseen: data.timesseen = 0 diff --git a/static/js/pandora/upload.js b/static/js/pandora/upload.js index 4c4d532e..62598479 100644 --- a/static/js/pandora/upload.js +++ b/static/js/pandora/upload.js @@ -61,12 +61,12 @@ pandora.ui.upload = function(oshash, file) { that.status = 'uplaod failed'; that.progress = -1; that.responseText = evt.target.responseText; - that.triggerEvent('done', tat); + done(); }, false); self.req.addEventListener('abort', function (evt) { that.status = 'aborted'; that.progress = -1; - that.triggerEvent('done', tat); + done(); }, false); var formData = new FormData(); Ox.forEach(uploadData, function(value, key) {