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
memoriav
Memobase 2020
services
Import Process
Import API
Commits
bc256693
Commit
bc256693
authored
May 11, 2021
by
Jonas Waeber
Browse files
Fix dupal uuid retrieval
parent
55628b4c
Pipeline
#26438
passed with stages
in 1 minute and 50 seconds
Changes
1
Pipelines
3
Show whitespace changes
Inline
Side-by-side
import_api_app/resources/WriteTypeReportToDrupal.py
View file @
bc256693
...
@@ -64,7 +64,7 @@ class WriteTypeReportToDrupal(Resource):
...
@@ -64,7 +64,7 @@ class WriteTypeReportToDrupal(Resource):
'message'
:
f
'Missing a element in input body:
{
er
}
'
'message'
:
f
'Missing a element in input body:
{
er
}
'
},
400
},
400
try
:
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
)
return
self
.
write_results
(
node_type
,
node_id
,
status
,
report
)
except
ImportApiError
as
e
:
except
ImportApiError
as
e
:
current_app
.
logger
.
error
(
current_app
.
logger
.
error
(
...
@@ -73,16 +73,12 @@ class WriteTypeReportToDrupal(Resource):
...
@@ -73,16 +73,12 @@ class WriteTypeReportToDrupal(Resource):
'error'
:
f
"Could not write report to
{
node_type
}
/
{
identifier
}
: "
'error'
:
f
"Could not write report to
{
node_type
}
/
{
identifier
}
: "
f
"
{
e
.
message
}
"
},
500
f
"
{
e
.
message
}
"
},
500
def
get_node_id
(
self
,
memobase_id
:
str
,
node_type
:
str
):
def
get_drupal_uuid
(
self
,
memobase_id
:
str
,
node_type
:
str
):
current_app
.
logger
.
debug
(
url
=
f
'
{
self
.
base_url
}
/jsonapi/node/
{
node_type
}
?filter[field_memobase_id]=
{
memobase_id
}
'
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
}
'
response
=
requests
.
get
(
url
,
headers
=
self
.
headers
)
response
=
requests
.
get
(
url
,
headers
=
self
.
headers
)
if
response
.
ok
:
if
response
.
ok
:
try
:
try
:
return
response
.
json
()[
'data'
][
0
][
'
attributes'
][
'drupal_internal__n
id'
]
return
response
.
json
()[
'data'
][
0
][
'id'
]
except
KeyError
as
er
:
except
KeyError
as
er
:
current_app
.
logger
.
error
(
f
"Could not find the key
{
er
}
in data:
{
response
.
text
}
."
)
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
}
): "
raise
ImportApiError
(
f
"Could not find the key
{
er
}
in data (url=
{
url
}
): "
...
...
Write
Preview
Markdown
is supported
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