products/models.py: add UPC class

This commit is contained in:
2020-02-13 16:38:11 -08:00
parent cc93a8e4d6
commit 9cbf48383c
2 changed files with 22 additions and 3 deletions

View File

@ -1,14 +1,20 @@
from products.models import Product, SeasonRegionMaterial
from products.models import Product, SeasonRegionMaterial, UPC
class ProductDBRouter(object):
def is_product_class(self, model):
return \
model == Product or \
model == SeasonRegionMaterial or \
model == UPC
def db_for_read(self, model, **hints):
if model == Product or model == SeasonRegionMaterial:
if self.is_product_class(model):
return 'products'
return None
def db_for_write(self, model, **hints):
if model == Product or model == SeasonRegionMaterial:
if self.is_product_class(model):
return 'products'
return None

View File

@ -125,3 +125,16 @@ class SeasonRegionMaterial(models.Model):
class Meta:
managed = False
db_table = "keen_season_region_material"
class UPC(models.Model):
upc = models.CharField(max_length=20, db_column='upc', primary_key=True)
size = models.CharField(max_length=20, db_column='size')
dimension = models.CharField(max_length=20, db_column='dimension')
material = models.CharField(max_length=10, db_column='material')
size_grid = models.CharField(max_length=20, db_column='size_grid')
updated = models.DateTimeField()
class Meta:
managed = False
db_table = "keen_upc"