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

Merge remote-tracking branch 'origin/master'

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