Commit 2481172d authored by Matthias's avatar Matthias
Browse files

Merge remote-tracking branch 'origin/master'

parents 396da0d5 5d1dcfe0
Pipeline #26227 passed with stages
in 1 minute and 44 seconds
......@@ -101,8 +101,8 @@ def create_app(test_config=None):
# api.add_resource(JobReport, '/v1/job/<topic_name>/report')
api.add_resource(WriteJobResultToDrupal, '/v1/drupal/<job_drupal_uuid>/<job_log_drupal_uuid>')
api.add_resource(WriteTypeReportToDrupal, '/v1/drupal/WriteElementReport')
api.add_resource(UpdateInstitution, '/v1/drupal/institution/<institutionId>')
api.add_resource(UpdateRecordSet, '/v1/drupal/recordset/<record_set_id>')
api.add_resource(UpdateInstitution, '/v1/drupal/institution/<institution_drupal_uuid>')
api.add_resource(UpdateRecordSet, '/v1/drupal/recordset/<record_set_drupal_uuid>')
api.add_resource(
DeleteRecord,
'/v1/drupal/delete/record/<session_id>',
......
......@@ -75,11 +75,11 @@ class UpdateInstitution(Resource):
paragraph_url = f'{base_url}{extended_address_path}{element["id"]}'
drupal_response_address = requests.get(paragraph_url, headers=headers, auth=auth)
response_data = drupal_response_address.json()['data']
addresses = response_data['attributes']['field_address']
if addresses is not None:
addresses['coordinates'] = \
next_address = response_data['attributes']['field_address']
if next_address is not None:
next_address['coordinates'] = \
response_data['attributes']['field_geographical_coordinates']['value']
addresses.append(addresses)
addresses.append(next_address)
institution_types = []
paragraph_url = \
......@@ -139,14 +139,14 @@ class UpdateInstitution(Resource):
institution_data_de['attributes']['computed_teaser_image_url'],
'computed_teaser_color': institution_data_de['attributes']['computed_teaser_color'],
}
producer_topic = current_app.config['topic-drupal-export']
headers = [
('recordSetId', bytes('none', encoding='utf-8')),
('sessionId', bytes(str(uuid.uuid4()), encoding='utf-8')),
('institutionId', bytes(result.get('field_memobase_id'), encoding='utf-8')),
('isPublished', bytes(str(result['status']), encoding='utf-8'))
]
try:
producer_topic = current_app.config['topic-drupal-export']
headers = [
('recordSetId', bytes('none', encoding='utf-8')),
('sessionId', bytes(str(uuid.uuid4()), encoding='utf-8')),
('institutionId', bytes(result.get('field_memobase_id'), encoding='utf-8')),
('isPublished', bytes(str(result['status']), encoding='utf-8'))
]
key = bytes(result.get('field_memobase_id'), encoding='utf-8')
self.producer.send(producer_topic, result, key, headers=headers)
except Exception as ex:
......
......@@ -17,7 +17,7 @@ class UpdateRecordSet(Resource):
value_serializer=lambda m: json.dumps(m, ensure_ascii=False)
.encode('utf-8'))
def get(self, record_set_id):
def get(self, record_set_drupal_uuid):
"""
Update the record set with the given drupal UUID in the backend.
---
......@@ -25,7 +25,7 @@ class UpdateRecordSet(Resource):
- Import Record Set
parameters:
- in: path
name: record_set_id
name: record_set_drupal_uuid
required: true
description: The UUID of the updated recordset
example: 0c4c777c-94f8-45ba-945a-bfe6967d40da
......@@ -56,9 +56,9 @@ class UpdateRecordSet(Resource):
# Retrieve Drupal Entities for each language.
# Returns default entity if there is a language missing.
de_drupal_url = f'{base_url}/de{json_api_path}{record_set_id}'
fr_drupal_url = f'{base_url}/fr{json_api_path}{record_set_id}'
it_drupal_url = f'{base_url}/it{json_api_path}{record_set_id}'
de_drupal_url = f'{base_url}/de{json_api_path}{record_set_drupal_uuid}'
fr_drupal_url = f'{base_url}/fr{json_api_path}{record_set_drupal_uuid}'
it_drupal_url = f'{base_url}/it{json_api_path}{record_set_drupal_uuid}'
try:
drupal_record_set_de = \
requests.get(de_drupal_url, headers=headers, auth=auth).json()['data']
......@@ -199,7 +199,7 @@ class UpdateRecordSet(Resource):
'field_teaser_image': drupal_record_set_de['relationships']['field_teaser_image']
}
except LookupError as ex:
msg = 'LookupError for ' + record_set_id + ': ' + str(ex) + '\n' + \
msg = 'LookupError for ' + record_set_drupal_uuid + ': ' + str(ex) + '\n' + \
traceback.format_exc() + '\n' + \
'baseRequest: ' + de_drupal_url + '\n'
current_app.logger.error(msg)
......@@ -209,7 +209,7 @@ class UpdateRecordSet(Resource):
'result_topic_value': result_topic_value
}, 500
except Exception as ex:
msg = 'Exception for ' + record_set_id + ': ' + str(ex) + '\n' + \
msg = 'Exception for ' + record_set_drupal_uuid + ': ' + str(ex) + '\n' + \
traceback.format_exc() + '\n' + \
'baseRequest: ' + de_drupal_url + '\n'
current_app.logger.error(msg)
......@@ -219,7 +219,7 @@ class UpdateRecordSet(Resource):
'result_topic_value': result_topic_value,
}, 500
return self.send_message(result_topic_value, record_set_id)
return self.send_message(result_topic_value, record_set_drupal_uuid)
def send_message(self, result_topic_value, record_set_drupal_id):
headers = [
......
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