Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/pip/faker-0.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
alanmoo committed Oct 23, 2018
2 parents bd314f2 + d0dfc68 commit a7d01f3
Show file tree
Hide file tree
Showing 63 changed files with 1,539 additions and 667 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -265,6 +265,7 @@ Opening a PR will automatically create a Review App in the `foundation-site` pip

- `GITHUB_TOKEN`: GITHUB API authentication,
- `SLACK_WEBHOOK_RA`: Webhook to `mofo-review-apps`
- `CORAL_TALK_SERVER_URL`: If Coral Talk commenting is to be enabled, set the server URL here. Don't forget to add the domain to your CSP directives for script-src and child-src

#### Staging

Expand Down
4 changes: 4 additions & 0 deletions env.default
Expand Up @@ -63,3 +63,7 @@ PETITION_TEST_CAMPAIGN_ID=""

GITHUB_TOKEN=""
SLACK_WEBHOOK_RA=""

# BUYER'S GUIDE TALK SERVER

CORAL_TALK_SERVER_URL=""
6 changes: 5 additions & 1 deletion network-api/networkapi/buyersguide/factory.py
Expand Up @@ -8,7 +8,10 @@
)

from networkapi.utility.faker_providers import ImageProvider
from networkapi.buyersguide.models import Product, BuyersGuideProductCategory
from networkapi.buyersguide.models import (
Product,
BuyersGuideProductCategory
)

Faker.add_provider(ImageProvider)

Expand Down Expand Up @@ -60,6 +63,7 @@ def product_category(self, create, extracted, **kwargs):
location_app = Faker('boolean')
location_device = Faker('boolean')
uses_encryption = Faker('boolean')
privacy_policy_reading_level_url = Faker('url')
privacy_policy_reading_level = str(random.randint(7, 19))
share_data = Faker('boolean')
must_change_default_password = Faker('boolean')
Expand Down
20 changes: 20 additions & 0 deletions network-api/networkapi/buyersguide/migrations/0008_product_slug.py
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-10-18 20:46
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('buyersguide', '0007_auto_20181012_2045'),
]

operations = [
migrations.AddField(
model_name='product',
name='slug',
field=models.CharField(blank=True, default=None, editable=False, help_text='slug used in urls', max_length=256, null=True),
),
]
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-10-18 20:47
from __future__ import unicode_literals

from django.db import migrations
from django.utils.text import slugify


def generate_slugs(apps, schema_editor):
Product = apps.get_model('buyersguide', 'Product')
for product in Product.objects.all():
product.slug = slugify(product.name)
product.save()


def remove_slug():
# It's safe for these to just get deleted
pass


class Migration(migrations.Migration):

dependencies = [
('buyersguide', '0008_product_slug'),
]

operations = [
migrations.RunPython(generate_slugs, remove_slug)
]
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-10-18 20:53
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('buyersguide', '0009_auto_20181018_2047'),
]

operations = [
migrations.AlterField(
model_name='product',
name='slug',
field=models.CharField(blank=True, default=None, editable=False, help_text='slug used in urls', max_length=256),
),
]
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-10-23 00:05
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('buyersguide', '0010_auto_20181018_2053'),
]

operations = [
migrations.AddField(
model_name='product',
name='privacy_policy_reading_level_url',
field=models.URLField(blank='True', help_text='Link to privacy policy reading level', max_length=2048),
),
migrations.AlterField(
model_name='product',
name='privacy_policy_url',
field=models.URLField(blank='True', help_text='Link to privacy policy', max_length=2048),
),
]
23 changes: 23 additions & 0 deletions network-api/networkapi/buyersguide/models.py
Expand Up @@ -3,6 +3,7 @@
from django.db import models
from django.core.validators import MaxValueValidator, MinValueValidator
from django.forms import model_to_dict
from django.utils.text import slugify

from networkapi.buyersguide.validators import ValueListValidator
from networkapi.utility.images import get_image_upload_path
Expand Down Expand Up @@ -77,6 +78,14 @@ class Product(models.Model):
blank="True",
)

slug = models.CharField(
max_length=256,
help_text='slug used in urls',
blank=True,
default=None,
editable=False
)

company = models.CharField(
max_length=100,
help_text='Name of Company',
Expand Down Expand Up @@ -173,6 +182,8 @@ class Product(models.Model):
)

privacy_policy_url = models.URLField(
max_length=2048,
help_text='Link to privacy policy',
blank="True"
)

Expand All @@ -182,6 +193,12 @@ class Product(models.Model):
max_length=2,
)

privacy_policy_reading_level_url = models.URLField(
max_length=2048,
help_text='Link to privacy policy reading level',
blank="True"
)

