mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-08 22:50:26 +00:00
Use json.dumps for every detail in history
This works much better instead of just writing a str to the db and expect it to be loaded just fine from json.loads
This commit is contained in:
parent
3df36adbf4
commit
44c9aff5db
@ -93,7 +93,7 @@ def extract_changelogs_from_a_history_entry(out_changes, history_entry, change_n
|
|||||||
return
|
return
|
||||||
|
|
||||||
if "add_rrests" in history_entry.detail:
|
if "add_rrests" in history_entry.detail:
|
||||||
detail_dict = json.loads(history_entry.detail.replace("\'", ''))
|
detail_dict = json.loads(history_entry.detail)
|
||||||
else: # not a record entry
|
else: # not a record entry
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -362,13 +362,14 @@ def edit_key(key_id=None):
|
|||||||
current_app.logger.error('Error: {0}'.format(e))
|
current_app.logger.error('Error: {0}'.format(e))
|
||||||
|
|
||||||
history = History(msg=history_message,
|
history = History(msg=history_message,
|
||||||
detail=str({
|
detail=str(
|
||||||
'key': apikey.id,
|
json.dumps({
|
||||||
'role': apikey.role.name,
|
'key': apikey.id,
|
||||||
'description': apikey.description,
|
'role': apikey.role.name,
|
||||||
'domains': [domain.name for domain in apikey.domains],
|
'description': apikey.description,
|
||||||
'accounts': [a.name for a in apikey.accounts]
|
'domains': [domain.name for domain in apikey.domains],
|
||||||
}),
|
'accounts': [a.name for a in apikey.accounts]
|
||||||
|
})),
|
||||||
created_by=current_user.username)
|
created_by=current_user.username)
|
||||||
history.add()
|
history.add()
|
||||||
|
|
||||||
@ -411,12 +412,13 @@ def manage_keys():
|
|||||||
|
|
||||||
current_app.logger.info('Delete API key {0}'.format(apikey.id))
|
current_app.logger.info('Delete API key {0}'.format(apikey.id))
|
||||||
history = History(msg='Delete API key {0}'.format(apikey.id),
|
history = History(msg='Delete API key {0}'.format(apikey.id),
|
||||||
detail=str({
|
detail=str(
|
||||||
'key': history_apikey_id,
|
json.dumps({
|
||||||
'role': history_apikey_role,
|
'key': history_apikey_id,
|
||||||
'description': history_apikey_description,
|
'role': history_apikey_role,
|
||||||
'domains': history_apikey_domains
|
'description': history_apikey_description,
|
||||||
}),
|
'domains': history_apikey_domains
|
||||||
|
})),
|
||||||
created_by=current_user.username)
|
created_by=current_user.username)
|
||||||
history.add()
|
history.add()
|
||||||
|
|
||||||
@ -763,10 +765,7 @@ class DetailedHistory():
|
|||||||
self.detailed_msg = ""
|
self.detailed_msg = ""
|
||||||
return
|
return
|
||||||
|
|
||||||
if 'add_rrest' in history.detail:
|
detail_dict = json.loads(history.detail)
|
||||||
detail_dict = json.loads(history.detail.replace("\'", ''))
|
|
||||||
else:
|
|
||||||
detail_dict = json.loads(history.detail.replace("'", '"'))
|
|
||||||
|
|
||||||
if 'domain_type' in detail_dict and 'account_id' in detail_dict: # this is a domain creation
|
if 'domain_type' in detail_dict and 'account_id' in detail_dict: # this is a domain creation
|
||||||
self.detailed_msg = render_template_string("""
|
self.detailed_msg = render_template_string("""
|
||||||
@ -1673,10 +1672,11 @@ def create_template():
|
|||||||
result = t.create()
|
result = t.create()
|
||||||
if result['status'] == 'ok':
|
if result['status'] == 'ok':
|
||||||
history = History(msg='Add domain template {0}'.format(name),
|
history = History(msg='Add domain template {0}'.format(name),
|
||||||
detail=str({
|
detail=str(
|
||||||
'name': name,
|
json.dumps({
|
||||||
'description': description
|
'name': name,
|
||||||
}),
|
'description': description
|
||||||
|
})),
|
||||||
created_by=current_user.username)
|
created_by=current_user.username)
|
||||||
history.add()
|
history.add()
|
||||||
return redirect(url_for('admin.templates'))
|
return redirect(url_for('admin.templates'))
|
||||||
@ -1720,10 +1720,11 @@ def create_template_from_zone():
|
|||||||
result = t.create()
|
result = t.create()
|
||||||
if result['status'] == 'ok':
|
if result['status'] == 'ok':
|
||||||
history = History(msg='Add domain template {0}'.format(name),
|
history = History(msg='Add domain template {0}'.format(name),
|
||||||
detail=str({
|
detail=str(
|
||||||
'name': name,
|
json.dumps({
|
||||||
'description': description
|
'name': name,
|
||||||
}),
|
'description': description
|
||||||
|
})),
|
||||||
created_by=current_user.username)
|
created_by=current_user.username)
|
||||||
history.add()
|
history.add()
|
||||||
|
|
||||||
@ -1883,7 +1884,7 @@ def delete_template(template):
|
|||||||
if result['status'] == 'ok':
|
if result['status'] == 'ok':
|
||||||
history = History(
|
history = History(
|
||||||
msg='Deleted domain template {0}'.format(template),
|
msg='Deleted domain template {0}'.format(template),
|
||||||
detail=str({'name': template}),
|
detail=str(json.dumps({'name': template})),
|
||||||
created_by=current_user.username)
|
created_by=current_user.username)
|
||||||
history.add()
|
history.add()
|
||||||
return redirect(url_for('admin.templates'))
|
return redirect(url_for('admin.templates'))
|
||||||
|
@ -409,11 +409,12 @@ def add():
|
|||||||
domain_id = Domain().get_id_by_name(domain_name)
|
domain_id = Domain().get_id_by_name(domain_name)
|
||||||
history = History(msg='Add domain {0}'.format(
|
history = History(msg='Add domain {0}'.format(
|
||||||
pretty_domain_name(domain_name)),
|
pretty_domain_name(domain_name)),
|
||||||
detail=str({
|
detail=str(
|
||||||
|
json.dumps({
|
||||||
'domain_type': domain_type,
|
'domain_type': domain_type,
|
||||||
'domain_master_ips': domain_master_ips,
|
'domain_master_ips': domain_master_ips,
|
||||||
'account_id': account_id
|
'account_id': account_id
|
||||||
}),
|
})),
|
||||||
created_by=current_user.username,
|
created_by=current_user.username,
|
||||||
domain_id=domain_id)
|
domain_id=domain_id)
|
||||||
history.add()
|
history.add()
|
||||||
@ -464,7 +465,7 @@ def add():
|
|||||||
msg=
|
msg=
|
||||||
'Failed to apply template {0} to {1}.'
|
'Failed to apply template {0} to {1}.'
|
||||||
.format(template.name, domain_name),
|
.format(template.name, domain_name),
|
||||||
detail=str(result),
|
detail=str(json.dumps(result)),
|
||||||
created_by=current_user.username)
|
created_by=current_user.username)
|
||||||
history.add()
|
history.add()
|
||||||
return redirect(url_for('dashboard.dashboard'))
|
return redirect(url_for('dashboard.dashboard'))
|
||||||
@ -617,10 +618,11 @@ def change_soa_edit_api(domain_name):
|
|||||||
history = History(
|
history = History(
|
||||||
msg='Update soa_edit_api for domain {0}'.format(
|
msg='Update soa_edit_api for domain {0}'.format(
|
||||||
pretty_domain_name(domain_name)),
|
pretty_domain_name(domain_name)),
|
||||||
detail=str({
|
detail=str(
|
||||||
|
json.dumps({
|
||||||
"domain": domain_name,
|
"domain": domain_name,
|
||||||
"soa_edit_api": new_setting
|
"soa_edit_api": new_setting
|
||||||
}),
|
})),
|
||||||
created_by=current_user.username,
|
created_by=current_user.username,
|
||||||
domain_id=d.get_id_by_name(domain_name))
|
domain_id=d.get_id_by_name(domain_name))
|
||||||
history.add()
|
history.add()
|
||||||
|
@ -550,12 +550,13 @@ def signin_history(username, authenticator, success):
|
|||||||
|
|
||||||
# Write history
|
# Write history
|
||||||
History(msg='User {} authentication {}'.format(username, str_success),
|
History(msg='User {} authentication {}'.format(username, str_success),
|
||||||
detail=str({
|
detail=str(
|
||||||
"username": username,
|
json.dumps({
|
||||||
"authenticator": authenticator,
|
"username": username,
|
||||||
"ip_address": request_ip,
|
"authenticator": authenticator,
|
||||||
"success": 1 if success else 0
|
"ip_address": request_ip,
|
||||||
}),
|
"success": 1 if success else 0
|
||||||
|
})),
|
||||||
created_by='System').add()
|
created_by='System').add()
|
||||||
|
|
||||||
# Get a list of Azure security groups the user is a member of
|
# Get a list of Azure security groups the user is a member of
|
||||||
@ -864,13 +865,14 @@ def dyndns_update():
|
|||||||
if result['status'] == 'ok':
|
if result['status'] == 'ok':
|
||||||
history = History(
|
history = History(
|
||||||
msg='DynDNS update: updated {} successfully'.format(hostname),
|
msg='DynDNS update: updated {} successfully'.format(hostname),
|
||||||
detail=str({
|
detail=str(
|
||||||
"domain": domain.name,
|
json.dumps({
|
||||||
"record": hostname,
|
"domain": domain.name,
|
||||||
"type": rtype,
|
"record": hostname,
|
||||||
"old_value": oldip,
|
"type": rtype,
|
||||||
"new_value": str(ip)
|
"old_value": oldip,
|
||||||
}),
|
"new_value": str(ip)
|
||||||
|
})),
|
||||||
created_by=current_user.username,
|
created_by=current_user.username,
|
||||||
domain_id=domain.id)
|
domain_id=domain.id)
|
||||||
history.add()
|
history.add()
|
||||||
@ -906,11 +908,12 @@ def dyndns_update():
|
|||||||
msg=
|
msg=
|
||||||
'DynDNS update: created record {0} in zone {1} successfully'
|
'DynDNS update: created record {0} in zone {1} successfully'
|
||||||
.format(hostname, domain.name, str(ip)),
|
.format(hostname, domain.name, str(ip)),
|
||||||
detail=str({
|
detail=str(
|
||||||
"domain": domain.name,
|
json.dumps({
|
||||||
"record": hostname,
|
"domain": domain.name,
|
||||||
"value": str(ip)
|
"record": hostname,
|
||||||
}),
|
"value": str(ip)
|
||||||
|
})),
|
||||||
created_by=current_user.username,
|
created_by=current_user.username,
|
||||||
domain_id=domain.id)
|
domain_id=domain.id)
|
||||||
history.add()
|
history.add()
|
||||||
|
Loading…
Reference in New Issue
Block a user