Skip to content

Commit

Permalink
Merge 1ac8ef7 into a7f42be
Browse files Browse the repository at this point in the history
  • Loading branch information
gvn committed Oct 2, 2018
2 parents a7f42be + 1ac8ef7 commit 542a28a
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 34 deletions.
4 changes: 2 additions & 2 deletions network-api/networkapi/buyersguide/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ class Meta:
url = Faker('url')
price = random.randint(49, 1500)
camera_app = Faker('boolean')
meets_minimum_security_standards = Faker('boolean')
camera_device = Faker('boolean')
microphone_app = Faker('boolean')
microphone_device = Faker('boolean')
location_app = Faker('boolean')
location_device = Faker('boolean')
uses_encryption = Faker('boolean')
privacy_policy = str(random.randint(0, 1))
privacy_policy_reading_level = str(random.randint(7, 19))
share_data = Faker('boolean')
must_change_default_password = Faker('boolean')
security_updates = Faker('boolean')
need_account = Faker('boolean')
delete_data = Faker('boolean')
child_rules = Faker('boolean')
manage_security = Faker('boolean')
customer_support_easy = Faker('boolean')
phone_number = Faker('phone_number')
live_chat = Faker('url')
email = Faker('email')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.14 on 2018-10-02 16:59
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('buyersguide', '0003_auto_20180927_2052'),
]

operations = [
migrations.RemoveField(
model_name='product',
name='customer_support_easy',
),
migrations.RemoveField(
model_name='product',
name='customer_support_easy_helptext',
),
migrations.RemoveField(
model_name='product',
name='privacy_policy',
),
migrations.AddField(
model_name='product',
name='meets_minimum_security_standards',
field=models.NullBooleanField(help_text='Does this product meet minimum security standards?'),
),
migrations.AddField(
model_name='product',
name='privacy_policy_reading_level',
field=models.CharField(choices=[('0', "Can't Determine"), ('7', 'Grade 7'), ('8', 'Grade 8'), ('9', 'Grade 9'), ('10', 'Grade 10'), ('11', 'Grade 11'), ('12', 'Grade 12'), ('13', 'Grade 13'), ('14', 'Grade 14'), ('15', 'Grade 15'), ('16', 'Grade 16'), ('17', 'Grade 17'), ('18', 'Grade 18'), ('19', 'Grade 19')], default='0', max_length=2),
),
migrations.AddField(
model_name='product',
name='privacy_policy_url',
field=models.URLField(blank='True'),
),
migrations.AddField(
model_name='product',
name='related_products',
field=models.ManyToManyField(blank=True, null=True, related_name='_product_related_products_+', to='buyersguide.Product'),
),
migrations.AddField(
model_name='product',
name='twitter',
field=models.CharField(blank='True', help_text='Twitter username', max_length=100),
),
migrations.AlterField(
model_name='product',
name='updates',
field=models.ManyToManyField(blank=True, null=True, related_name='products', to='buyersguide.Update'),
),
]
49 changes: 34 additions & 15 deletions network-api/networkapi/buyersguide/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ class Product(models.Model):
blank=True,
)

meets_minimum_security_standards = models.NullBooleanField(
help_text='Does this product meet minimum security standards?',
)

# Can it spy on me?

camera_device = models.NullBooleanField(
Expand Down Expand Up @@ -119,14 +123,30 @@ class Product(models.Model):
)

PP_CHOICES = (
('0', 'Grade 8-12'),
('1', 'Grade 13+'),
('0', 'Can\'t Determine'),
('7', 'Grade 7'),
('8', 'Grade 8'),
('9', 'Grade 9'),
('10', 'Grade 10'),
('11', 'Grade 11'),
('12', 'Grade 12'),
('13', 'Grade 13'),
('14', 'Grade 14'),
('15', 'Grade 15'),
('16', 'Grade 16'),
('17', 'Grade 17'),
('18', 'Grade 18'),
('19', 'Grade 19'),
)

privacy_policy_url = models.URLField(
blank="True"
)

