diff --git a/halfapi/lib/responses.py b/halfapi/lib/responses.py index 679d446..8652bac 100644 --- a/halfapi/lib/responses.py +++ b/halfapi/lib/responses.py @@ -7,28 +7,13 @@ from io import TextIOBase, StringIO # asgi framework from starlette.responses import PlainTextResponse, Response -__all__ = ['CSVResponse', +__all__ = [ 'InternalServerErrorResponse', 'NotFoundResponse', 'NotImplementedResponse', 'PlainTextResponse', 'UnauthorizedResponse'] -class CSVResponse(Response): - def __init__(self, obj): - - with StringIO() as csv_file: - csv_obj = csv.writer(csv_file, dialect="excel") - csv_obj.writerows([elt.values() for elt in obj]) - filename = f'Personnels_LIRMM-{date.today()}.csv' - - super().__init__( - content=csv_file.getvalue(), - headers={ - 'Content-Type': 'text/csv; charset=UTF-8', - 'Content-Disposition': f'attachment; filename="{filename}"'}, - status_code = 200) - class InternalServerErrorResponse(Response): """ The 500 Internal Server Error default Response diff --git a/pyproject.toml b/pyproject.toml index 4498e08..096399f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,7 @@ fastapi = { version = "^0", optional = true } organigramme = { git = "git@gite.lirmm.fr:newsi/api/organigramme.git", optional = true } sidb = { git = "git@gite.lirmm.fr:newsi/sidb_halfORM.git", optional = true } python-dotenv = "^0.14.0" +pyexcel-ods3 = { version = "^0.5.3", optional = true } [tool.poetry.dev-dependencies] pytest = "^5" @@ -24,7 +25,7 @@ requests = "^2" pytest-env = "^0.6.2" [tool.poetry.extras] -organigramme = [ "fastapi", "organigramme", "sidb" ] +organigramme = [ "fastapi", "organigramme", "sidb", "pyexcel-ods3" ] [tool.poetry.scripts] halfapi = 'halfapi.cli:cli'