Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into pjbummmmmp
- Loading branch information
Showing
34 changed files
with
473 additions
and
323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
release: cd network-api && python ./manage.py migrate --no-input | ||
release: cd network-api && python ./manage.py migrate --no-input && python ./manage.py block_inventory | ||
web: cd network-api && gunicorn networkapi.wsgi:application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from wagtail.contrib.modeladmin.options import ( | ||
ModelAdmin, modeladmin_register) | ||
from networkapi.buyersguide.models import Product | ||
|
||
|
||
# Wagtail admin | ||
class WagtailBuyersGuideAdmin(ModelAdmin): | ||
model = Product | ||
menu_label = 'Buyer\'s Guide' | ||
menu_icon = 'pick' # change as required | ||
menu_order = 600 # will put in 3rd place (000 being 1st, 100 2nd) | ||
add_to_settings_menu = False # or True to add your model to the Settings sub-menu | ||
exclude_from_explorer = False # or True to exclude pages of this type from Wagtail's explorer view | ||
list_display = ('name', 'company', 'url',) | ||
search_fields = ('name', 'company') | ||
|
||
|
||
modeladmin_register(WagtailBuyersGuideAdmin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class BuyersguideConfig(AppConfig): | ||
name = 'buyersguide' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import random | ||
|
||
from factory import ( | ||
DjangoModelFactory, | ||
Faker, | ||
post_generation, | ||
LazyAttribute, | ||
) | ||
|
||
from networkapi.utility.faker_providers import ImageProvider | ||
from networkapi.buyersguide.models import Product | ||
|
||
Faker.add_provider(ImageProvider) | ||
|
||
|
||
class ProductFactory(DjangoModelFactory): | ||
|
||
class Meta: | ||
model = Product | ||
exclude = ( | ||
'product_words' | ||
) | ||
|
||
product_words = Faker('words', nb=2) | ||
|
||
name = LazyAttribute(lambda o: ' '.join(o.product_words)) | ||
company = Faker('company') | ||
blurb = Faker('sentence') | ||
url = Faker('url') | ||
price = random.randint(49, 1500) | ||
camera = Faker('boolean') | ||
microphone = Faker('boolean') | ||
location = Faker('boolean') | ||
need_account = Faker('boolean') | ||
privacy_controls = Faker('boolean') | ||
delete_data = Faker('boolean') | ||
share_data = Faker('boolean') | ||
child_rules = Faker('boolean') | ||
privacy_policy = Faker('url') | ||
worst_case = Faker('sentence') | ||
|
||
@post_generation | ||
def set_image(self, create, extracted, **kwargs): | ||
self.image.name = Faker('generic_image').generate({}) |
39 changes: 39 additions & 0 deletions
39
network-api/networkapi/buyersguide/migrations/0001_initial.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.13 on 2018-07-27 21:07 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
import networkapi.buyersguide.models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Product', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(blank='True', help_text='Name of Product', max_length=100)), | ||
('company', models.CharField(blank='True', help_text='Name of Company', max_length=100)), | ||
('blurb', models.TextField(blank='True', help_text='Description of the product', max_length=5000)), | ||
('url', models.URLField(blank='True', help_text='Link to this product page', max_length=2048)), | ||
('price', models.CharField(blank='True', help_text='Price range', max_length=100)), | ||
('image', models.FileField(blank=True, help_text='Image representing this prodct', max_length=2048, upload_to=networkapi.buyersguide.models.get_product_image_upload_path)), | ||
('camera', models.NullBooleanField(help_text='Does this product have or access a camera?')), | ||
('microphone', models.NullBooleanField(help_text='Does this product have or access a microphone?')), | ||
('location', models.NullBooleanField(help_text='Does this product access your location?')), | ||
('need_account', models.NullBooleanField(help_text='Do you need an account to use this product?')), | ||
('privacy_controls', models.NullBooleanField(help_text='Do users have access to privacy controls?')), | ||
('delete_data', models.NullBooleanField(help_text='Can you request data be deleted?')), | ||
('share_data', models.NullBooleanField(help_text='Does the maker share data with other companies?')), | ||
('child_rules', models.NullBooleanField(help_text='Are there rules for children?')), | ||
('privacy_policy', models.URLField(blank='True', help_text='Link to privacy policy for this product', max_length=2048)), | ||
('worst_case', models.CharField(blank='True', help_text="What's the worst thing that could happen by using this product?", max_length=5000)), | ||
], | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
from django.db import models | ||
from networkapi.utility.images import get_image_upload_path | ||
# from wagtail.snippets.models import register_snippet | ||
|
||
|
||
def get_product_image_upload_path(instance, filename): | ||
return get_image_upload_path( | ||
app_name='buyersguide', | ||
prop_name='name', | ||
instance=instance, | ||
current_filename=filename | ||
) | ||
|
||
|
||
class Product(models.Model): | ||
""" | ||
A thing you can buy in stores and our review of it | ||
""" | ||
|
||
name = models.CharField( | ||
max_length=100, | ||
help_text='Name of Product', | ||
blank="True", | ||
) | ||
company = models.CharField( | ||
max_length=100, | ||
help_text='Name of Company', | ||
blank="True", | ||
) | ||
|
||
blurb = models.TextField( | ||
max_length=5000, | ||
help_text='Description of the product', | ||
blank="True" | ||
) | ||
url = models.URLField( | ||
max_length=2048, | ||
help_text='Link to this product page', | ||
blank="True", | ||
) | ||
price = models.CharField( | ||
max_length=100, | ||
help_text='Price range', | ||
blank="True", | ||
) | ||
image = models.FileField( | ||
max_length=2048, | ||
help_text='Image representing this prodct', | ||
upload_to=get_product_image_upload_path, | ||
blank=True, | ||
) | ||
camera = models.NullBooleanField( | ||
help_text='Does this product have or access a camera?', | ||
) | ||
microphone = models.NullBooleanField( | ||
help_text='Does this product have or access a microphone?', | ||
) | ||
location = models.NullBooleanField( | ||
help_text='Does this product access your location?', | ||
) | ||
need_account = models.NullBooleanField( | ||
help_text='Do you need an account to use this product?', | ||
) | ||
privacy_controls = models.NullBooleanField( | ||
help_text='Do users have access to privacy controls?', | ||
) | ||
delete_data = models.NullBooleanField( | ||
help_text='Can you request data be deleted?', | ||
) | ||
share_data = models.NullBooleanField( | ||
help_text='Does the maker share data with other companies?', | ||
) | ||
child_rules = models.NullBooleanField( | ||
help_text='Are there rules for children?', | ||
) | ||
privacy_policy = models.URLField( | ||
help_text='Link to privacy policy for this product', | ||
max_length=2048, | ||
blank="True", | ||
) | ||
worst_case = models.CharField( | ||
max_length=5000, | ||
help_text="What's the worst thing that could happen by using this product?", | ||
blank="True", | ||
) | ||
|
||
# objects = HighlightQuerySet.as_manager() | ||
|
||
def __str__(self): | ||
return str(self.name) |
5 changes: 5 additions & 0 deletions
5
network-api/networkapi/buyersguide/templates/buyersguide_home.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Buyer's guide homepage! | ||
|
||
{% for product in products %} | ||
<div><a href="{{product.name | urlencode}}">{{product.name}}</a></div> | ||
{% endfor %} |
19 changes: 19 additions & 0 deletions
19
network-api/networkapi/buyersguide/templates/product_page.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<h2>{{product.name}}</h2> | ||
|
||
<img src="{{mediaUrl}}{{product.image}}" width="500"/> | ||
<div> | ||
{{product.company}} | ||
</div> | ||
<div>{{product.blurb}}</div> | ||
<div>{{product.url}}</div> | ||
<div>{{product.price}}</div> | ||
<div>Camera: {{product.camera}}</div> | ||
<div>Microphone: {{product.microphone}}</div> | ||
<div>Location: {{product.location}}</div> | ||
<div>Need account: {{product.need_account}}</div> | ||
<div>Privacy Controls: {{product.privacy_controls}}</div> | ||
<div>Delete Data: {{product.delete_data}}</div> | ||
<div>Share Data: {{product.share_data}}</div> | ||
<div>Child rules: {{product.child_rules}}</div> | ||
<div>Privacy Policy: {{product.privacy_policy}}</div> | ||
<div>Worst case scenario: {{product.worst_case}}</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.conf.urls import url | ||
from networkapi.buyersguide import views | ||
|
||
|
||
urlpatterns = [ | ||
url(r'^$', views.buyersguide_home, name='buyersguide-home'), | ||
url(r'^(?P<productname>[\w\ ]+)/', views.product_view, name='product-view'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from django.shortcuts import render | ||
from networkapi.buyersguide.models import Product | ||
from django.contrib.auth.decorators import login_required | ||
from django.conf import settings | ||
|
||
|
||
# Login required so we can continue to develop this and merge into master without the public seeing it. | ||
# Remove this when we're ready to launch. | ||
@login_required | ||
def buyersguide_home(request): | ||
products = Product.objects.all() | ||
return render(request, 'buyersguide_home.html', {'products': products}) | ||
|
||
|
||
@login_required | ||
def product_view(request, productname): | ||
product = Product.objects.get(name__iexact=productname) | ||
return render(request, 'product_page.html', {'product': product, 'mediaUrl': settings.MEDIA_URL}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.