Skip to content
Snippets Groups Projects
Commit 0828bf6f authored by Richard Fernando Heise Ferreira's avatar Richard Fernando Heise Ferreira
Browse files

Merge branch 'issue-3/Update-script-for-projects' into 'main'

issue #3: UPDATE including rotes for Projects collection type in the script

See merge request !3
parents b74c9339 cae08459
Branches
No related tags found
1 merge request!3issue #3: UPDATE including rotes for Projects collection type in the script
...@@ -6,6 +6,7 @@ app = Flask(__name__) ...@@ -6,6 +6,7 @@ app = Flask(__name__)
# Diretórios onde os arquivos Markdown serão salvos # Diretórios onde os arquivos Markdown serão salvos
DIR_O_C3SL = os.path.join(os.getcwd(), '../cms-c3sl/themes/c3sl/exampleSite/content') DIR_O_C3SL = os.path.join(os.getcwd(), '../cms-c3sl/themes/c3sl/exampleSite/content')
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')
def create_or_update_post(post_id, data, event, content_type): def create_or_update_post(post_id, data, event, content_type):
if not data: if not data:
...@@ -26,6 +27,29 @@ layout: 'legal' ...@@ -26,6 +27,29 @@ layout: 'legal'
--- ---
{content} {content}
""" """
elif content_type == 'projeto':
attributes = data.get('entry', {})
title = attributes.get('Titulo', '')
status = attributes.get('Status', '')
partner = attributes.get('Parceiro', '')
content = attributes.get('Descricao', '')
file_name = f"{post_id}.md"
file_path = os.path.join(DIR_PROJECTS, file_name)
edited_line = 'Edited: true\n' if event == 'entry.update' else ''
content_markdown = f"""---
title: "{title}"
author: " Parceiro: {partner}"
status: "{status}"
{edited_line}ShowReadingTime: true
---
---
{content}
"""
else: else:
attributes = data.get('entry', {}) attributes = data.get('entry', {})
content = attributes.get('Descricao', '') content = attributes.get('Descricao', '')
...@@ -75,6 +99,16 @@ def delete_post(post_id, content_type): ...@@ -75,6 +99,16 @@ def delete_post(post_id, content_type):
#print(f"Post com ID {post_id} deletado") #print(f"Post com ID {post_id} deletado")
else: else:
print(f"Arquivo com ID {post_id} não encontrado para exclusão") print(f"Arquivo com ID {post_id} não encontrado para exclusão")
elif content_type == 'projeto':
file_name = f"{post_id}.md"
file_path = os.path.join(DIR_PROJECTS, file_name)
if os.path.exists(file_path):
os.remove(file_path)
#print(f"Post com ID {post_id} deletado")
else:
print(f"Arquivo com ID {post_id} não encontrado para exclusão")
@app.route('/run-script', methods=['POST']) @app.route('/run-script', methods=['POST'])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment