Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
Merge 7c5c17f into 26b6171
Browse files Browse the repository at this point in the history
  • Loading branch information
jezdez committed Jun 10, 2015
2 parents 26b6171 + 7c5c17f commit 813e0d7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
13 changes: 9 additions & 4 deletions kuma/wiki/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def item_description(self, document):
return document.current_revision.summary

def item_author_name(self, document):
return '%s' % document.current_revision.creator
return document.current_revision.creator.username

def item_author_link(self, document):
return self.request.build_absolute_uri(
Expand Down Expand Up @@ -281,8 +281,13 @@ def items(self):
if self.request.GET.get('all_locales', False) is False:
items = items.filter(document__locale=self.request.locale)

items = items.prefetch_related('creator', 'document')
return items.order_by('-created')[start:finish]
# Temporarily storing the selected revision PKs in a list
# to speed up retrieval (max MAX_FEED_ITEMS size)
item_pks = items.values_list('pk', flat=True)[start:finish]
return (Revision.objects.filter(pk__in=list(item_pks))
.prefetch_related('creator',
'document')
.order_by('-created'))

def item_title(self, item):
return '%s (%s)' % (item.document.full_path, item.document.locale)
Expand Down Expand Up @@ -371,7 +376,7 @@ def item_pubdate(self, item):
return item.created

def item_author_name(self, item):
return u'%s' % item.creator
return item.creator.username

def item_author_link(self, item):
return self.request.build_absolute_uri(item.creator.get_absolute_url())
Expand Down
7 changes: 2 additions & 5 deletions kuma/wiki/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1834,11 +1834,8 @@ def get_previous(self):
Returns the previous approved revision or None.
"""
try:
return self.document.revisions.filter(
is_approved=True,
created__lt=self.created,
).order_by('-created')[0]
except IndexError:
return self.get_previous_by_created(is_approved=True)
except Revision.DoesNotExist:
return None

@cached_property
Expand Down

0 comments on commit 813e0d7

Please sign in to comment.