mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-28 00:07:57 -05:00
wiki: Switch wiki authors to id.
This commit is contained in:
@@ -1597,7 +1597,7 @@ class ApiController(RedditController, OAuth2ResourceController):
|
||||
except tdb_cassandra.NotFound:
|
||||
wikipage = wiki.WikiPage.create(sr, pagename)
|
||||
try:
|
||||
wr = wikipage.revise(value, previous=prev, author=c.user.name)
|
||||
wr = wikipage.revise(value, previous=prev, author=c.user._id36)
|
||||
setattr(sr, field, value)
|
||||
if not wr:
|
||||
return True
|
||||
|
||||
@@ -90,7 +90,7 @@ def may_revise(sr, user, page=None):
|
||||
# Global wiki contribute ban
|
||||
return False
|
||||
|
||||
if page and page.has_editor(user.name):
|
||||
if page and page.has_editor(user._id36):
|
||||
# If the user is an editor on the page, they may edit
|
||||
return True
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ class WikiApiController(WikiController):
|
||||
c.site.change_css(content, parsed, previous, reason=reason)
|
||||
else:
|
||||
try:
|
||||
page.revise(content, previous, c.user.name, reason=reason)
|
||||
page.revise(content, previous, c.user._id36, reason=reason)
|
||||
except ContentLengthError as e:
|
||||
self.handle_error(403, 'CONTENT_LENGTH_ERROR', max_length = e.max_length)
|
||||
|
||||
@@ -306,9 +306,9 @@ class WikiApiController(WikiController):
|
||||
if not user:
|
||||
self.handle_error(404, 'UNKNOWN_USER')
|
||||
elif act == 'del':
|
||||
page.remove_editor(user.name)
|
||||
page.remove_editor(user._id36)
|
||||
elif act == 'add':
|
||||
page.add_editor(user.name)
|
||||
page.add_editor(user._id36)
|
||||
else:
|
||||
self.handle_error(400, 'INVALID_ACTION')
|
||||
return json.dumps({})
|
||||
|
||||
@@ -364,7 +364,7 @@ class Subreddit(Thing, Printable):
|
||||
|
||||
def change_css(self, content, parsed, prev=None, reason=None, author=None, force=False):
|
||||
from r2.models import ModAction
|
||||
author = author if author else c.user.name
|
||||
author = author if author else c.user._id36
|
||||
if content is None:
|
||||
content = ''
|
||||
try:
|
||||
|
||||
@@ -86,7 +86,7 @@ class WikiRevision(tdb_cassandra.UuidThing, Printable):
|
||||
|
||||
def get_author(self):
|
||||
author = self._get('author')
|
||||
return Account._by_name(author, allow_deleted=True) if author else None
|
||||
return Account._byID36(author) if author else None
|
||||
|
||||
@classmethod
|
||||
def add_props(cls, user, wrapped):
|
||||
@@ -173,7 +173,7 @@ class WikiPage(tdb_cassandra.Thing):
|
||||
|
||||
def get_author(self):
|
||||
if self._get('last_edit_by'):
|
||||
return Account._by_name(self.last_edit_by, allow_deleted=True)
|
||||
return Account._byID36(self.last_edit_by)
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
@@ -271,7 +271,7 @@ class WikiPage(tdb_cassandra.Thing):
|
||||
|
||||
def get_editor_accounts(self):
|
||||
editors = self.get_editors()
|
||||
accounts = [Account._by_name(editor, allow_deleted=True)
|
||||
accounts = [Account._byID36(editor)
|
||||
for editor in self.get_editors()]
|
||||
accounts = [account for account in accounts
|
||||
if not account._deleted]
|
||||
|
||||
Reference in New Issue
Block a user