In order to mitigate against the brute force attacks against Gitlab accounts, we are moving to all edu-ID Logins. We would like to remind you to link your account with your edu-id. Login will be possible only by edu-ID after November 30, 2021. Here you can find the instructions for linking your account.

If you don't have a SWITCH edu-ID, you can create one with this guide here

kind regards

Commit 4ba0723d authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Fix write report.

parent 5e9b664c
Pipeline #28650 passed with stages
in 2 minutes
......@@ -69,8 +69,8 @@ class WriteTypeReportToDrupal(Resource):
'message': f'Missing a element in input body: {er}'
}, 400
node_id = self.get_drupal_uuid(identifier, node_type)
return self.write_results(node_type, node_id, status, report)
node_id, lang_code = self.get_drupal_uuid(identifier, node_type)
return self.write_results(node_type, node_id, lang_code, status, report)
except ImportApiError as e:
f"Could not write report to {node_type}/{identifier}: {e.message}")
......@@ -83,7 +83,8 @@ class WriteTypeReportToDrupal(Resource):
response = requests.get(url, headers=self.headers, auth=self.auth)
if response.ok:
return response.json()['data'][0]['id']
result = response.json()['data'][0]
return result['id'], result['attributes']['langcode']
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}): "
......@@ -97,19 +98,19 @@ class WriteTypeReportToDrupal(Resource):
current_app.logger.error("Could not find element: " + url)
raise ImportApiError(f"Could not find element for report: {response.text}.")
def write_results(self, node_type, identifier, status, report):
"writing: " + node_type + "/" + str(identifier) + "/" + str(status) + "/" + report)
def write_results(self, node_type, identifier, lang_code, status, report):
current_app.logger.debug(f"writing: {lang_code}/{node_type}/{str(identifier)}"
drupal_type = ''
url = f'{self.base_url}/jsonapi/node/'
url = f'{self.base_url}/{lang_code}/jsonapi/node/'
if node_type == 'institution':
drupal_type = 'node--institution'
url += 'institution/'
elif node_type == 'record_set':
drupal_type = 'node--record_set'
url += 'record_set/'
url = f'{url}{identifier}'
url = f'{url}{identifier}'
data = {
"data": {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment