mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-24 06:18:08 -05:00
wiki: Add option to remove wiki pages from list
When combined with a mod only page, this allows users to delete and undelete pages. This also allows users to "move" pages by unlisting the old one.
This commit is contained in:
@@ -37,6 +37,7 @@ from r2.lib.template_helpers import join_urls
|
||||
from r2.lib.validator import (
|
||||
nop,
|
||||
validate,
|
||||
VBoolean,
|
||||
VExistingUname,
|
||||
VInt,
|
||||
VMarkdown,
|
||||
@@ -217,7 +218,7 @@ class WikiController(RedditController):
|
||||
|
||||
def GET_wiki_listing(self):
|
||||
def check_hidden(page):
|
||||
return this_may_view(page)
|
||||
return page.listed and this_may_view(page)
|
||||
pages, linear_pages = WikiPage.get_listing(c.site, filter_check=check_hidden)
|
||||
return WikiListing(pages, linear_pages).render()
|
||||
|
||||
@@ -236,7 +237,8 @@ class WikiController(RedditController):
|
||||
|
||||
@validate(page=VWikiPage('page', restricted=True, modonly=True))
|
||||
def GET_wiki_settings(self, page):
|
||||
settings = {'permlevel': page._get('permlevel', 0)}
|
||||
settings = {'permlevel': page._get('permlevel', 0),
|
||||
'listed': page.listed}
|
||||
mayedit = page.get_editor_accounts()
|
||||
restricted = (not page.special) and page.restricted
|
||||
show_editors = not restricted
|
||||
@@ -247,16 +249,27 @@ class WikiController(RedditController):
|
||||
|
||||
@validate(VModhash(),
|
||||
page=VWikiPage('page', restricted=True, modonly=True),
|
||||
permlevel=VInt('permlevel'))
|
||||
def POST_wiki_settings(self, page, permlevel):
|
||||
permlevel=VInt('permlevel'),
|
||||
listed=VBoolean('listed'))
|
||||
def POST_wiki_settings(self, page, permlevel, listed):
|
||||
oldpermlevel = page.permlevel
|
||||
try:
|
||||
page.change_permlevel(permlevel)
|
||||
except ValueError:
|
||||
self.handle_error(403, 'INVALID_PERMLEVEL')
|
||||
description = 'Page: %s, Changed from %s to %s' % (page.name, oldpermlevel, permlevel)
|
||||
ModAction.create(c.site, c.user, 'wikipermlevel',
|
||||
description=description)
|
||||
if page.listed != listed:
|
||||
page.listed = listed
|
||||
page._commit()
|
||||
verb = 'Relisted' if listed else 'Delisted'
|
||||
description = '%s page %s' % (verb, page.name)
|
||||
ModAction.create(c.site, c.user, 'wikipagelisted',
|
||||
description=description)
|
||||
if oldpermlevel != permlevel:
|
||||
description = 'Page: %s, Changed from %s to %s' % (
|
||||
page.name, oldpermlevel, permlevel
|
||||
)
|
||||
ModAction.create(c.site, c.user, 'wikipermlevel',
|
||||
description=description)
|
||||
return self.GET_wiki_settings(page=page.name)
|
||||
|
||||
def on_validation_error(self, error):
|
||||
|
||||
@@ -779,6 +779,7 @@ class WikiSettingsJsonTemplate(ThingJsonTemplate):
|
||||
def data(self, thing):
|
||||
editors = [Wrapped(e).render() for e in thing.mayedit]
|
||||
return dict(permlevel=thing.permlevel,
|
||||
listed=thing.listed,
|
||||
editors=editors)
|
||||
|
||||
class WikiRevisionJsonTemplate(ThingJsonTemplate):
|
||||
|
||||
@@ -73,6 +73,7 @@ class WikiPageSettings(Templated):
|
||||
def __init__(self, settings, mayedit, show_editors=True,
|
||||
show_settings=True, page=None, **context):
|
||||
self.permlevel = settings['permlevel']
|
||||
self.listed = settings['listed']
|
||||
self.show_settings = show_settings
|
||||
self.show_editors = show_editors
|
||||
self.page = page
|
||||
|
||||
@@ -56,7 +56,7 @@ class ModAction(tdb_cassandra.UuidThing, Printable):
|
||||
'invitemoderator', 'uninvitemoderator', 'acceptmoderatorinvite',
|
||||
'removemoderator', 'addcontributor', 'removecontributor',
|
||||
'editsettings', 'editflair', 'distinguish', 'marknsfw',
|
||||
'wikibanned', 'wikicontributor', 'wikiunbanned',
|
||||
'wikibanned', 'wikicontributor', 'wikiunbanned', 'wikipagelisted',
|
||||
'removewikicontributor', 'wikirevise', 'wikipermlevel',
|
||||
'ignorereports', 'unignorereports', 'setpermissions', 'sticky',
|
||||
'unsticky')
|
||||
@@ -81,6 +81,7 @@ class ModAction(tdb_cassandra.UuidThing, Printable):
|
||||
'wikibanned': _('ban from wiki'),
|
||||
'wikiunbanned': _('unban from wiki'),
|
||||
'wikicontributor': _('add wiki contributor'),
|
||||
'wikipagelisted': _('delist/relist wiki pages'),
|
||||
'removewikicontributor': _('remove wiki contributor'),
|
||||
'wikirevise': _('wiki revise page'),
|
||||
'wikipermlevel': _('wiki page permissions'),
|
||||
@@ -112,6 +113,7 @@ class ModAction(tdb_cassandra.UuidThing, Printable):
|
||||
'editflair': _('edited flair'),
|
||||
'wikirevise': _('edited wiki page'),
|
||||
'wikipermlevel': _('changed wiki page permission level'),
|
||||
'wikipagelisted': _('changed wiki page listing preference'),
|
||||
'distinguish': _('distinguished'),
|
||||
'marknsfw': _('marked nsfw'),
|
||||
'ignorereports': _('ignored reports'),
|
||||
|
||||
@@ -91,7 +91,7 @@ class WikiRevision(tdb_cassandra.UuidThing, Printable):
|
||||
|
||||
_str_props = ('pageid', 'content', 'author', 'reason')
|
||||
_bool_props = ('hidden')
|
||||
|
||||
|
||||
cache_ignore = set(list(_str_props)).union(Printable.cache_ignore).union(['wikipage'])
|
||||
|
||||
def get_author(self):
|
||||
@@ -192,8 +192,9 @@ class WikiPage(tdb_cassandra.Thing):
|
||||
_date_props = ('last_edit_date')
|
||||
_str_props = ('revision', 'name', 'last_edit_by', 'content', 'sr')
|
||||
_int_props = ('permlevel')
|
||||
_bool_props = ('listed_')
|
||||
|
||||
_bool_props = ('listed')
|
||||
_defaults = {'listed': True}
|
||||
|
||||
def get_author(self):
|
||||
if self._get('last_edit_by'):
|
||||
return Account._byID36(self.last_edit_by, data=True)
|
||||
@@ -225,7 +226,7 @@ class WikiPage(tdb_cassandra.Thing):
|
||||
if not name or not sr:
|
||||
raise ValueError
|
||||
name = name.lower()
|
||||
kw = dict(sr=sr._id36, name=name, permlevel=0, content='', listed_=False)
|
||||
kw = dict(sr=sr._id36, name=name, permlevel=0, content='')
|
||||
page = cls(**kw)
|
||||
page._commit()
|
||||
return page
|
||||
|
||||
@@ -6875,6 +6875,7 @@ body:not(.gold) .allminus-link {
|
||||
.modactions.wikibanned,
|
||||
.modactions.wikiunbanned,
|
||||
.modactions.wikicontributor,
|
||||
.modactions.wikipagelisted,
|
||||
.modactions.removewikicontributor,
|
||||
.modactions.ignorereports,
|
||||
.modactions.unignorereports,
|
||||
@@ -6920,6 +6921,7 @@ body:not(.gold) .allminus-link {
|
||||
.modactions.removecontributor {
|
||||
background-image: url(../modactions_removecontributor.png); /* SPRITE */
|
||||
}
|
||||
.modactions.wikipagelisted,
|
||||
.modactions.editsettings {
|
||||
background-image: url(../modactions_editsettings.png); /* SPRITE */
|
||||
}
|
||||
|
||||
@@ -49,6 +49,14 @@
|
||||
%endif
|
||||
/><label for="permlevel2">${_('only mods may edit and view')}</label><br/>
|
||||
</%utils:line_field>
|
||||
|
||||
<%utils:line_field title=" ${_('show this page on the listing?')}">
|
||||
<input type="checkbox" name="listed" id="listed"
|
||||
%if thing.listed:
|
||||
checked
|
||||
%endif
|
||||
/><label for="listed">${_('show this page on the list of wiki pages')}</label><br/>
|
||||
</%utils:line_field>
|
||||
</form>
|
||||
%endif
|
||||
%if thing.show_editors and thing.permlevel != 2:
|
||||
|
||||
Reference in New Issue
Block a user