privacy_policy = models.CharField(
privacy_policy_reading_level = models.CharField(
choices=PP_CHOICES,
default=0,
max_length=1,
default='0',
max_length=2,
)

privacy_policy_helptext = models.TextField(
Expand Down Expand Up @@ -201,15 +221,6 @@ class Product(models.Model):
blank="True"
)

customer_support_easy = models.NullBooleanField(
help_text='Makes it easy to contact customer support?',
)

customer_support_easy_helptext = models.TextField(
max_length=5000,
blank="True"
)

phone_number = models.CharField(
max_length=100,
help_text='Phone Number',
Expand All @@ -228,6 +239,12 @@ class Product(models.Model):
blank="True",
)

twitter = models.CharField(
max_length=100,
help_text='Twitter username',
blank="True",
)

# What could happen if something went wrong?

worst_case = models.CharField(
Expand All @@ -236,7 +253,9 @@ class Product(models.Model):
blank="True",
)

updates = models.ManyToManyField(Update, related_name='products', null=True)
updates = models.ManyToManyField(Update, related_name='products', null=True, blank=True)

related_products = models.ManyToManyField('self', related_name='rps', null=True, blank=True)

# objects = HighlightQuerySet.as_manager()

Expand Down
43 changes: 34 additions & 9 deletions network-api/networkapi/buyersguide/templates/product_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
{% load criterion %}
{% load product-update %}
{% load yes_no %}
{% load env %}

{% block body-id %}TODO-CATEGORY{% endblock %}

{% block guts %}
<div class="container-fluid text-center product-header bg-gray">

<img class="mb-0" src="{{mediaUrl}}{{product.image}}" width="500"/>
<img class="mb-0" src="{{mediaUrl}}{{"AWS_LOCATION"|env}}/{{product.image}}" width="500"/>
</div>
<div class="container">

Expand Down Expand Up @@ -61,14 +61,18 @@ <h3 class="h3-heading h3-heading-small">What does it know about me?</h3>

<div class="mb-5">
{% criterion "uses_encryption" "Product uses encryption" product.uses_encryption product.uses_encryption_helptext %}
{% criterion "privacy_policy" "Privacy policy reading level" product.privacy_policy product.privacy_policy_helptext %}
{% if product.privacy_policy_url %}
{% criterion "privacy_policy_reading_level" "<a target=\\\"_blank\\\" href=\\\""|add:product.privacy_policy_url|add:"\\\">Privacy policy</a> reading level" product.privacy_policy_reading_level product.privacy_policy_helptext %}
{% else %}
{% criterion "privacy_policy_reading_level" "Privacy policy reading level" product.privacy_policy_reading_level product.privacy_policy_helptext %}
{% endif %}
{% criterion "share_data" "Shares your information with third parties" product.share_data product.share_data_helptext %}
</div>

<h3 class="h3-heading h3-heading-small">Can I control it?</h3>

<div class="mb-5">
{% criterion "must_change_default_password" "Must change the default password" product.must_change_default_password product.must_change_default_password_helptext %}
{% criterion "must_change_default_password" "If a password is required, you must change the default password" product.must_change_default_password product.must_change_default_password_helptext "Not required" %}
{% criterion "security_updates" "Automatic security updates" product.security_updates product.security_updates_helptext %}
{% criterion "need_account" "Requires an account" product.need_account product.need_account_helptext %}
{% criterion "delete_data" "Deletes data it stores on you" product.delete_data product.delete_data_helptext %}
Expand All @@ -82,7 +86,7 @@ <h3 class="h3-heading h3-heading-small">Company shows it cares about its custome
</div>

<div class="row mb-5">
<div class="col-12 col-md-4">
<div class="col-12 col-md-3">
<div class="spy">
<img src="/_images/buyers-guide/icon-phone.svg" width="28" height="28" />
<div>
Expand All @@ -95,7 +99,7 @@ <h3 class="h3-heading h3-heading-small">Company shows it cares about its custome
</div>
</div>
</div>
<div class="col-12 col-md-4">
<div class="col-12 col-md-3">
<div class="spy">
<img src="/_images/buyers-guide/icon-chat.svg" width="31" height="26" />
<div>
Expand All @@ -108,7 +112,7 @@ <h3 class="h3-heading h3-heading-small">Company shows it cares about its custome
</div>
</div>
</div>
<div class="col-12 col-md-4">
<div class="col-12 col-md-3">
<div class="spy">
<img src="/_images/buyers-guide/icon-mail.svg" width="31" height="23" />
<div>
Expand All @@ -121,6 +125,19 @@ <h3 class="h3-heading h3-heading-small">Company shows it cares about its custome
</div>
</div>
</div>
<div class="col-12 col-md-3">
<div class="spy">
<img src="/_images/buyers-guide/icon-twitter.svg" width="31" height="23" />
<div>
<strong class="d-block">Twitter</strong>
{% if product.twitter %}
<a href="https://twitter.com/{{product.twitter}}">Yes</a>
{% else %}
No
{% endif %}
</div>
</div>
</div>
</div>

<h3 class="h3-heading h3-heading-small">What could happen if something went wrong?</h3>
Expand All @@ -143,9 +160,17 @@ <h3 class="h3-heading my-5">Updates</h3>
{% productUpdate product.source product.title product.author product.snippet %}
{% endfor %}

<h3 class="h3-heading my-5">Related Products</h3>
<h3 class="h3-heading mb-3 mt-5">Related Products</h3>

<!-- TODO -->
<div class="row">
{% for product in product.related_products.all %}
<div class="col-12 col-md-3">
<a href="/privacynotincluded/product/{{ product.name }}">
<img src="{{mediaUrl}}{{"AWS_LOCATION"|env}}/{{product.image}}"/>
</a>
</div>
{% endfor %}
</div>

</div>
</div>
Expand Down
12 changes: 6 additions & 6 deletions network-api/networkapi/buyersguide/templatetags/criterion.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@


@register.inclusion_tag('tags/criterion.html')
def criterion(id, question, answer, helptext=None):
def criterion(id, question, answer, helptext=None, indeterminate_copy="Can't determine"):
cssClassSuffix = "null"

if answer is None:
formattedAnswer = "Can't determine"
formattedAnswer = indeterminate_copy
elif isinstance(answer, str):
if answer is "0":
cssClassSuffix = "8"
formattedAnswer = "Grade 8-12"
cssClassSuffix = "0"
formattedAnswer = indeterminate_copy
else:
cssClassSuffix = "13"
formattedAnswer = "Grade 13+"
cssClassSuffix = answer
formattedAnswer = ("Grade {answer}".format(answer=answer))
else:
cssClassSuffix = ("false", "true")[answer]
formattedAnswer = ("No", "Yes")[answer]
Expand Down
12 changes: 12 additions & 0 deletions network-api/networkapi/buyersguide/templatetags/env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django import template
from django.conf import settings

register = template.Library()


@register.filter
def env(value):
if hasattr(settings, value):
return getattr(settings, value)
else:
return ""
14 changes: 14 additions & 0 deletions source/images/buyers-guide/icon-twitter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion source/js/buyers-guide/components/criterion/criterion.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class Criterion extends React.Component {
<div className={fullClass}>
<div className="primary-info">
<p className="d-flex align-items-center">
{this.props.meta.question}
<span dangerouslySetInnerHTML={{__html:this.props.meta.question}}></span>
{this.state.hasHelptext &&
<button onClick={this.toggle} className={this.state.helptextVisible ? `open` : `closed`}></button>
}
Expand Down
16 changes: 15 additions & 1 deletion source/sass/buyers-guide/views/product.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
.spy {
display: flex;
align-items: center;
word-break: break-word;

img {
margin-right: 15px;
Expand All @@ -44,6 +45,12 @@
justify-content: space-between;
}

a {
text-decoration: underline;
color: $black;
font-weight: 400;
}

p {
margin-bottom: 0;
}
Expand Down Expand Up @@ -85,7 +92,13 @@

// Sad Cases
.criterion-uses_encryption.criterion-false,
.criterion-privacy_policy.criterion-13,
.criterion-privacy_policy_reading_level.criterion-13,
.criterion-privacy_policy_reading_level.criterion-14,
.criterion-privacy_policy_reading_level.criterion-15,
.criterion-privacy_policy_reading_level.criterion-16,
.criterion-privacy_policy_reading_level.criterion-17,
.criterion-privacy_policy_reading_level.criterion-18,
.criterion-privacy_policy_reading_level.criterion-19,
.criterion-share_data.criterion-true,
.criterion-must_change_default_password.criterion-false,
.criterion-security_updates.criterion-false,
Expand All @@ -105,6 +118,7 @@
}

// Ambivalent Case
.criterion-privacy_policy_reading_level.criterion-0,
.criterion.criterion-null {
.emoji {
background: url("/_images/buyers-guide/icon-face-neutral.svg") no-repeat;
Expand Down

0 comments on commit 542a28a

Please sign in to comment.