annotate MoinMoin/action/Despam.py @ 14:c8a7e012ebeb

Despam / mass revert action, needs superuser imported from: moin--main--1.5--patch-15
author Thomas Waldmann <tw@waldmann-edv.de>
date Fri, 23 Sep 2005 19:27:45 +0000
parents
children 2202f548cbb0
rev   line source
14
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
2 """
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
3 MoinMoin - Despam action
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
4
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
5 Mass revert changes done by some specific author / bot.
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
6
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
7 @copyright: 2005 by ???, Thomas Waldmann
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
8 @license: GNU GPL, see COPYING for details.
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
9 """
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
10
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
11 import time, urllib
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
12
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
13 from MoinMoin.logfile import editlog
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
14 from MoinMoin.util.dataset import TupleDataset, Column
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
15 from MoinMoin.widget.browser import DataBrowserWidget
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
16 from MoinMoin import wikiutil, Page, PageEditor
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
17 from MoinMoin.macro import RecentChanges
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
18 from MoinMoin.formatter.text_html import Formatter
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
19
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
20 def show_editors(request, pagename, timestamp):
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
21 _ = request.getText
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
22
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
23 timestamp = int(timestamp * 1000000)
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
24 log = editlog.EditLog(request)
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
25 editors = {}
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
26 pages = {}
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
27 for line in log.reverse():
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
28 if line.ed_time_usecs < timestamp:
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
29 break
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
30
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
31 if not request.user.may.read(line.pagename):
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
32 continue
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
33
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
34 editor = line.getEditor(request)
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
35 if not pages.has_key(line.pagename):
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
36 pages[line.pagename] = 1
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
37 editors[editor] = editors.get(editor, 0) + 1
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
38
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
39 editors = [(nr, editor) for editor, nr in editors.iteritems()]
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
40 editors.sort()
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
41
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
42 pg = Page.Page(request, pagename)
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
43
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
44 dataset = TupleDataset()
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
45 dataset.columns = [Column('editor', label=_("Editor"), align='left'),
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
46 Column('pages', label=_("Pages"), align='right'),
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
47 Column('link', label='', align='left')]
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
48 for nr, editor in editors:
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
49 dataset.addRow((editor, unicode(nr), pg.link_to(request, text=_("Select Author"), querystr="action=Despam&editor=%s" % urllib.quote_plus(editor))))
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
50
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
51 table = DataBrowserWidget(request)
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
52 table.setData(dataset)
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
53 table.render()
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
54
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
55 class tmp:
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
56 pass
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
57
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
58 def show_pages(request, pagename, editor, timestamp):
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
59 _ = request.getText
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
60
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
61 timestamp = int(timestamp * 1000000)
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
62 log = editlog.EditLog(request)
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
63 lines = []
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
64 pages = {}
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
65 # mimic macro object for use of RecentChanges subfunctions
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
66 macro = tmp()
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
67 macro.request = request
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
68 macro.formatter = Formatter(request)
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
69
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
70 request.write("<p>")
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
71 for line in log.reverse():
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
72 if line.ed_time_usecs < timestamp:
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
73 break
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
74
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
75 if not request.user.may.read(line.pagename):
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
76 continue
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
77
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
78
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
79 if not pages.has_key(line.pagename):
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
80 pages[line.pagename] = 1
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
81 if line.getEditor(request) == editor:
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
82 request.write(RecentChanges.format_page_edits(macro, [line], timestamp))
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
83
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
84 request.write('''
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
85 </p>
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
86 <p>
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
87 <form method="post" action="%s/%s">
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
88 <input type="hidden" name="action" value="Despam">
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
89 <input type="hidden" name="editor" value="%s">
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
90 <input type="submit" name="ok" value="%s">
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
91 </form>
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
92 </p>
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
93 ''' % (request.getScriptname(), wikiutil.quoteWikinameURL(pagename),
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
94 urllib.quote(editor), _("Revert all!")))
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
95
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
96 def revert_page(request, pagename, editor):
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
97 if not request.user.may.revert(pagename):
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
98 return
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
99
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
100 log = editlog.EditLog(request, rootpagename=pagename)
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
101
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
102 first = True
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
103 rev = u"00000000"
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
104 for line in log.reverse():
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
105 if first:
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
106 first = False
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
107 if line.getEditor(request) != editor:
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
108 return
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
109 else:
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
110 if line.getEditor(request) != editor:
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
111 rev = line.rev
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
112 break
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
113 oldpg = Page.Page(request, pagename, rev=int(rev))
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
114 pg = PageEditor.PageEditor(request, pagename)
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
115 try:
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
116 savemsg = pg.saveText(oldpg.get_raw_body(), 0, extra=rev, action="SAVE/REVERT")
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
117 except pg.SaveError, msg:
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
118 # msg contain a unicode string
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
119 savemsg = unicode(msg)
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
120 return savemsg
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
121
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
122 def revert_pages(request, editor, timestamp):
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
123 _ = request.getText
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
124
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
125 editor = urllib.unquote(editor)
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
126 timestamp = int(timestamp * 1000000)
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
127 log = editlog.EditLog(request)
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
128 pages = {}
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
129 messages = []
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
130 for line in log.reverse():
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
131 if line.ed_time_usecs < timestamp:
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
132 break
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
133
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
134 if not request.user.may.read(line.pagename):
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
135 continue
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
136
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
137 if not pages.has_key(line.pagename):
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
138 pages[line.pagename] = 1
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
139 if line.getEditor(request) == editor:
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
140 msg = revert_page(request, line.pagename, editor)
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
141 if msg:
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
142 request.write("<p>%s: %s</p>" % (
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
143 Page.Page(request, line.pagename).link_to(request), msg))
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
144
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
145 def execute(pagename, request):
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
146 _ = request.getText
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
147 # be extra paranoid in dangerous actions
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
148 actname = __name__.split('.')[-1]
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
149 if actname in request.cfg.actions_excluded or \
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
150 request.user.name not in request.cfg.superuser:
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
151 return Page.Page(request, pagename).send_page(request,
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
152 msg = _('You are not allowed to use this action.'))
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
153
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
154 editor = request.form.get('editor', [None])[0]
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
155 timestamp = time.time() - 24 * 3600
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
156 # request.form.get('timestamp', [None])[0]
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
157 ok = request.form.get('ok', [0])[0]
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
158
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
159 wikiutil.send_title(request, "Despam", pagename=pagename)
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
160 # Start content (important for RTL support)
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
161 request.write(request.formatter.startContent("content"))
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
162
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
163 if ok:
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
164 revert_pages(request, editor, timestamp)
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
165 elif editor:
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
166 show_pages(request, pagename, editor, timestamp)
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
167 else:
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
168 show_editors(request, pagename, timestamp)
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
169
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
170 # End content and send footer
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
171 request.write(request.formatter.endContent())
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
172 wikiutil.send_footer(request, pagename, editable=0, showactions=0, form=request.form)
c8a7e012ebeb Despam / mass revert action, needs superuser
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
173