Opened 4 years ago
Closed 3 years ago
#20983 closed defect (fixed)
Spam report not working on second attempt
Reported by: | Bjoeni | Owned by: | stoecker |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Trac | Version: | |
Keywords: | Cc: |
Description
When reporting a ticket using the "report spam" function, a prompt asks for a comment.
If that is cancelled, the this.href
(of the link) is set to the document URL (I assume to prevent the spam report from being sent).
When that URL contains a # (e.g. anchor from a comment) the page will not be reloaded, which means the second time (when a valid comment is provided) the href is still set to the ticket URL and the report will never be sent.
See https://josm.openstreetmap.de/chrome/spamfilter/reportspam.js: event.preventDefault()
should be used instead of changing the href.
Also some kind of feedback that the report was successfully sent would be nice instead of just redirecting back to the ticket.
Attachments (0)
Change History (5)
comment:2 by , 4 years ago
Well this should do the job for the reportspam.js
:
jQuery(function($){ $("#reportspam").click(function(event){ var comment = prompt(spamreport_comment, ""); if (comment == null) { event.preventDefault(); return; } this.href += "&comment=" + encodeURIComponent(comment); }); });
But I only analyzed it on the client side. I have absolutely no clue regarding trac plugin development or python in general, I didn't even know it was a plugin until now. I assume the magic should happen somewhere around report.py#L58, but I don't know how to display a message there.
comment:3 by , 4 years ago
Ah. Right. I thought about a JS alert(), but your' right. I simply can issue an add_notice(). I'll do so when I find a bit time for this.
comment:5 by , 3 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
As you already analyzed the issue, can you provide a patch? Also for the feedback (user visible text must go via the html page as variable, as no translation is possible in the js directly).
https://trac.edgewall.org/wiki/SpamFilter#GetthePlugin