Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

wiki: Add author props in batch.

  • Loading branch information...
commit 3bc9344965eaa8915a371a741389936c7cd74e31 1 parent ef5bd9d
@andre-d andre-d authored spladug committed
Showing with 16 additions and 6 deletions.
  1. +16 −6 r2/r2/models/wiki.py
View
22 r2/r2/models/wiki.py
@@ -89,16 +89,26 @@ def get_author(self):
return Account._byID36(author) if author else None
@classmethod
- def add_props(cls, user, wrapped):
+ def get_authors(cls, revisions):
+ authors = [r._get('author') for r in revisions]
+ authors = filter(None, authors)
+ return Account._byID36(authors)
+
+ @classmethod
+ def get_printable_authors(cls, revisions):
from r2.lib.pages import WrappedUser
+ authors = cls.get_authors(revisions)
+ return dict([(v._id36, WrappedUser(v))
+ for k, v in authors.items() if v])
+
+ @classmethod
+ def add_props(cls, user, wrapped):
+ authors = cls.get_printable_authors(wrapped)
for item in wrapped:
item._hidden = item.is_hidden
item._spam = False
- author = item.get_author()
- if author is None:
- item.printable_author = '[unknown]'
- else:
- item.printable_author = WrappedUser(author)
+ author = item._get('author')
+ item.printable_author = authors.get(author, '[unknown]')
item.reported = False
@classmethod
Please sign in to comment.
Something went wrong with that request. Please try again.