Permalink
Browse files

Merge pull request #712 from floemker/sorting

Sort search results, images, and attachments.
  • Loading branch information...
benjaoming committed Nov 7, 2017
2 parents afefd8e + f656638 commit dc4354b4b01e6b2b86db49684cf11148ae5e5090
Showing with 4 additions and 4 deletions.
  1. +1 −1 src/wiki/plugins/attachments/views.py
  2. +1 −1 src/wiki/plugins/images/views.py
  3. +2 −2 src/wiki/views/article.py
@@ -386,7 +386,7 @@ def get_queryset(self):
Q(original_filename__contains=self.query) |
Q(current_revision__description__contains=self.query) |
Q(article__current_revision__title__contains=self.query))
return qs
return qs.order_by('original_filename')
def get_context_data(self, **kwargs):
# Is this a bit of a hack? Use better inheritance?
@@ -41,7 +41,7 @@ def get_queryset(self):
article=self.article,
current_revision__deleted=False)
images.select_related()
return images
return images.order_by('-current_revision__imagerevision__created')
def get_context_data(self, **kwargs):
kwargs.update(ArticleMixin.get_context_data(self, **kwargs))
@@ -686,15 +686,15 @@ def dispatch(self, request, *args, **kwargs):
def get_queryset(self):
if not self.query:
return models.Article.objects.none()
return models.Article.objects.none().order_by('-current_revision__created')
articles = models.Article.objects.filter(
Q(current_revision__title__icontains=self.query) |
Q(current_revision__content__icontains=self.query))
if not permissions.can_moderate(
models.URLPath.root().article,
self.request.user):
articles = articles.active().can_read(self.request.user)
return articles
return articles.order_by('-current_revision__created')
def get_context_data(self, **kwargs):
kwargs = super(SearchView, self).get_context_data(**kwargs)

0 comments on commit dc4354b

Please sign in to comment.