privacy_policy_helptext = models.TextField(
max_length=5000,
blank="True"
Expand Down Expand Up @@ -313,6 +330,7 @@ def votes(self):
# Build + return the votes dict
votes['creepiness'] = creepiness
votes['confidence'] = confidence_vote_breakdown
votes['total'] = BooleanVote.objects.filter(product=self).count()
return votes

except ObjectDoesNotExist:
Expand All @@ -322,8 +340,13 @@ def votes(self):
def to_dict(self):
model_dict = model_to_dict(self)
model_dict['votes'] = self.votes
model_dict['slug'] = self.slug
return model_dict

def save(self, *args, **kwargs):
self.slug = slugify(self.name)
models.Model.save(self, *args, **kwargs)

def __str__(self):
return str(self.name)

Expand Down
86 changes: 44 additions & 42 deletions network-api/networkapi/buyersguide/templates/bg_base.html
Expand Up @@ -3,6 +3,13 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:type" content="website" />
{% block og-title %}
<meta property="og:title" content="privacy not included" />
{% endblock %}
<meta property="og:description" content="This year, learn what tech comes with privacy included, using Mozilla's buyer's guide for connected gadgets." />
<meta property="og:image" content="{{request.scheme}}://{{request.get_host}}/_images/buyers-guide/share.jpg" />
<meta property="og:url" content="{{request.scheme}}://{{request.get_host}}{{request.path}}" />
<link rel="stylesheet" href="/_css/buyers-guide.compiled.css">
<link rel="stylesheet" href="//code.cdn.mozilla.net/fonts/fira.css">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Nunito+Sans:400,300,700,300i">
Expand All @@ -14,53 +21,48 @@
<title>Mozilla - *privacy not included</title>
</head>
<body class="pni" id="pni-{% block body-id %}{% endblock %}">
<header class="container">
<div class="d-flex align-items-center justify-content-between">
<div class="d-flex align-items-center py-3">
<a href="/" class="moz-logo mb-0 mr-3"><span class="sr-only">Mozilla</span></a>
<p class="mb-0 h4-heading">*privacy not&nbsp;included</p>
{% include "./primary_nav.html" %}
<div class="underneath-screen-overlay">
<div class="category-nav">
<div class="container">
<div class="row">
<div class="col">
<a class="nav-home" href="/privacynotincluded">Home</a>
{% for current in categories %}
<a class="nav{% if category %}
{% if category.name == current.name %}
active
{% endif %}
{% endif %}" href="/privacynotincluded/categories/{{ current.name }}">{{ current.name }}</a>
{% endfor %}
<a class="nav-about" href="/privacynotincluded/about">About the Guide</a>
</div>
</div>
</div>
<div class="social d-flex align-items-center">
<a class="social-button social-button-fb" href="#TODO"><span class="sr-only">Facebook</a></a>
<a class="social-button social-button-twitter" href="#TODO"><span class="sr-only">Twitter</a></a>
<a class="social-button social-button-email" href="#TODO"><span class="sr-only">Email</a></a>
<a class="d-none d-sm-block btn btn-blue ml-3" href="https://donate.mozilla.org">Donate</a>
</div>
</div>
</header>
<div class="primary-nav">
<div class="container">
<a class="nav-home" href="/privacynotincluded">Home</a>
{% for current in categories %}
<a class="nav{% if category %}
{% if category.name == current.name %}
active
{% endif %}
{% endif %}" href="/privacynotincluded/categories/{{ current.name }}">{{ current.name }}</a>
{% endfor %}
<a class="nav-about" href="/privacynotincluded/about">About the Guide</a>
</div>
</div>

<div class="pb-5">{% block guts %}{% endblock %}</div>
<div class="pb-5 main-content">{% block guts %}{% endblock %}</div>

<footer class="mofo-footer">
<div class="container">
<ul class="list-unstyled footer-links row justify-content-center">
<li class="col-auto"><a class="footer-link-email" href="mailto:network@mozillafoundation.org">Email</a></li>
<li class="col-auto"><a class="footer-link-twitter" href="https://twitter.com/mozilla">Twitter</a></li>
<li class="col-auto"><a class="footer-link-cc-license" href="https://creativecommons.org/licenses/by/4.0">License</a></li>
<li class="col-auto"><a class="footer-link-participation-guidelines" href="https://www.mozilla.org/about/governance/policies/participation/">Participation Guidelines</a></li>
<li class="col-auto"><a class="footer-link-legal" href="https://mozilla.org/en-US/about/legal/">Legal</a></li>
<li class="col-auto"><a class="footer-link-privacy" href="https://mozilla.org/en-US/privacy/websites/">Privacy</a></li>
<li class="col-auto"><a class="footer-link-donate" id="donate-footer-btn" href="https://donate.mozilla.org?utm_source=foundation.mozilla.org&amp;utm_medium=referral&amp;utm_content=footer" target="_blank" rel="noopener noreferrer">Donate</a></li>
</ul>
<div class="org-info mozilla">
<div class="logo-container"><a class="logo" href="https://mozilla.org"></a></div>
<p>Mozilla is a global non-profit dedicated to putting you in control of your online experience and shaping the future of the web for the public good. Visit us at <a href="https://mozilla.org">mozilla.org</a>.</p>
<footer class="mofo-footer">
<div class="container">
<ul class="list-unstyled footer-links row justify-content-center">
<li class="col-auto"><a class="footer-link-email" href="mailto:network@mozillafoundation.org">Email</a></li>
<li class="col-auto"><a class="footer-link-twitter" href="https://twitter.com/mozilla">Twitter</a></li>
<li class="col-auto"><a class="footer-link-cc-license" href="https://creativecommons.org/licenses/by/4.0">License</a></li>
<li class="col-auto"><a class="footer-link-participation-guidelines" href="https://www.mozilla.org/about/governance/policies/participation/">Participation Guidelines</a></li>
<li class="col-auto"><a class="footer-link-legal" href="https://mozilla.org/en-US/about/legal/">Legal</a></li>
<li class="col-auto"><a class="footer-link-privacy" href="https://mozilla.org/en-US/privacy/websites/">Privacy</a></li>
<li class="col-auto"><a class="footer-link-donate" id="donate-footer-btn" href="https://donate.mozilla.org?utm_source=foundation.mozilla.org&amp;utm_medium=referral&amp;utm_content=footer" target="_blank" rel="noopener noreferrer">Donate</a></li>
</ul>
<div class="org-info mozilla">
<div class="logo-container"><a class="logo" href="https://mozilla.org"></a></div>
<p>Mozilla is a global non-profit dedicated to putting you in control of your online experience and shaping the future of the web for the public good. Visit us at <a href="https://mozilla.org">mozilla.org</a>.</p>
</div>
</div>
</div>
</footer>
</footer>
</div>

<script src="/_js/bg-main.compiled.js" defer="defer"></script>
{% block extra_scripts %}{% endblock %}
</body>
</html>
46 changes: 41 additions & 5 deletions network-api/networkapi/buyersguide/templates/buyersguide_home.html
@@ -1,15 +1,51 @@
{% extends "./bg_base.html" %}

{% load env %}

{% block body-id %}home{% endblock %}

{% block guts %}
<div class="container-fluid text-center page-header bg-gray">
<!-- home banner as css background -->
</div>

<div class="container">
<h1>Buyer's guide homepage!</h1>
<div class="row">
<div class="product-listing bg-white col-12 col-md-10 offset-md-1">
<h1 class="h1-heading text-center mt-4">Shop Safe This Holiday Season</h1>

{% for product in products %}
<div><a href="./products/{{product.name | urlencode}}">{{product.name}}</a></div>
{% endfor %}
</div>
<div class="row px-5 mx-4">
<p class="col body-large text-center">
Teddy bears that connect to the internet.
Smart speakers that listen to commands.
Great gifts—unless they spy on you.
We created this guide to help you buy safe, secure products this holiday season.
</p>
</div>

<div class="creepiness-slider sticky-top bg-white text-center">
<span class="current-creepiness"></span>
</div>

<div class="d-flex justify-content-center align-items-stretch flex-wrap">
{% for product in products %}
<div class="product-box bg-gray" data-creepiness="{{ product.votes.creepiness.average }}">
{% if product.votes.confidence %}
{% if product.votes.confidence.1 > product.votes.confidence.0 %}
<div class="recommendation go-for-it m-2"></div>
{% else %}
<div class="recommendation stay-away m-2"></div>
{% endif %}
{% endif %}
<a class="" href="/privacynotincluded/products/{{ product.slug }}">
<div>
<img src="{{mediaUrl}}{{"AWS_LOCATION"|env}}/{{product.image }}">
</div>
</a>
</div>
{% endfor %}
</div>
</div>
</div>
</div>
{% endblock %}
Expand Up @@ -14,9 +14,9 @@ <h1 class="h3-heading">{{ category.name }}</h1>
<div class="categories-container">
{% for product in products %}
<div class="category-item-container" >
<a class="" href="/privacynotincluded/products/{{ product.name}}">
<a class="" href="/privacynotincluded/products/{{ product.slug }}">
<div class="category-image-container">
<img src="{{mediaUrl}}{{"AWS_LOCATION"|env}}/{{product.image }}">
<img src="{{ mediaUrl }}{{ "AWS_LOCATION" | env }}/{{ product.image }}">
</div>
<h3 class="mb-2 h6-heading-uppercase">{{ product.company }}</h3>
<h3 class="mb-5 h5-heading">{{ product.name }}</h3>
Expand Down

0 comments on commit a7d01f3

Please sign in to comment.