Changeset 59
- Timestamp:
- 07/12/05 08:30:47 (3 years ago)
- Files:
-
- addcommentmacro/trunk/AddComment.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
addcommentmacro/trunk/AddComment.py
r41 r59 7 7 from trac.wiki.model import WikiPage 8 8 from trac.util import TracError 9 from trac.web.chrome import add_link 9 10 import re 10 11 … … 17 18 authname = hdf.getValue("trac.authname", "anonymous") 18 19 db = env.get_db_cnx() 19 perm = trac.perm.PermissionCache( db, authname)20 perm = trac.perm.PermissionCache(env, authname) 20 21 pagename = hdf.getValue("wiki.page_name", "WikiStart") 21 22 page = WikiPage(env, pagename, None, db) … … 26 27 cancomment = not readonlypage 27 28 # Is this an "append-only" comment or are we an administrator? 28 if perm.has_permission( trac.perm.WIKI_ADMIN) or appendonly:29 if perm.has_permission('WIKI_ADMIN') or appendonly: 29 30 cancomment = True 30 31 … … 47 48 48 49 out = StringIO() 49 if wikipreview or not perm.has_permission( trac.perm.WIKI_MODIFY):50 if wikipreview or not perm.has_permission('WIKI_MODIFY'): 50 51 disabled = ' disabled="disabled"' 51 52 … … 54 55 if preview: 55 56 out.write("<div class='wikipage' id='preview'>\n") 56 out.write("<h4 id='commentpreview'>Comment by %s on %s</h4>\n<p>\n%s\n</p>\n" % (authname, time.strftime('%c', time.localtime()), wiki_to_html(comment, hdf, env, db)))57 out.write("<h4 id='commentpreview'>Comment by %s on %s</h4>\n<p>\n%s\n</p>\n" % (authname, time.strftime('%c', time.localtime()), wiki_to_html(comment, env, None))) 57 58 if preview: 58 59 out.write("</div>\n") … … 79 80 out.write("<div class='system-message'><strong>ERROR: [[AddComment]] macro call must be the only content on its line. Could not add comment.</strong></div>\n") 80 81 81 out.write("<form action='%s#commentpreview' method=' post'>\n" % env.href.wiki(pagename))82 out.write("<form action='%s#commentpreview' method='get'>\n" % env.href.wiki(pagename)) 82 83 out.write("<fieldset>\n<legend>Add comment</legend>\n") 83 84 out.write("<div class='field'>\n<textarea id='addcomment' name='addcomment' cols='80' rows='5'%s>" % disabled) … … 92 93 out.write("<input type='submit' name='previewaddcomment' value='Preview comment'%s/>\n" % disabled) 93 94 out.write("<input type='submit' name='canceladdcomment' value='Cancel'%s/>\n</div>\n" % disabled) 95 out.write('<script type="text/javascript" src="%sjs/wikitoolbar.js"></script>' % hdf['htdocs_location']) 94 96 out.write("<script type='text/javascript'>\naddWikiFormattingToolbar(document.getElementById('addcomment'));\n</script>\n") 95 97 out.write("</fieldset>\n</form>\n")
