wiki: Switch wiki authors to id.

This commit is contained in:
Andre D
2012-11-11 19:59:02 -05:00
committed by Neil Williams
parent 0fbe7f63c3
commit 35bec69726
5 changed files with 9 additions and 9 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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({})

View File

@@ -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:

View File

@@ -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]