Fix bugs in #53

This commit is contained in:
Khanh Ngo 2016-06-29 00:22:11 +07:00
parent 7f5a57f80c
commit c7efb85feb
2 changed files with 7 additions and 4 deletions

View File

@ -803,13 +803,15 @@ class Record(object):
records = [] records = []
for r in deleted_records: for r in deleted_records:
record = { record = {
"name": r['name'], "name": r['name'] + '.' if NEW_SCHEMA else r['name'],
"type": r['type'], "type": r['type'],
"changetype": "DELETE", "changetype": "DELETE",
"records": [ "records": [
] ]
} }
records.append(record) records.append(record)
print records
postdata_for_delete = {"rrsets": records} postdata_for_delete = {"rrsets": records}
records = [] records = []
@ -895,10 +897,10 @@ class Record(object):
headers = {} headers = {}
headers['X-API-Key'] = PDNS_API_KEY headers['X-API-Key'] = PDNS_API_KEY
jdata1 = utils.fetch_json(urlparse.urljoin(PDNS_STATS_URL, API_EXTENDED_URL + '/servers/localhost/zones/%s' % domain), headers=headers, method='PATCH', data=postdata_for_delete) jdata1 = utils.fetch_json(urlparse.urljoin(PDNS_STATS_URL, API_EXTENDED_URL + '/servers/localhost/zones/%s' % domain), headers=headers, method='PATCH', data=postdata_for_delete)
#logging.debug(jdata1) logging.debug('jdata1: ', jdata1)
jdata2 = utils.fetch_json(urlparse.urljoin(PDNS_STATS_URL, API_EXTENDED_URL + '/servers/localhost/zones/%s' % domain), headers=headers, method='PATCH', data=postdata_for_new) jdata2 = utils.fetch_json(urlparse.urljoin(PDNS_STATS_URL, API_EXTENDED_URL + '/servers/localhost/zones/%s' % domain), headers=headers, method='PATCH', data=postdata_for_new)
#logging.debug(jdata2) logging.debug('jdata2: ', jdata2)
if 'error' in jdata2.keys(): if 'error' in jdata2.keys():
logging.error('Cannot apply record changes.') logging.error('Cannot apply record changes.')

View File

@ -152,10 +152,11 @@
var modal = $("#modal_delete"); var modal = $("#modal_delete");
var table = $("#tbl_records").DataTable(); var table = $("#tbl_records").DataTable();
var record = $(this).prop('id'); var record = $(this).prop('id');
var nRow = $(this).parents('tr')[0];
var info = "Are you sure you want to delete " + record + "?"; var info = "Are you sure you want to delete " + record + "?";
modal.find('.modal-body p').text(info); modal.find('.modal-body p').text(info);
modal.find('#button_delete_confirm').click(function() { modal.find('#button_delete_confirm').click(function() {
table.row($(this).parents('tr')[0]).remove().draw(); table.row(nRow).remove().draw();
modal.modal('hide'); modal.modal('hide');
}) })
modal.modal('show'); modal.modal('show');