products/models.py: add UPC class
This commit is contained in:
@ -1,14 +1,20 @@
|
|||||||
from products.models import Product, SeasonRegionMaterial
|
from products.models import Product, SeasonRegionMaterial, UPC
|
||||||
|
|
||||||
|
|
||||||
class ProductDBRouter(object):
|
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):
|
def db_for_read(self, model, **hints):
|
||||||
if model == Product or model == SeasonRegionMaterial:
|
if self.is_product_class(model):
|
||||||
return 'products'
|
return 'products'
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def db_for_write(self, model, **hints):
|
def db_for_write(self, model, **hints):
|
||||||
if model == Product or model == SeasonRegionMaterial:
|
if self.is_product_class(model):
|
||||||
return 'products'
|
return 'products'
|
||||||
return None
|
return None
|
||||||
|
|||||||
@ -125,3 +125,16 @@ class SeasonRegionMaterial(models.Model):
|
|||||||
class Meta:
|
class Meta:
|
||||||
managed = False
|
managed = False
|
||||||
db_table = "keen_season_region_material"
|
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"
|
||||||
|
|||||||
Reference in New Issue
Block a user