- Timestamp:
- 10/27/05 18:50:34 (8 years ago)
- File:
-
- 1 edited
-
trac/trunk/wiki-macros/AddComment.py (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trac/trunk/wiki-macros/AddComment.py
r3000 r3038 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 … … 33 34 34 35 disabled = '' 35 print dir(hdf)36 36 37 37 comment = hdf.getValue("args.addcomment", "") … … 47 47 48 48 out = StringIO() 49 if wikipreview or not perm.has_permission(trac.perm.WIKI_MODIFY):49 if wikipreview or not (perm.has_permission('WIKI_MODIFY') or appendonly): 50 50 disabled = ' disabled="disabled"' 51 51 … … 54 54 if preview: 55 55 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)))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, env, None))) 57 57 if preview: 58 58 out.write("</div>\n") … … 68 68 newtext.write(line + "\n") 69 69 if submitted: 70 # XXX Is this the dod igest hack ever? This is needed in70 # XXX Is this the dodgiest hack ever? This is needed in 71 71 # "appendonly" mode when the page is readonly. XXX 72 if appendonly:73 perm.expand_meta_permission('WIKI_ADMIN');72 # if appendonly: 73 # perm.expand_meta_permission('WIKI_ADMIN'); 74 74 # TODO: How do we get remote_addr from a macro? 75 75 page.text = newtext.getvalue() … … 79 79 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 80 81 out.write("<form action='%s#commentpreview' method=' post'>\n" % env.href.wiki(pagename))81 out.write("<form action='%s#commentpreview' method='get'>\n" % env.href.wiki(pagename)) 82 82 out.write("<fieldset>\n<legend>Add comment</legend>\n") 83 83 out.write("<div class='field'>\n<textarea id='addcomment' name='addcomment' cols='80' rows='5'%s>" % disabled) … … 92 92 out.write("<input type='submit' name='previewaddcomment' value='Preview comment'%s/>\n" % disabled) 93 93 out.write("<input type='submit' name='canceladdcomment' value='Cancel'%s/>\n</div>\n" % disabled) 94 out.write('<script type="text/javascript" src="%sjs/wikitoolbar.js"></script>' % hdf['htdocs_location']) 94 95 out.write("<script type='text/javascript'>\naddWikiFormattingToolbar(document.getElementById('addcomment'));\n</script>\n") 95 96 out.write("</fieldset>\n</form>\n")
Note: See TracChangeset
for help on using the changeset viewer.
