pep8 it
This commit is contained in:
@@ -16,7 +16,7 @@ class Category(db.Model):
|
||||
if not row:
|
||||
raise Exception(
|
||||
'Could not find a path for category: {}, locale: {}'.format(self.id, locale))
|
||||
path = row.path.split('/', 1)[-1] # get all text after the first /
|
||||
path = row.path.split('/', 1)[-1] # get all text after the first /
|
||||
path = slugify(path)
|
||||
return path
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ class Market(object):
|
||||
@property
|
||||
def price_adjustments(self):
|
||||
if self._price_adjustments is None:
|
||||
row = PriceAdjustments.query.filter_by(territory=self.territory).first()
|
||||
row = PriceAdjustments.query.filter_by(
|
||||
territory=self.territory).first()
|
||||
if row:
|
||||
self._price_adjustments = float(row.adjustment)
|
||||
self._price_adjustments = 1
|
||||
@@ -86,18 +87,21 @@ _markets = [
|
||||
Market('International', 'en_EU', 'EUR', 1, None),
|
||||
]
|
||||
|
||||
|
||||
def iter_markets():
|
||||
for market in _markets:
|
||||
yield market
|
||||
|
||||
|
||||
def from_locale(locale):
|
||||
for market in iter_markets():
|
||||
if market.locale == locale:
|
||||
return market
|
||||
return None
|
||||
|
||||
|
||||
def from_territory(territory):
|
||||
for market in iter_markets():
|
||||
if market.territory == territory.upper():
|
||||
return market
|
||||
return None
|
||||
return None
|
||||
|
||||
@@ -8,4 +8,4 @@ class Currencies(db.Model):
|
||||
__tablename__ = 'product-currencies'
|
||||
|
||||
iso3char = db.Column(db.String(3), primary_key=True)
|
||||
exchange_rate = db.Column(db.Numeric, default=1)
|
||||
exchange_rate = db.Column(db.Numeric, default=1)
|
||||
|
||||
Reference in New Issue
Block a user