def add_year_restriction(self, function):
"""Resource method decorator which applies a restriction
only allowing results related to a syllabus of one year of
age or older.
This only works for HTTP GET methods on collection resources.
Other methods will be unaffected entirely by this decorator.
"""
method = function.__name__
__, resource_type = self.resource_method_info(function)
if method == "get" and resource_type == ResourceType.collection:
@wraps(function)
def new_function_to_replace_old(*args, **kwargs):
request_args = {
'useOldIndex': True
}
request_args.update(flask.request.args)
flask.request.args = ImmutableMultiDict(request_args)
return function(*args, **kwargs)
return new_function_to_replace_old
else:
return function
# TODO, FIXME: bad, remove this ASAP
# (this is here as filler because we haven't gotten
# to the elasticsearch bit yet)
评论列表
文章目录