if DECORATED_CREATORS take into account the "fake" username if has_own_perm()
authorgibus
Mon, 06 Jun 2011 10:08:10 +0200
changeset 355 c926868cf7e6
parent 354 4c7feb67d4a0
child 356 52569110fb34
if DECORATED_CREATORS take into account the "fake" username if has_own_perm()
src/cm/converters/pandoc_converters.py
src/cm/security.py
--- a/src/cm/converters/pandoc_converters.py	Tue May 31 18:26:38 2011 +0200
+++ b/src/cm/converters/pandoc_converters.py	Mon Jun 06 10:08:10 2011 +0200
@@ -15,7 +15,7 @@
 import re
 
 PANDOC_BIN = "pandoc"
-PANDOC_OPTIONS = " --sanitize-html --email-obfuscation=none  "
+PANDOC_OPTIONS = " --sanitize-html --email-obfuscation=none "
 PANDOC_OPTIONS_RAW = " -R --email-obfuscation=none "
 
 MARKDOWN2PDF_BIN = "markdown2pdf"
@@ -202,7 +202,7 @@
       stdoutdata = re.sub(r"(\/?)>", r"\n\1>", stdoutdata)
       # do not split closing tag with following opening tag
       stdoutdata = re.sub(r">\n<", r"><", stdoutdata)
-      # nest headers tags 
+      # nest headers tags
       #stdoutdata = re.sub(r'<h(\d) id="([^"]+)"\n>', r'<div id="\2"><h\1>', stdoutdata)
       #stdoutdata = re.sub(r'<\/h(\d)\n>', r'</h\1></div>', stdoutdata)
       return stdoutdata
--- a/src/cm/security.py	Tue May 31 18:26:38 2011 +0200
+++ b/src/cm/security.py	Mon Jun 06 10:08:10 2011 +0200
@@ -98,7 +98,15 @@
        not has_perm(request, 'can_manage_text', text=text):
         return False
     
-    return (comment.user == request.user and has_perm(request, perm_name, text=text)) 
+    actual_own_user = False
+    from cm.cm_settings import DECORATED_CREATORS
+    if comment.user == request.user:
+      if DECORATED_CREATORS:
+        if request.GET.get('name', None) == comment.get_name():
+          actual_own_user = True
+      else:
+        actual_own_user = True
+    return (actual_own_user and has_perm(request, perm_name, text=text)) 
         
 def is_authenticated(request):
     # We customize this to be able to monkey patch it if needed