intermediate commit
This commit is contained in:
parent
78a8a5d699
commit
d1113364a9
|
|
@ -1,7 +1,7 @@
|
|||
"""Product admin conf."""
|
||||
from django.contrib import admin
|
||||
from utils.admin import BaseModelAdminMixin
|
||||
from .models import Product, ProductType, ProductSubType
|
||||
from .models import Product, ProductType, ProductSubType, Unit, Characteristic
|
||||
|
||||
|
||||
@admin.register(Product)
|
||||
|
|
@ -17,3 +17,13 @@ class ProductTypeAdmin(admin.ModelAdmin):
|
|||
@admin.register(ProductSubType)
|
||||
class ProductSubTypeAdmin(admin.ModelAdmin):
|
||||
"""Admin page for model ProductSubType."""
|
||||
|
||||
|
||||
@admin.register(Unit)
|
||||
class UnitAdmin(admin.ModelAdmin):
|
||||
"""Admin page for model Unit."""
|
||||
|
||||
|
||||
@admin.register(Characteristic)
|
||||
class CharacteristicAdmin(admin.ModelAdmin):
|
||||
"""Admin page for model Characteristic."""
|
||||
|
|
|
|||
|
|
@ -138,7 +138,8 @@ class Product(TranslatedFieldsMixin, BaseAttributes):
|
|||
verbose_name=_('name'))
|
||||
description = TJSONField(_('Description'), null=True, blank=True,
|
||||
default=None, help_text='{"en-GB":"some text"}')
|
||||
characteristics = JSONField(_('Characteristics'))
|
||||
characteristics = models.ManyToManyField('Characteristic',
|
||||
verbose_name=_('characteristics'))
|
||||
country = models.ManyToManyField('location.Country',
|
||||
verbose_name=_('Country'))
|
||||
available = models.BooleanField(_('Available'), default=True)
|
||||
|
|
@ -163,8 +164,6 @@ class Product(TranslatedFieldsMixin, BaseAttributes):
|
|||
wine_village = models.ForeignKey('location.WineVillage', on_delete=models.PROTECT,
|
||||
blank=True, null=True,
|
||||
verbose_name=_('wine appellation'))
|
||||
bottles_produced = models.IntegerField(blank=True, null=True,
|
||||
verbose_name=_('bottles produced'))
|
||||
slug = models.SlugField(unique=True, max_length=255, null=True,
|
||||
verbose_name=_('Establishment slug'))
|
||||
favorites = generic.GenericRelation(to='favorites.Favorites')
|
||||
|
|
@ -213,6 +212,23 @@ class OnlineProduct(Product):
|
|||
verbose_name_plural = _('Online products')
|
||||
|
||||
|
||||
class Unit(models.Model):
|
||||
"""Product unit model."""
|
||||
name = models.CharField(max_length=255,
|
||||
verbose_name=_('name'))
|
||||
value = models.CharField(max_length=255,
|
||||
verbose_name=_('value'))
|
||||
|
||||
class Meta:
|
||||
"""Meta class."""
|
||||
verbose_name = _('unit')
|
||||
verbose_name_plural = _('units')
|
||||
|
||||
def __str__(self):
|
||||
"""Overridden dunder method."""
|
||||
return self.name
|
||||
|
||||
|
||||
class Characteristic(TranslatedFieldsMixin, models.Model):
|
||||
"""Characteristic model."""
|
||||
|
||||
|
|
@ -222,8 +238,7 @@ class Characteristic(TranslatedFieldsMixin, models.Model):
|
|||
help_text='{"en-GB":"some text"}')
|
||||
value = models.CharField(max_length=255,
|
||||
verbose_name=_('value'))
|
||||
unit = models.ForeignKey('Unit', on_delete=models.PROTECT,
|
||||
)
|
||||
unit = models.ForeignKey('Unit', on_delete=models.PROTECT)
|
||||
priority = models.IntegerField(unique=True, null=True, default=None)
|
||||
|
||||
class Meta:
|
||||
|
|
|
|||
|
|
@ -900,8 +900,8 @@ class KeyValueMetadatumKeyValueMetadatumEstablishments(MigrateMixin):
|
|||
class WineColor(MigrateMixin):
|
||||
using = 'legacy'
|
||||
|
||||
id = models.IntegerField()
|
||||
name = models.CharField(max_length=255)
|
||||
order_number = models.IntegerField(null=True, blank=True)
|
||||
fra_encima_id = models.IntegerField(null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
|
|
@ -912,7 +912,6 @@ class WineColor(MigrateMixin):
|
|||
class WineClassification(MigrateMixin):
|
||||
using = 'legacy'
|
||||
|
||||
id = models.IntegerField()
|
||||
name = models.CharField(max_length=255)
|
||||
desc = models.TextField()
|
||||
latitude = models.FloatField(blank=True, null=True)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user