mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-11 02:20:59 +00:00
Fix crash in get_search_promotions templatetag
This commit is contained in:
parent
e1abccd829
commit
e01cada04f
2 changed files with 5 additions and 4 deletions
|
|
@ -1,6 +1,7 @@
|
|||
from django import template
|
||||
|
||||
from wagtail.wagtailsearch.models import Query
|
||||
from wagtail.contrib.wagtailsearchpromotions.models import SearchPromotion
|
||||
|
||||
|
||||
register = template.Library()
|
||||
|
|
@ -8,4 +9,7 @@ register = template.Library()
|
|||
|
||||
@register.assignment_tag()
|
||||
def get_search_promotions(search_query):
|
||||
return Query.get(search_query).editors_picks.all()
|
||||
if search_query:
|
||||
return Query.get(search_query).editors_picks.all()
|
||||
else:
|
||||
return SearchPromotion.objects.none()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import unittest
|
||||
|
||||
from django.test import TestCase
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
|
|
@ -73,7 +71,6 @@ class TestGetSearchPromotionsTemplateTag(TestCase):
|
|||
search_picks = list(get_search_promotions("root page"))
|
||||
self.assertEqual(search_picks, [pick])
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_get_search_promotions_with_none_query_string(self):
|
||||
search_picks = list(get_search_promotions(None))
|
||||
self.assertEqual(search_picks, [])
|
||||
|
|
|
|||
Loading…
Reference in a new issue