From 6bccb82f7751d8c126f0342ccc97ff5311fa2ed6 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Sat, 9 Nov 2019 20:01:48 -0500 Subject: finished up product insert template --- app/products/admin.py | 8 +++- app/products/migrations/0004_auto_20191109_0849.py | 23 ++++++++++ .../migrations/0005_product_featured_image.py | 20 ++++++++ .../migrations/0006_remove_product_image.py | 17 +++++++ app/products/models.py | 12 +++-- app/products/templates/products/snippet.html | 53 ++++++++++++++-------- design/sass/_details.scss | 35 ++++++++++++-- 7 files changed, 141 insertions(+), 27 deletions(-) create mode 100644 app/products/migrations/0004_auto_20191109_0849.py create mode 100644 app/products/migrations/0005_product_featured_image.py create mode 100644 app/products/migrations/0006_remove_product_image.py diff --git a/app/products/admin.py b/app/products/admin.py index d8059f2..3a26358 100644 --- a/app/products/admin.py +++ b/app/products/admin.py @@ -1,15 +1,21 @@ from django.contrib import admin + from .models import Brand, Product +from utils.widgets import AdminImageWidget, LGEntryForm @admin.register(Product) class ProductAdmin(admin.ModelAdmin): + form = LGEntryForm list_display = ('name', 'admin_thumbnail', 'rating', 'pub_date') search_fields = ['name', 'body_markdown'] list_filter = ('rating', 'pub_date') class Media: - js = ('next-prev-links.js',) + js = ('image-loader.js', 'next-prev-links.js') + css = { + "all": ("my_styles.css",) + } @admin.register(Brand) diff --git a/app/products/migrations/0004_auto_20191109_0849.py b/app/products/migrations/0004_auto_20191109_0849.py new file mode 100644 index 0000000..1666a56 --- /dev/null +++ b/app/products/migrations/0004_auto_20191109_0849.py @@ -0,0 +1,23 @@ +# Generated by Django 2.2.6 on 2019-11-09 08:49 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('products', '0003_auto_20191008_0941'), + ] + + operations = [ + migrations.AlterField( + model_name='product', + name='primary_offer_retailer', + field=models.IntegerField(choices=[(0, 'Amazon'), (1, 'REI'), (2, 'eBay')], default=0), + ), + migrations.AlterField( + model_name='product', + name='secondary_offer_retailer', + field=models.IntegerField(choices=[(0, 'Amazon'), (1, 'REI'), (2, 'eBay')], default=0), + ), + ] diff --git a/app/products/migrations/0005_product_featured_image.py b/app/products/migrations/0005_product_featured_image.py new file mode 100644 index 0000000..91e37b0 --- /dev/null +++ b/app/products/migrations/0005_product_featured_image.py @@ -0,0 +1,20 @@ +# Generated by Django 2.2.6 on 2019-11-09 09:35 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('photos', '0019_auto_20190704_0903'), + ('products', '0004_auto_20191109_0849'), + ] + + operations = [ + migrations.AddField( + model_name='product', + name='featured_image', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='photos.LuxImage'), + ), + ] diff --git a/app/products/migrations/0006_remove_product_image.py b/app/products/migrations/0006_remove_product_image.py new file mode 100644 index 0000000..b05110d --- /dev/null +++ b/app/products/migrations/0006_remove_product_image.py @@ -0,0 +1,17 @@ +# Generated by Django 2.2.6 on 2019-11-09 09:47 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('products', '0005_product_featured_image'), + ] + + operations = [ + migrations.RemoveField( + model_name='product', + name='image', + ), + ] diff --git a/app/products/models.py b/app/products/models.py index bf33db4..d4dd5a8 100644 --- a/app/products/models.py +++ b/app/products/models.py @@ -10,6 +10,7 @@ from django.utils.html import format_html from django.conf import settings from django.template.defaultfilters import slugify +from photos.models import PhotoGallery, LuxImage, LuxImageSize from photos.utils import resize_image from utils.util import render_images, render_products, parse_video, markdown_to_html @@ -32,15 +33,20 @@ class Product(models.Model): pub_date = models.DateTimeField() body_markdown = models.TextField(blank=True) body_html = models.TextField(null=True, blank=True) - primary_offer_retailer = models.CharField(max_length=400) + RETAILER = ( + (0, 'Amazon'), + (1, 'REI'), + (2, 'eBay'), + ) + primary_offer_retailer = models.IntegerField(choices=RETAILER, default=0) primary_offer_url = models.CharField(max_length=400) primary_offer_price = models.IntegerField() - secondary_offer_retailer = models.CharField(max_length=400) + secondary_offer_retailer = models.IntegerField(choices=RETAILER, default=0) secondary_offer_url = models.CharField(max_length=400, blank=True, null=True) secondary_offer_price = models.IntegerField(blank=True, null=True) rating = models.IntegerField() is_public = models.BooleanField(default=True) - image = models.FileField(upload_to=get_upload_path, null=True, blank=True) + featured_image = models.ForeignKey(LuxImage, on_delete=models.CASCADE, null=True, blank=True) class Meta: ordering = ('-pub_date',) diff --git a/app/products/templates/products/snippet.html b/app/products/templates/products/snippet.html index be5d874..3fc9f6f 100644 --- a/app/products/templates/products/snippet.html +++ b/app/products/templates/products/snippet.html @@ -1,26 +1,41 @@ -
+{% load get_image_by_size %} +{% load get_image_width %} +{% with image=object.featured_image %} +
- -
- - - - +
+ + {{image.alt}} photographed by {% if image.photo_credit_source %}{{image.photo_credit_source}}{%else%}luxagraf{%endif%} + +
{% if image.caption %}{{image.caption|safe}}{% endif %}{% if image.photo_credit_source %}{%if image.caption %} | {%endif%}image: {% if image.photo_credit_url %}{%endif%}{%endif%} +
+
+ + + + + + -
+{% endwith %} diff --git a/design/sass/_details.scss b/design/sass/_details.scss index 5f5ebdc..83651ca 100644 --- a/design/sass/_details.scss +++ b/design/sass/_details.scss @@ -213,14 +213,41 @@ h4.post-source { padding-left: 3px; } //### GUIDE STUFF ### +.product-card { + margin: 5rem 0; +} .detail .product-link { - margin: 2rem 0 1rem 0; - letter-spacing: -0.02rem; + a { + display: block; + padding: 1rem; + background: #249bd6; + color: white; + text-transform: uppercase; + font-size: 16px; + text-decoration: none; + } +} +.buy-btn-wrapper { + margin-top: 4rem; + display: flex; + justify-content: center; + align-items: center; + align-content: space-between; + h4 { + margin: 0 1.5rem 0 0; + line-height: normal; + &:after { + content: ":"; + } + } + h5 { + margin-right: 1rem; + } } .detail .post-guide { h3 { - @include fontsize(24); - margin: 4rem 0 .25rem 0; + @include fontsize(27); + margin: 4rem 0 .5rem 0; & + p { margin-top: 0; } -- cgit v1.2.3