diff --git a/app/parser.py b/app/parser.py index f4aea52ae84599ecf56959fb553fbe8195ea36f9..11e35e0c7729e6c7f21b59788b360c90033b2119 100644 --- a/app/parser.py +++ b/app/parser.py @@ -18,7 +18,7 @@ DIR_O_C3SL = os.path.join(os.getcwd(), '../../cms-c3sl/themes/c3sl/exampleSite/c DIR_POSTS = os.path.join(os.getcwd(), '../../cms-c3sl/themes/c3sl/exampleSite/content/noticia') DIR_PROJECTS = os.path.join(os.getcwd(), '../../cms-c3sl/themes/c3sl/exampleSite/content/projetos') -def create_or_update_noticia(identifier, data, event, content_type): +def create_or_update(identifier, data, event, content_type): if not data: logging.error(f"Code: 400" f"Status: JSON file not found\n") @@ -46,7 +46,7 @@ layout: 'legal' #Coleta os dados necessários para estar no arquivo JSON attributes = data.get('entry', {}) title = attributes.get('Titulo', '') - status = attributes.get('Status', '') + status = attributes.get('Estado', '') partner = attributes.get('Parceiro', '') content = attributes.get('Descricao', '') @@ -120,7 +120,7 @@ summary: "{summary}" return f"Error writing file{e}", 400 #Deleta algum tipo de conteudo enviado por requisição -def delete_noticia(identifier, content_type): +def delete(identifier, content_type): #Deletando uma notícia if content_type == 'noticia': file_name = f"{identifier}.md" @@ -175,14 +175,14 @@ def run_script(): return f"File created in Strapi {identifier} - Type: {content_type}", 200 elif event in ['entry.update', 'entry.publish']: - create_or_update_noticia(identifier, data, event, content_type) + create_or_update(identifier, data, event, content_type) logging.info(f"\nFile created in Hugo- ID: {identifier} - Type: {content_type}" f"\nData: {data}\nOperation completed successfully\n") return f"Operation completed successfully\n Data: {data}", 200 elif event in ['entry.delete', 'entry.unpublish']: - delete_noticia(identifier, content_type) + delete(identifier, content_type) logging.info(f"File removed - ID: {identifier} - Type: {content_type}") return f"File removed with ID {identifier}", 200