Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Parser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CMS
Parser
Commits
b53fa8cf
Commit
b53fa8cf
authored
8 months ago
by
esrsc23
Browse files
Options
Downloads
Patches
Plain Diff
UPDATE Changing status name to state
parent
cb2264a3
Branches
Branches containing commit
No related tags found
1 merge request
!9
UPDATE Changing status name to state
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/parser.py
+5
-5
5 additions, 5 deletions
app/parser.py
with
5 additions
and
5 deletions
app/parser.py
+
5
−
5
View file @
b53fa8cf
...
...
@@ -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
"
\n
File created in Hugo- ID:
{
identifier
}
- Type:
{
content_type
}
"
f
"
\n
Data:
{
data
}
\n
Operation 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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment