diff --git a/backend/OLA_DATA.mysql b/backend/OLA_DATA.mysql index 65e56a8..7c8db3a 100644 --- a/backend/OLA_DATA.mysql +++ b/backend/OLA_DATA.mysql @@ -1,5 +1,6 @@ USE OLA; INSERT INTO SETTINGS VALUES ('BASE_DIRECTORY', '/OLA_RESSOURCES/', 'Répertoire base pour le dépot des fichiers'); +INSERT INTO SETTINGS VALUES ('TEMPLATES_DIRECTORY', '/OLA_TEMPLATES/', 'Répertoire base pour le dépot des fichiers'); INSERT INTO SETTINGS VALUES ('OLA_URL', 'ola.univ-tlse2.fr/', 'URL de l application'); INSERT INTO `USER` VALUES (1, '1', 'sec@univ-tlse2.fr', 'Secrétaire', DEFAULT, 'aZeRtYuIoP', '01.23.45.67.89'); diff --git a/backend/app/api/PdfAPI.py b/backend/app/api/PdfAPI.py new file mode 100644 index 0000000..e46d8df --- /dev/null +++ b/backend/app/api/PdfAPI.py @@ -0,0 +1,22 @@ +from flask_restful import Resource +from flask_restful.reqparse import RequestParser +from app.tools.LibPdf import delete_file +from model import getParam + +import os + +class LoginAPI(Resource): + """ + Login Api Resource + """ + + def delete(self): + parser = RequestParser() + parser.add_argument('templateName', required=True, help="Template name is required !") + args = parser.parse_args() + + if ".." in args: + return { "msg" : ".. not allowed in path"}, 400 + + delete_file(os.path.join(getParam('TEMPLATES_DIRECTORY'), args['file'])) + diff --git a/backend/app/tools/LibPdf.py b/backend/app/tools/LibPdf.py index 91704b2..567953f 100644 --- a/backend/app/tools/LibPdf.py +++ b/backend/app/tools/LibPdf.py @@ -78,3 +78,7 @@ def upload_file(): ''' + +def delete_file(pdf_path): + if os.path.exists(pdf_path): + os.remove(pdf_path)