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 self.is_product_class(model):
            return 'products'
        return None

    def db_for_write(self, model, **hints):
        if self.is_product_class(model):
            return 'products'
        return None
