Skip to content

Commit

Permalink
7476 - update search fields/ranking
Browse files Browse the repository at this point in the history
fixes

Fix tests

fixes

Added changes to pushstate

fix

fixes

Fixes

Fix no search results

fix
  • Loading branch information
fessehaye committed Oct 21, 2021
1 parent 145ad47 commit aeab95e
Show file tree
Hide file tree
Showing 9 changed files with 653 additions and 544 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
{% else %}{% blocktrans context "“*privacy not included” can be localized. This is a reference to the “*batteries not included” mention on toys." %}*privacy not included | Shop smart and safe{% endblocktrans %} | Mozilla Foundation{% endif %}
{% endblock %}


{# TODO: consider using a different ga_identifier? #}


Expand All @@ -23,6 +22,8 @@

{% block wagtail_metadata %}
{% meta_tags %}
<meta name="pni-home-title" content="{% blocktrans context "“*privacy not included” can be localized. This is a reference to the “*batteries not included” mention on toys." %}*privacy not included | Shop smart and safe | Mozilla Foundation{% endblocktrans %}">
<meta name="pni-category-title" content="{% trans "Privacy & Security Guide | Mozilla Foundation" %}">
{% endblock %}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "buyersguide/bg_base.html" %}

{% load env i18n static wagtailimages_tags cache %}
{% load env i18n static wagtailimages_tags cache bg_nav_tags %}

{% block bodyclass %}pni catalog{% endblock %}

Expand All @@ -21,7 +21,7 @@ <h1 class="h1-heading text-center mt-0">{{ page.header }}</h1>
<p class="body-large mb-0">{{ page.intro_text }}</p>
<div id="product-filter-search" class='col-12 col-md-9 tw-my-5' tabindex="0">
<span class="search-icon">&nbsp;</span>
<input type="text" role="searchbox" id="product-filter-search-input" placeholder="{% trans "Search all products" %}" class="body-large" value="">
<input type="text" role="searchbox" id="product-filter-search-input" placeholder="{% trans "Search all products" %}" class="body-large tw-text-black" value="">
<label for="product-filter-search-input" class="clear-icon">&nbsp;</label>
</div>
</div>
Expand Down Expand Up @@ -69,13 +69,15 @@ <h1 class="h1-heading text-center mt-0">{{ page.header }}</h1>
{# User is not logged in. Return cached results. 24 hour caching applied. #}
{% cache 86400 pni_home_page template_cache_key_fragment %}
{% for product in products %}
{% include "../fragments/buyersguide_item.html" with product=product.localized %}
{% prod_in_cat product category as matched %}
{% include "../fragments/buyersguide_item.html" with product=product.localized matched=matched %}
{% endfor %}
{% endcache %}
{% else %}
{# User is logged in. Don't cache their results so they can see live and draft products here. #}
{% for product in products %}
{% include "../fragments/buyersguide_item.html" with product=product.localized %}
{% prod_in_cat product category as matched %}
{% include "../fragments/buyersguide_item.html" with product=product.localized matched=matched %}
{% endfor %}
{% endif %}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% load static i18n wagtailimages_tags l10n localization %}

<figure
class="product-box d-flex flex-column justify-content-between{% if product.draft %} draft-product{% endif %}{% if product.adult_content %} adult-content{% endif %}{% if product.privacy_ding %} privacy-ding{% endif%}"
class="product-box {% if matched == False %}d-none{% else %}d-flex{% endif %} flex-column justify-content-between{% if product.draft %} draft-product{% endif %}{% if product.adult_content %} adult-content{% endif %}{% if product.privacy_ding %} privacy-ding{% endif%}"
data-creepiness="{{ product.creepiness|unlocalize }}">
<div class="top-left-badge-container">
{% if product.privacy_ding %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load i18n static %}
{% load i18n static localization %}

<div class="container">
<img class="mb-3 oh-no-face" src="{% static '_images/buyers-guide/faces/oh-no.svg' %}" alt="{% trans "Sad face. No products were found." %}">
Expand All @@ -9,8 +9,9 @@ <h3 class="h3-heading">

<p class="mb-0">
{% url 'buyersguide-home' as home_url %}
{% blocktrans trimmed %}
Try going back to <a href="#" class="go-back-to-all-link">All</a>. You might find it there.
{% relocalized_url home_page.localized.url as home_url%}
{% blocktrans trimmed with home_url=home_url %}
Try going back to <a href="{{home_url}}" class="go-back-to-all-link">All</a>. You might find it there.
{% endblocktrans %}
</p>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ def bg_active_nav(current, target):
return 'active' if urlparse(current).path == urlparse(target).path else ''


@register.simple_tag(name='prod_in_cat')
def prod_in_cat(productpage, categorySlug):
if categorySlug == "":
return True
return categorySlug in [cat.category.slug for cat in productpage.product_categories.all()]


"""
# Instantiate a list of category page links based on the current page's relation to them
# NOTE: this points to the new, namespaced category_nav_links. If we need to revert to the old app, change this back.
Expand Down
2 changes: 1 addition & 1 deletion network-api/networkapi/wagtailpages/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def test_category_filter_view(self):
with self.settings(CACHES={'default': {'BACKEND': 'django.core.cache.backends.dummy.DummyCache'}}):
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.context['products']), 0)
self.assertEqual(len(response.context['products']), 1)

# Add BuyersGuideProductCategory
category_orderable = ProductPageCategory(
Expand Down
Loading

0 comments on commit aeab95e

Please sign in to comment.