P5-6491 use market instead of territory for price calculations (#37)
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
from functools import wraps
|
||||
from flask import request
|
||||
import jsonschema
|
||||
from api.models.market import iter_markets
|
||||
|
||||
|
||||
class ValidationError(Exception):
|
||||
@@ -72,30 +71,6 @@ def validate_number(*keys):
|
||||
return decorator
|
||||
|
||||
|
||||
def validate_territory(*keys):
|
||||
def decorator(f):
|
||||
@wraps(f)
|
||||
def wrapper(*args, **kwargs):
|
||||
for key in keys:
|
||||
if not key in request.args:
|
||||
raise ValidationError("No {} is specified".format(key))
|
||||
value = request.args.get(key)
|
||||
valid = False
|
||||
for market in iter_markets():
|
||||
if market.territory == value:
|
||||
valid = True
|
||||
break
|
||||
|
||||
if not valid:
|
||||
raise ValidationError("{} is not a valid territory".format(value))
|
||||
|
||||
return f(*args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
||||
return decorator
|
||||
|
||||
|
||||
def validate_any_of(key, values):
|
||||
def decorator(f):
|
||||
@wraps(f)
|
||||
|
||||
Reference in New Issue
Block a user