X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/5dd35dc51c94ec63a25ad17dca4259e7e80e2bc0..c6fc086238de9fefb56169edc148bbcd3ff866fa:/apps/explorer/middleware.py?ds=sidebyside 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()