From 98693e66f46b848477a0a79bd6161c31cd956c87 Mon Sep 17 00:00:00 2001 From: zuber Date: Wed, 2 Sep 2009 13:07:10 +0200 Subject: [PATCH] =?utf8?q?FIX:=20U=C5=BCytkownik=20bez=20ustawionego=20coo?= =?utf8?q?kie=20nie=20m=C3=B3g=C5=82=20wej=C5=9B=C4=87=20na=20stron=C4=99?= =?utf8?q?=20(b=C5=82=C4=85d=20w=20EditorSettings=20middleware).?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- apps/explorer/middleware.py | 7 +++++-- apps/explorer/views.py | 1 + project/settings.py | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/explorer/middleware.py b/apps/explorer/middleware.py index 661a7a64..018f1aae 100644 --- a/apps/explorer/middleware.py +++ b/apps/explorer/middleware.py @@ -6,14 +6,18 @@ from django.utils import simplejson from explorer import models +EDITOR_DEFAULT_SETTINGS_JSON = simplejson.dumps(settings.EDITOR_DEFAULT_SETTINGS) + + class EditorSettingsMiddleware(object): def process_request(self, request): if request.user.is_anonymous(): return - cookie_settings = request.COOKIES.get(settings.EDITOR_COOKIE_NAME, '{}') + cookie_settings = request.COOKIES.get(settings.EDITOR_COOKIE_NAME, EDITOR_DEFAULT_SETTINGS_JSON) cookie_settings = simplejson.loads(urllib.unquote(cookie_settings)) last_update = cookie_settings.get('lastUpdate', 0) + cookie_settings['lastUpdate'] = last_update try: editor_settings = models.EditorSettings.objects.get(user=request.user) @@ -24,7 +28,6 @@ class EditorSettingsMiddleware(object): # print editor_settings.get_settings_value()['lastUpdate'], '<>', last_update if editor_settings.get_settings_value()['lastUpdate'] < last_update: - print "\n\nZmiana!\n\n" editor_settings.set_settings_value(cookie_settings) editor_settings.save() diff --git a/apps/explorer/views.py b/apps/explorer/views.py index 79160f8a..6754930a 100644 --- a/apps/explorer/views.py +++ b/apps/explorer/views.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import urllib2 import hg from librarian import html, parser, dcparser, ParseError, ValidationError diff --git a/project/settings.py b/project/settings.py index 3bfc7db0..22d9bdd2 100644 --- a/project/settings.py +++ b/project/settings.py @@ -119,6 +119,12 @@ INSTALLED_APPS = ( # REPOSITORY_PATH = '/Users/zuber/Projekty/platforma/files/books' IMAGE_DIR = 'images' EDITOR_COOKIE_NAME = 'options' +EDITOR_DEFAULT_SETTINGS = { + 'panels': [ + {'name': 'htmleditor', 'ratio': 0.5}, + {'name': 'gallery', 'ratio': 0.5} + ], +} try: from localsettings import * -- 2.20.1