from django.contrib import admin
-from cartridge.shop.models import Product, ProductVariation
+from cartridge.shop.models import Product, ProductImage, ProductVariation
from cartridge.shop.admin import ProductAdmin, ProductImageAdmin, ProductVariationAdmin
# Register your models here.
class RecordInline(admin.StackedInline):
model = Record
extra = 0
+ max_num = 0
class RecordProductAdmin(ProductAdmin):
inlines = [ProductImageAdmin, ProductVariationAdmin, RecordInline]
+class RecordAdmin(admin.ModelAdmin):
+ search_fields = ["title", "artist__name", "label__name"]
+
admin.site.unregister(Product)
admin.site.register(Product, RecordProductAdmin)
admin.site.register(Artist)
admin.site.register(Label)
admin.site.register(Country)
-admin.site.register(Record)
+admin.site.register(Record, RecordAdmin)
admin.site.register(Podcast)
admin.site.register(ConditionGrading)
def populate_category(self):
#
shop_cat, created = Category.objects.get_or_create(title="Shop")
-
+
theme_list = [theme for theme in rec_models.Theme.objects.all() if theme.published==1]
count = 0
IMG_PATH = os.path.join('uploads/product')
shop_list = rec_models.Shop.objects.all()
-
+ DOUBLONS_TO_SKIP = [2734, 1006, 1393]
+
for shop in shop_list:
+ if shop.id in DOUBLONS_TO_SKIP:
+ continue
obj, created = rec_models.Record.objects.get_or_create(pk=shop.id)
obj.title = parser.unescape(shop.titre)
--- /dev/null
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('shop', '0003_auto_20150906_1911'),
+ ('records', '0006_auto_20150907_0835'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='record',
+ name='image',
+ field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, verbose_name='Image', blank=True, to='shop.ProductImage', null=True),
+ ),
+ ]
--- /dev/null
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('records', '0007_record_image'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='record',
+ name='performers',
+ field=models.ManyToManyField(related_name='records_performers', verbose_name='performers', to='records.Artist', blank=True),
+ ),
+ migrations.AlterField(
+ model_name='record',
+ name='product',
+ field=models.OneToOneField(related_name='record', null=True, on_delete=django.db.models.deletion.SET_NULL, verbose_name='product', to='shop.Product'),
+ ),
+ ]
--- /dev/null
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('records', '0008_auto_20150909_0818'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='record',
+ name='image',
+ ),
+ ]
from mezzanine.blog.models import BlogPost
from mezzanine.utils.models import upload_to
-from cartridge.shop.models import Product, ProductVariation
+from cartridge.shop.models import Product
# Auto-generated Django models with manage.py inspectdb on the old database
title = models.CharField(max_length=128)
artist = models.ForeignKey(Artist, verbose_name=_('artist'), related_name='records_artists', null=True, on_delete=models.SET_NULL)
- performers = models.ManyToManyField(Artist, verbose_name=_('performers'), related_name='records_performers')
+ performers = models.ManyToManyField(Artist, verbose_name=_('performers'), related_name='records_performers', blank=True)
record_status = models.IntegerField(_('record status'), choices=NOVELTY_CHOICES, default=NEW)
label = models.ForeignKey(Label, verbose_name=_('label'), related_name='records', null=True, on_delete=models.SET_NULL)
release_year = models.IntegerField(_('release year'), null=True, choices=YEAR_CHOICES)
vinyl_condition = models.ForeignKey(ConditionGrading, verbose_name=_('vinyl condition'), related_name='records_vinyl_condition', null=True, on_delete=models.SET_NULL)
audio_file = FileField(_("audio file"), max_length=1024, format="audio",
upload_to=upload_to("records.Record.audio", "audio/records"), null=True)
- product = models.ForeignKey(Product, verbose_name=_('product'), related_name='records', null=True, on_delete=models.SET_NULL)
+ product = models.OneToOneField(Product, verbose_name=_('product'), related_name='record', null=True, on_delete=models.SET_NULL)
def __unicode__(self):
return " - ".join([self.artist.name, self.title])
<h4>{{ category.title }}</h4>
</div>
</a>
- </div>
+ </div>
{% endfor %}
{% else %}
{% for category in child_categories %}
<ul>
- <li><strong>{{ product.records.first.artist }}</strong></li>
- <li><em>{{ product.records.first.title }}</em></li>
+ <li><strong>{{ product.record.artist }}</strong></li>
+ <li><em>{{ product.record.title }}</em></li>
<li>
{% trans "Label:" %}
- {{ product.records.first.label }}
+ {{ product.record.label }}
</li>
<li>
{% trans "Country:" %}
- {{ product.records.first.country }}
+ {{ product.record.country }}
</li>
- {% if product.records.first.release_year %}
+ {% if product.record.release_year %}
<li>
{% trans "Release year:" %}
- {{ product.records.first.release_year }}
+ {{ product.record.release_year }}
</li>
{% else %}
<li>
{% trans "Release decade:" %}
- {{ product.records.first.release_decade }}</li>
+ {{ product.record.release_decade }}</li>
{% endif %}
<li>
{% trans "Cover:" %}
<a class="badge" tabindex="0" role="button" data-toggle="popover" data-trigger="hover focus"
- title="{{ product.records.first.cover_condition.name }}"
- data-content="{{ product.records.first.cover_condition.description }}">
- {{ product.records.first.cover_condition.abbr }}
+ title="{{ product.record.cover_condition.name }}"
+ data-content="{{ product.record.cover_condition.description }}">
+ {{ product.record.cover_condition.abbr }}
</a>
</li>
<li>
{% trans " Vinyl:" %}
<a class="badge" tabindex="0" role="button" data-toggle="popover" data-trigger="hover focus"
- title="{{ product.records.first.vinyl_condition.name }}"
- data-content="{{ product.records.first.cover_condition.description }}">
- {{ product.records.first.vinyl_condition.abbr }}
+ title="{{ product.record.vinyl_condition.name }}"
+ data-content="{{ product.record.cover_condition.description }}">
+ {{ product.record.vinyl_condition.abbr }}
</a>
</li>
</ul>
-
+{% if product.record.audio_file %}
+<audio controls>
+ <source src="{{ MEDIA_URL }}{{ product.record.audio_file }}">
+</audio>
+{% endif %}
{% editable product.content %}
{{ product.content|richtext_filters|safe }}