summaryrefslogtreecommitdiff
path: root/app/products
diff options
context:
space:
mode:
Diffstat (limited to 'app/products')
-rw-r--r--app/products/admin.py28
-rw-r--r--app/products/migrations/0001_initial.py36
-rw-r--r--app/products/migrations/0002_auto_20191008_0841.py29
-rw-r--r--app/products/migrations/0003_auto_20191008_0941.py30
-rw-r--r--app/products/migrations/0004_auto_20191109_0849.py23
-rw-r--r--app/products/migrations/0005_product_featured_image.py19
-rw-r--r--app/products/migrations/0006_remove_product_image.py17
-rw-r--r--app/products/migrations/__init__.py0
-rw-r--r--app/products/models.py92
-rw-r--r--app/products/static/product-loader.js10
-rw-r--r--app/products/templates/products/snippet.html41
-rw-r--r--app/products/views.py15
12 files changed, 0 insertions, 340 deletions
diff --git a/app/products/admin.py b/app/products/admin.py
deleted file mode 100644
index 3a26358..0000000
--- a/app/products/admin.py
+++ /dev/null
@@ -1,28 +0,0 @@
-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 = ('image-loader.js', 'next-prev-links.js')
- css = {
- "all": ("my_styles.css",)
- }
-
-
-@admin.register(Brand)
-class BrandAdmin(admin.ModelAdmin):
- list_display = ('name', )
- search_fields = ['name',]
- list_filter = ('pub_date',)
-
- class Media:
- js = ('next-prev-links.js',)
diff --git a/app/products/migrations/0001_initial.py b/app/products/migrations/0001_initial.py
deleted file mode 100644
index eb2a822..0000000
--- a/app/products/migrations/0001_initial.py
+++ /dev/null
@@ -1,36 +0,0 @@
-# Generated by Django 2.2.6 on 2019-10-08 07:46
-
-from django.db import migrations, models
-import products.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(max_length=200)),
- ('slug', models.CharField(max_length=50)),
- ('pub_date', models.DateTimeField()),
- ('body_markdown', models.TextField(blank=True)),
- ('body_html', models.TextField(blank=True, null=True)),
- ('primary_offer_url', models.CharField(max_length=400)),
- ('primary_offer_price', models.IntegerField()),
- ('secondary_offer_url', models.CharField(blank=True, max_length=400, null=True)),
- ('secondar_offer_price', models.IntegerField(blank=True, null=True)),
- ('rating', models.IntegerField()),
- ('is_public', models.BooleanField(default=True)),
- ('image', models.FileField(blank=True, null=True, upload_to=products.models.get_upload_path)),
- ],
- options={
- 'ordering': ('-pub_date',),
- },
- ),
- ]
diff --git a/app/products/migrations/0002_auto_20191008_0841.py b/app/products/migrations/0002_auto_20191008_0841.py
deleted file mode 100644
index 11b2d59..0000000
--- a/app/products/migrations/0002_auto_20191008_0841.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# Generated by Django 2.2.6 on 2019-10-08 08:41
-
-from django.db import migrations, models
-import django.db.models.deletion
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('products', '0001_initial'),
- ]
-
- operations = [
- migrations.CreateModel(
- name='Brand',
- fields=[
- ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
- ('name', models.CharField(max_length=200)),
- ('slug', models.CharField(max_length=50)),
- ('pub_date', models.DateTimeField(auto_now_add=True)),
- ],
- ),
- migrations.AddField(
- model_name='product',
- name='brand',
- field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='products.Brand'),
- preserve_default=False,
- ),
- ]
diff --git a/app/products/migrations/0003_auto_20191008_0941.py b/app/products/migrations/0003_auto_20191008_0941.py
deleted file mode 100644
index 085fd32..0000000
--- a/app/products/migrations/0003_auto_20191008_0941.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# Generated by Django 2.2.6 on 2019-10-08 09:41
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('products', '0002_auto_20191008_0841'),
- ]
-
- operations = [
- migrations.RenameField(
- model_name='product',
- old_name='secondar_offer_price',
- new_name='secondary_offer_price',
- ),
- migrations.AddField(
- model_name='product',
- name='primary_offer_retailer',
- field=models.CharField(default='Amazon', max_length=400),
- preserve_default=False,
- ),
- migrations.AddField(
- model_name='product',
- name='secondary_offer_retailer',
- field=models.CharField(default='Amazon', max_length=400),
- preserve_default=False,
- ),
- ]
diff --git a/app/products/migrations/0004_auto_20191109_0849.py b/app/products/migrations/0004_auto_20191109_0849.py
deleted file mode 100644
index 1666a56..0000000
--- a/app/products/migrations/0004_auto_20191109_0849.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# 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
deleted file mode 100644
index 032bbfa..0000000
--- a/app/products/migrations/0005_product_featured_image.py
+++ /dev/null
@@ -1,19 +0,0 @@
-# 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 = [
- ('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='media.LuxImage'),
- ),
- ]
diff --git a/app/products/migrations/0006_remove_product_image.py b/app/products/migrations/0006_remove_product_image.py
deleted file mode 100644
index b05110d..0000000
--- a/app/products/migrations/0006_remove_product_image.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# 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/migrations/__init__.py b/app/products/migrations/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/app/products/migrations/__init__.py
+++ /dev/null
diff --git a/app/products/models.py b/app/products/models.py
deleted file mode 100644
index 4b7dbec..0000000
--- a/app/products/models.py
+++ /dev/null
@@ -1,92 +0,0 @@
-import os
-from PIL import Image
-from django.db import models
-from django.db.models.signals import post_save
-from django.contrib.sitemaps import Sitemap
-from django.dispatch import receiver
-from django.urls import reverse
-from django.apps import apps
-from django.utils.html import format_html
-from django.conf import settings
-from django.template.defaultfilters import slugify
-
-from media.models import LuxImage, LuxImageSize
-from media.utils import resize_image
-from utils.util import render_images, render_products, parse_video, markdown_to_html
-
-
-def get_upload_path(self, filename):
- return "images/products/%s" % (filename)
-
-class Brand(models.Model):
- name = models.CharField(max_length=200)
- slug = models.CharField(max_length=50)
- pub_date = models.DateTimeField(auto_now_add=True)
-
- def __str__(self):
- return self.name
-
-class Product(models.Model):
- name = models.CharField(max_length=200)
- brand = models.ForeignKey(Brand, on_delete=models.CASCADE)
- slug = models.CharField(max_length=50)
- pub_date = models.DateTimeField()
- body_markdown = models.TextField(blank=True)
- body_html = models.TextField(null=True, blank=True)
- 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.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)
- featured_image = models.ForeignKey(LuxImage, on_delete=models.CASCADE, null=True, blank=True)
-
- class Meta:
- ordering = ('-pub_date',)
-
- def __str__(self):
- return self.name
-
- @property
- def get_previous_admin_url(self):
- n = self.get_previous_by_read_date()
- return reverse('admin:%s_%s_change' % (self._meta.app_label, self._meta.model_name), args=[n.id])
-
- @property
- def get_next_admin_url(self):
- model = apps.get_model(app_label=self._meta.app_label, model_name=self._meta.model_name)
- try:
- return reverse('admin:%s_%s_change' % (self._meta.app_label, self._meta.model_name), args=[self.get_next_by_read_date().pk])
- except model.DoesNotExist:
- return ''
-
- def admin_thumbnail(self):
- return format_html('<img src="%s" width="100" style="width:100px" />' % (self.featured_image.get_thumbnail_url()))
- admin_thumbnail.short_description = 'Thumbnail'
-
- def get_full_name(self):
- return "%s %s" % (self.brand.name, self.name)
-
- def save(self, *args, **kwargs):
- md = render_images(self.body_markdown)
- prods = render_products(md)
- self.body_html = markdown_to_html(prods)
- super(Product, self).save()
-
-
-@receiver(post_save, sender=Product)
-def post_save_events(sender, update_fields, created, instance, **kwargs):
- #base_path = "%s/%s/" % (settings.MEDIA_ROOT, "/".join(str(i) for i in instance.image.name.split('/')[:-1]))
- #filename, file_extension = os.path.splitext(instance.image.path)
- #img = Image.open(instance.image.path)
- #resize_image(img, None, 160, 78, base_path, "%s_tn%s" % (filename.split('/')[-1], file_extension))
- #resize_image(img, None, 650, 78, base_path, "%s_small%s" % (filename.split('/')[-1], file_extension))
- pass
-
diff --git a/app/products/static/product-loader.js b/app/products/static/product-loader.js
deleted file mode 100644
index 6d04b61..0000000
--- a/app/products/static/product-loader.js
+++ /dev/null
@@ -1,10 +0,0 @@
-function add_products(){
- var el = document.getElementById("images_frame");
- if (el){
- var iframe='<iframe frameborder="0" style="border: #dddddd 1px solid;margin-left: 20px;width:330px; height:720px;" src="/luxproduct/insert/?textarea='+el.id+'"></iframe>';
- el.insertAdjacentHTML('afterend', iframe);
- }
-}
-document.addEventListener("DOMContentLoaded", function(event) {
- add_products();
-});
diff --git a/app/products/templates/products/snippet.html b/app/products/templates/products/snippet.html
deleted file mode 100644
index 3fc9f6f..0000000
--- a/app/products/templates/products/snippet.html
+++ /dev/null
@@ -1,41 +0,0 @@
-{% load get_image_by_size %}
-{% load get_image_width %}
-{% with image=object.featured_image %}
-<div itemscope itemtype="http://schema.org/Product" class="product-card">
- <meta itemprop="brand" content="{{object.brand.name}}" />
- <figure itemscope itemtype="http://schema.org/ImageObject" class="picfull">
- <a href="{% get_image_by_size image 'original' %}" title="view larger image">
- <img class="u-photo" itemprop="contentUrl" sizes="(max-width: 750px) 100vw, (min-width: 751) 750px" srcset="{% for size in image.sizes.all%}{% get_image_by_size image size.name %} {{size.width}}w{% if forloop.last%}"{%else%}, {%endif%}{%endfor%}{% for size in image.sizes.all%}{%if not forloop.first and not forloop.last%} src="{% get_image_by_size image size.name%}"{%endif%}{%endfor%} alt="{{image.alt}} photographed by {% if image.photo_credit_source %}{{image.photo_credit_source}}{%else%}luxagraf{%endif%}" >
- </a>
- <figcaption>{% if image.caption %}{{image.caption|safe}}{% endif %}{% if image.photo_credit_source %}{%if image.caption %} | {%endif%}image: {% if image.photo_credit_url %}<a href="{{image.photo_credit_url}}" itemprop="author">{%endif%}{{image.photo_credit_source|lower}}{% if image.photo_credit_url %}</a>{%endif%}{%endif%}
- </figcaption>
- </figure>
- <div class="buy-btn-wrapper">
- <h4 class="product-header" itemprop="name">{{object.get_full_name}}</h4>
- <h5 class="product-link" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
- <a href="{{object.primary_offer_url}}" title="buy the {{object.get_full_name}} for ${{object.primary_offer_price}} from {{object.primary_offer_retailer.get_primary_offer_retailer_display}}" itemprop="url" rel="nofollow">
- Buy Now ({{object.get_primary_offer_retailer_display}}
- <span itemprop="priceCurrency" content="USD">$</span><span itemprop="price" content="{{object.primary_offer_price}}">{{object.primary_offer_price}}</span>)
- </a>
- <link itemprop="availability" href="http://schema.org/InStock" />
- </h5>{% if object.secondary_offer_url %}
- <h5 class="product-link" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
- <a href="{{object.secondary_offer_url}}" title="buy the {{object.get_full_name}} for ${{object.secondary_offer_price}} from {{object.secondary_offer_retailer.get_secondary_offer_retailer_display}}" itemprop="url">
- Buy Now ({{object.get_secondary_offer_retailer_display}}
- <span itemprop="priceCurrency" content="USD">$</span><span itemprop="price" content="{{object.secondary_offer_price}}">{{object.secondary_offer_price}}</span>)
- </a>
- <link itemprop="availability" href="http://schema.org/InStock" />
- </h5>{% endif %}
- </div>
- <span itemprop="review" itemscope itemtype="http://schema.org/Review">
- <meta itemprop="name" content="{{object.get_full_name}}" />
- <meta itemprop="author" content="Scott Gilbertson" />
- <meta itemprop="datePublished" content="{{object.pub_date}}" />
- <span itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
- <meta itemprop="worstRating" content = "1"/>
- <meta itemprop="ratingValue" content="{{object.rating}}" />
- <meta itemprop="bestRating" content="10" />
- </span>
- <meta itemprop="description" content="{{object.body_markdown}}" />
-</div>
-{% endwith %}
diff --git a/app/products/views.py b/app/products/views.py
deleted file mode 100644
index 30be542..0000000
--- a/app/products/views.py
+++ /dev/null
@@ -1,15 +0,0 @@
-from django.shortcuts import render
-from .models import Product
-
-
-def insert_products(request):
- """
- The view that handles the admin insert products feature
- """
- object_list = Product.objects.all()
- #object_list = sorted(
- # chain(images, videos, audio),
- # key=lambda instance: instance.pub_date,
- # reverse=True
- #)
- return render(request, 'admin/insert_products.html', {'object_list': object_list, 'textarea_id': request.GET['textarea']})