show correct search placeholders on sphinx search pages (bug 712638, bug 712634)

This commit is contained in:
Chris Van 2011-12-29 01:08:01 -05:00
Родитель ee2a3829d9
Коммит 62bf0d1715
3 изменённых файлов: 26 добавлений и 5 удалений

Просмотреть файл

@ -75,6 +75,24 @@ class TestAdminDisabledAddons(SphinxTestCase):
super(TestAdminDisabledAddons, self).setUp()
class TestSphinxSearchboxTarget(SphinxTestCase):
fixtures = ['base/addon_3615']
def check(self, cat):
url = reverse('search.search')
r = self.client.get(url, dict(cat=cat))
form = pq(r.content)('#search')
eq_(form.attr('action'), url)
eq_(form('input[name=q]').attr('placeholder'), 'search for %s' % cat)
eq_(form('input[name=cat]').val(), cat)
def test_collections(self):
self.check('collections')
def test_personas(self):
self.check('personas')
class TestSearchboxTarget(amo.tests.ESTestCase):
@classmethod

Просмотреть файл

@ -220,7 +220,7 @@ def _personas(request):
pager = amo.utils.paginate(request, results, search_opts['limit'])
categories, filter, _, _ = browse.views.personas_listing(request)
c = dict(pager=pager, form=form, categories=categories, query=query,
filter=filter)
filter=filter, search_placeholder='personas')
return jingo.render(request, 'search/personas.html', c)
@ -244,7 +244,8 @@ def _collections(request):
pager = amo.utils.paginate(request, results, search_opts['limit'])
c = dict(pager=pager, form=form, query=query, opts=search_opts,
filter=bandwagon.views.get_filter(request))
filter=bandwagon.views.get_filter(request),
search_placeholder='collections')
return jingo.render(request, 'search/collections.html', c)

Просмотреть файл

@ -3,9 +3,11 @@
<span class="wrap">
<input id="search-q" type="text" name="q" autocomplete="off" title=""
class="text {% if not search_form.q.data %}placeholder{% endif %}"
placeholder="{{ search_form.placeholder() }}"
value="{{ search_form.q.data or '' }}">
placeholder="{{ search_form.placeholder(search_placeholder) }}"
value="{{ query.q if query else '' }}">
{% if search_form.cat.value() %}
{{ search_form.cat }}
{% endif %}
{{ search_form.appver }}
{{ search_form.platform }}
</span>