Skip to content
Snippets Groups Projects
Commit b53fa8cf authored by esrsc23's avatar esrsc23
Browse files

UPDATE Changing status name to state

parent cb2264a3
No related branches found
No related tags found
1 merge request!9UPDATE Changing status name to state
...@@ -18,7 +18,7 @@ DIR_O_C3SL = os.path.join(os.getcwd(), '../../cms-c3sl/themes/c3sl/exampleSite/c ...@@ -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_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') 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: if not data:
logging.error(f"Code: 400" logging.error(f"Code: 400"
f"Status: JSON file not found\n") f"Status: JSON file not found\n")
...@@ -46,7 +46,7 @@ layout: 'legal' ...@@ -46,7 +46,7 @@ layout: 'legal'
#Coleta os dados necessários para estar no arquivo JSON #Coleta os dados necessários para estar no arquivo JSON
attributes = data.get('entry', {}) attributes = data.get('entry', {})
title = attributes.get('Titulo', '') title = attributes.get('Titulo', '')
status = attributes.get('Status', '') status = attributes.get('Estado', '')
partner = attributes.get('Parceiro', '') partner = attributes.get('Parceiro', '')
content = attributes.get('Descricao', '') content = attributes.get('Descricao', '')
...@@ -120,7 +120,7 @@ summary: "{summary}" ...@@ -120,7 +120,7 @@ summary: "{summary}"
return f"Error writing file{e}", 400 return f"Error writing file{e}", 400
#Deleta algum tipo de conteudo enviado por requisição #Deleta algum tipo de conteudo enviado por requisição
def delete_noticia(identifier, content_type): def delete(identifier, content_type):
#Deletando uma notícia #Deletando uma notícia
if content_type == 'noticia': if content_type == 'noticia':
file_name = f"{identifier}.md" file_name = f"{identifier}.md"
...@@ -175,14 +175,14 @@ def run_script(): ...@@ -175,14 +175,14 @@ def run_script():
return f"File created in Strapi {identifier} - Type: {content_type}", 200 return f"File created in Strapi {identifier} - Type: {content_type}", 200
elif event in ['entry.update', 'entry.publish']: 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}" logging.info(f"\nFile created in Hugo- ID: {identifier} - Type: {content_type}"
f"\nData: {data}\nOperation completed successfully\n") f"\nData: {data}\nOperation completed successfully\n")
return f"Operation completed successfully\n Data: {data}", 200 return f"Operation completed successfully\n Data: {data}", 200
elif event in ['entry.delete', 'entry.unpublish']: 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}") logging.info(f"File removed - ID: {identifier} - Type: {content_type}")
return f"File removed with ID {identifier}", 200 return f"File removed with ID {identifier}", 200
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment