Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Matthias
my-test-project-1
Commits
bc256693
Commit
bc256693
authored
May 11, 2021
by
Jonas Waeber
Browse files
Fix dupal uuid retrieval
parent
55628b4c
Pipeline
#32973
passed with stages
in 1 minute and 50 seconds
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
import_api_app/resources/WriteTypeReportToDrupal.py
View file @
bc256693
...
...
@@ -64,7 +64,7 @@ class WriteTypeReportToDrupal(Resource):
'message'
:
f
'Missing a element in input body:
{
er
}
'
},
400
try
:
node_id
=
self
.
get_
node_
id
(
identifier
,
node_type
)
node_id
=
self
.
get_
drupal_uu
id
(
identifier
,
node_type
)
return
self
.
write_results
(
node_type
,
node_id
,
status
,
report
)
except
ImportApiError
as
e
:
current_app
.
logger
.
error
(
...
...
@@ -73,16 +73,12 @@ class WriteTypeReportToDrupal(Resource):
'error'
:
f
"Could not write report to
{
node_type
}
/
{
identifier
}
: "
f
"
{
e
.
message
}
"
},
500
def
get_node_id
(
self
,
memobase_id
:
str
,
node_type
:
str
):
current_app
.
logger
.
debug
(
f
'Retrieve node id from durpal json api with memobase id
{
memobase_id
}
.'
)
url
=
f
'
{
self
.
base_url
}
/jsonapi/node/
{
node_type
}
?filter['
\
f
'field_memobase_id]=
{
memobase_id
}
'
def
get_drupal_uuid
(
self
,
memobase_id
:
str
,
node_type
:
str
):
url
=
f
'
{
self
.
base_url
}
/jsonapi/node/
{
node_type
}
?filter[field_memobase_id]=
{
memobase_id
}
'
response
=
requests
.
get
(
url
,
headers
=
self
.
headers
)
if
response
.
ok
:
try
:
return
response
.
json
()[
'data'
][
0
][
'
attributes'
][
'drupal_internal__n
id'
]
return
response
.
json
()[
'data'
][
0
][
'id'
]
except
KeyError
as
er
:
current_app
.
logger
.
error
(
f
"Could not find the key
{
er
}
in data:
{
response
.
text
}
."
)
raise
ImportApiError
(
f
"Could not find the key
{
er
}
in data (url=
{
url
}
): "
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment