From e1c62e831ea892e6b299c652b87a09c0c696f17a Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 21 Oct 2011 20:36:21 +0200 Subject: [PATCH] RGB only, add resetUI url --- pandora/archive/extract.py | 2 +- pandora/urls.py | 1 + pandora/user/views.py | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pandora/archive/extract.py b/pandora/archive/extract.py index 1cf41cd6..1c357f1a 100644 --- a/pandora/archive/extract.py +++ b/pandora/archive/extract.py @@ -291,7 +291,7 @@ def average_color(prefix, start=0, end=0): timelines = sorted(filter(lambda t: t!= '%s%sp.png'%(prefix,height), glob("%s%sp*.png"%(prefix, height)))) for image in timelines: start_offset = 0 - timeline = Image.open(image) + timeline = Image.open(image).convert('RGB') frames += timeline.size[0] if start and frames < start: continue diff --git a/pandora/urls.py b/pandora/urls.py index 23a2b6f5..bdeb7056 100644 --- a/pandora/urls.py +++ b/pandora/urls.py @@ -27,6 +27,7 @@ urlpatterns = patterns('', (r'^url=(?P.*)$', 'app.views.redirect_url'), (r'^file/(?P.*)$', 'archive.views.lookup_file'), (r'^api/$', include('api.urls')), + (r'^resetUI$', 'user.views.reset_ui'), (r'', include('item.urls')), (r'^list/(?P.*?)/icon(?P\d*).jpg$', 'itemlist.views.icon'), (r'^robots.txt$', serve_static_file, {'location': os.path.join(settings.STATIC_ROOT, 'robots.txt'), 'content_type': 'text/plain'}), diff --git a/pandora/user/views.py b/pandora/user/views.py index 8737a4af..740d57dd 100644 --- a/pandora/user/views.py +++ b/pandora/user/views.py @@ -12,6 +12,7 @@ from django.utils import simplejson as json from django.conf import settings from django.core.mail import send_mail, BadHeaderError from django.db.models import Sum +from django.shortcuts import redirect from ox.django.shortcuts import render_to_json_response, json_response, get_object_or_404_json from ox.django.decorators import admin_required_json, login_required_json @@ -607,6 +608,16 @@ def editPreferences(request): actions.register(editPreferences, cache=False) +def reset_ui(request): + response = json_response() + if request.user.is_authenticated(): + profile = request.user.get_profile() + profile.ui = {} + profile.save() + else: + request.session['ui'] = '{}' + return redirect('/') + def resetUI(request): ''' reset user ui settings to defaults