Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only show products reviewed in the last year #3815

Merged
merged 4 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion network-api/networkapi/buyersguide/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from datetime import datetime

from cloudinary import uploader
from cloudinary.models import CloudinaryField

Expand Down Expand Up @@ -134,6 +136,13 @@ class Product(ClusterableModel):
help_text='Review date of this product',
)

@property
def is_current(self):
d = self.review_date
review = datetime(d.year, d.month, d.day)
cutoff = datetime(2019, 6, 1)
mmmavis marked this conversation as resolved.
Show resolved Hide resolved
return cutoff < review

name = models.CharField(
max_length=100,
help_text='Name of Product',
Expand Down Expand Up @@ -576,8 +585,9 @@ def to_dict(self):
model_dict['numeric_reading_grade'] = self.numeric_reading_grade
model_dict['reading_grade'] = self.reading_grade

# model_to_dict does NOT capture related fields!
# model_to_dict does NOT capture related fields or @properties!
model_dict['privacy_policy_links'] = list(self.privacy_policy_links.all())
model_dict['is_current'] = self.is_current

return model_dict

Expand Down
51 changes: 27 additions & 24 deletions network-api/networkapi/buyersguide/templates/buyersguide_home.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{% extends "./bg_base.html" %}

{% load env %}
{% load cloudinary %}
{% load env cloudinary %}

{% block body_id %}home{% endblock %}

Expand Down Expand Up @@ -32,8 +31,6 @@ <h1 class="h1-heading text-center mt-4">Be Smart. Shop Safe.</h1>
</div>
</div>



<div class="project-list-section">
<div class="creepiness-slider bg-white text-center">
<span class="current-creepiness">
Expand All @@ -49,37 +46,43 @@ <h1 class="h1-heading text-center mt-4">Be Smart. Shop Safe.</h1>

<div class="product-box-list-wrapper">
<div class="product-box-list d-flex justify-content-center align-items-stretch flex-wrap">

{% for product in products %}
<figure class="product-box d-flex flex-column justify-content-between{% if product.draft %} draft-product{% endif %}{% if product.adult_content %} adult-content{% endif %}" data-creepiness="{{ product.votes.creepiness.average }}">
{% if product.is_current %}

<figure class="product-box d-flex flex-column justify-content-between{% if product.draft %} draft-product{% endif %}{% if product.adult_content %} adult-content{% endif %}" data-creepiness="{{ product.votes.creepiness.average }}">
<div class="top-left-badge-container">
{% include "fragments/seal_of_approval.html" with product=product %}
{% if product.votes.confidence %}
{% if product.votes.confidence.1 > product.votes.confidence.0 %}
<div class="d-none recommendation positive"></div>
{% else %}
<div class="d-none recommendation negative"></div>
{% endif %}
{% endif %}
{% include "fragments/seal_of_approval.html" with product=product %}
{% if product.votes.confidence %}
{% if product.votes.confidence.1 > product.votes.confidence.0 %}
<div class="d-none recommendation positive"></div>
{% else %}
<div class="d-none recommendation negative"></div>
{% endif %}
{% endif %}
</div>

{% include "fragments/adult_content_badge.html" with product=product %}

<a class="product-image text-center mt-4 h-100 d-flex flex-column justify-content-between" href="{% url 'product-view' product.slug %}">
{% if USE_CLOUDINARY %}
<img
{% if USE_CLOUDINARY %}
<img
class="product-thumbnail"
src="{% cloudinary_url product.cloudinary_image quality=50 fetch_format="auto" crop="fit" width=600 %}"
alt="link to {{product.name}}"
>
{% else %}
<img class="product-thumbnail" src="{{mediaUrl}}{{"AWS_LOCATION"|env}}/{{product.image }}" alt="link to {{product.name}}">
{% endif %}
<figcaption class="hidden-sm-down mt-md-2 text-left">
>
{% else %}
<img class="product-thumbnail" src="{{mediaUrl}}{{"AWS_LOCATION"|env}}/{{product.image }}" alt="link to {{product.name}}">
{% endif %}
<figcaption class="hidden-sm-down mt-md-2 text-left">
<div class="body-small">{{product.company}}</div>
<div class="body">{{product.name}}</div>
</figcaption>
</figcaption>
</a>
</figure>
{% endfor %}
</figure>
{% endif %}
{% endfor %}

<div class="no-matching-products-note bg-gray w-100 pt-5 d-none">
<div class="d-flex flex-column align-items-center">
<div>No results.</div>
Expand Down
40 changes: 21 additions & 19 deletions network-api/networkapi/buyersguide/templates/category_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,29 @@ <h1 class="h2-heading">{{ category.name }}</h1>

<div class="row">
{% for product in products %}
<div class="category-item-container col-6 {% if product.draft %} draft-product{% endif %}{% if product.adult_content %} adult-content{% endif %}">
<a href="{% url 'product-view' product.slug %}">
<div class="category-image-container">
{% include "fragments/seal_of_approval.html" with product=product %}
{% include "fragments/adult_content_badge.html" with product=product %}
{% if product.is_current %}
<div class="category-item-container col-6 {% if product.draft %} draft-product{% endif %}{% if product.adult_content %} adult-content{% endif %}">
<a href="{% url 'product-view' product.slug %}">
<div class="category-image-container">
{% include "fragments/seal_of_approval.html" with product=product %}
{% include "fragments/adult_content_badge.html" with product=product %}

{% if USE_CLOUDINARY %}
<img
class="product-thumbnail thumb-border"
width="300"
src="{% cloudinary_url product.cloudinary_image quality=50 fetch_format="auto" crop="fit" width=600 %}"
alt="{{ product.name }}"
>
{% else %}
<img class="product-thumbnail" src="{{ mediaUrl }}{{ "AWS_LOCATION" | env }}/{{ product.image }}">
{% endif %}
{% if USE_CLOUDINARY %}
<img
class="product-thumbnail thumb-border"
width="300"
src="{% cloudinary_url product.cloudinary_image quality=50 fetch_format="auto" crop="fit" width=600 %}"
alt="{{ product.name }}"
>
{% else %}
<img class="product-thumbnail" src="{{ mediaUrl }}{{ "AWS_LOCATION" | env }}/{{ product.image }}">
{% endif %}
</div>
<h3 class="mb-1 body-small">{{ product.company }}</h3>
<h3 class="mb-5 h5-heading">{{ product.name }}</h3>
</a>
</div>
<h3 class="mb-1 body-small">{{ product.company }}</h3>
<h3 class="mb-5 h5-heading">{{ product.name }}</h3>
</a>
</div>
{% endif %}
{% endfor %}

<p><em>The information provided here is pulled directly from the product website.</em></p>
Expand Down