|
|
|
@ -17,6 +17,7 @@ cookie_schema = CookieSchema()
|
|
|
|
|
|
|
|
|
|
logger = logbook.Logger('Cookies')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@annotate(authentication=[JWTAuthentication()])
|
|
|
|
|
def get_state(injector: Injector, auth: Auth):
|
|
|
|
|
state = injector.state
|
|
|
|
@ -43,12 +44,6 @@ def get_cookie(session: Session, id):
|
|
|
|
|
|
|
|
|
|
def create_cookie(session: Session, json_data: http.RequestData, route: Router):
|
|
|
|
|
cookie_data = cookie_schema.load(json_data)
|
|
|
|
|
|
|
|
|
|
#cookie = Cookie(name=json_data['name'],
|
|
|
|
|
# recipe_url=json_data['recipe_url'],
|
|
|
|
|
# sku=json_data['sku'],
|
|
|
|
|
# qoh=json_data['qoh'],
|
|
|
|
|
# unit_cost=json_data['unit_cost'])
|
|
|
|
|
cookie = Cookie(**cookie_data)
|
|
|
|
|
session.add(cookie)
|
|
|
|
|
session.commit()
|
|
|
|
@ -64,7 +59,8 @@ def delete_cookie(session: Session, id: int):
|
|
|
|
|
session.delete(cookie)
|
|
|
|
|
return {"message": "200 OK"}
|
|
|
|
|
|
|
|
|
|
routes = [
|
|
|
|
|
|
|
|
|
|
_routes = [
|
|
|
|
|
Route('/state', 'GET', get_state),
|
|
|
|
|
Route('/cookies', 'GET', get_cookies),
|
|
|
|
|
Route('/cookies', 'POST', create_cookie),
|
|
|
|
@ -79,14 +75,14 @@ app_settings = {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
routes = routes + auth_routes
|
|
|
|
|
_routes = _routes + auth_routes
|
|
|
|
|
|
|
|
|
|
commands = sqlalchemy_backend.commands + commands
|
|
|
|
|
_commands = sqlalchemy_backend.commands + commands
|
|
|
|
|
|
|
|
|
|
components = sqlalchemy_backend.components + auth_components
|
|
|
|
|
_components = sqlalchemy_backend.components + auth_components
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def application_factory(settings={}):
|
|
|
|
|
def application_factory(settings={}, routes=_routes, commands=_commands, components=_components):
|
|
|
|
|
"""Returns an instance of Cookie API"""
|
|
|
|
|
_settings = {**app_settings, **settings}
|
|
|
|
|
|
|
|
|
|