allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kentontay...@apache.org
Subject allura git commit: [#8217] don't forget entered content if an error messages appears (regardless of response being a redirect or not)
Date Tue, 10 Jul 2018 15:52:59 GMT
Repository: allura
Updated Branches:
  refs/heads/master 0d602084c -> 9276f18a6


[#8217] don't forget entered content if an error messages appears (regardless of response
being a redirect or not)


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/9276f18a
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/9276f18a
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/9276f18a

Branch: refs/heads/master
Commit: 9276f18a643c8c96e936a2f531b25ecd8ddfec8c
Parents: 0d60208
Author: Dave Brondsema <dave@brondsema.net>
Authored: Mon Jul 9 16:29:15 2018 -0400
Committer: Kenton Taylor <ktaylor@slashdotmedia.com>
Committed: Tue Jul 10 15:52:37 2018 +0000

----------------------------------------------------------------------
 Allura/allura/lib/decorators.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/9276f18a/Allura/allura/lib/decorators.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/decorators.py b/Allura/allura/lib/decorators.py
index 4e1135c..5f37daf 100644
--- a/Allura/allura/lib/decorators.py
+++ b/Allura/allura/lib/decorators.py
@@ -19,6 +19,7 @@ import inspect
 import sys
 import json
 import logging
+from Cookie import Cookie
 from collections import defaultdict
 from urllib import unquote
 
@@ -262,11 +263,15 @@ def memorable_forget():
         Checks here will need to be expanded for controller actions that behave differently
         than others upon successful processing of their particular request
         """
-        # if there is a flash message with type "ok", then we can forget.
+        # if there is a flash message with status "ok", then we can forget.  If it is "error"
we cannot.
         if response.headers:
-            set_cookie = response.headers.get('Set-Cookie', '')
-            if 'status%22%3A%20%22ok' in set_cookie:
-                return True
+            cookies = Cookie(response.headers.get('Set-Cookie', ''))
+            if cookies and 'webflash' in cookies:
+                webflash_value = json.loads(unquote(cookies['webflash'].value))
+                if webflash_value['status'] == 'ok':
+                    return True
+                elif webflash_value['status'] == 'error':
+                    return False
 
         # if the controller raised a 302, we can assume the value will be remembered by the
app
         # if needed, and forget.


Mime
View raw message