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