Using client-side 'url_for' implementation in the import/export module.

This commit is contained in:
Ashesh Vashi
2017-06-16 00:00:17 +05:30
parent 07580b8444
commit e65b605912
2 changed files with 15 additions and 9 deletions

View File

@@ -53,6 +53,13 @@ class ImportExportModule(PgAdminModule):
return scripts
def get_exposed_url_endpoints(self):
"""
Returns:
list: URL endpoints for backup module
"""
return ['import_export.create_job']
blueprint = ImportExportModule(MODULE_NAME, __name__)
@@ -186,7 +193,7 @@ def filename_with_file_manager_path(_file, _present=False):
return fs_short_path(_file)
@blueprint.route('/create_job/<int:sid>', methods=['POST'])
@blueprint.route('/job/<int:sid>', methods=['POST'], endpoint="create_job")
@login_required
def create_import_export_job(sid):
"""

View File

@@ -1,9 +1,9 @@
define([
'sources/gettext', 'jquery', 'underscore', 'underscore.string', 'alertify',
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'underscore.string', 'alertify',
'pgadmin', 'pgadmin.browser', 'backbone', 'backgrid', 'backform',
'pgadmin.backform', 'pgadmin.backgrid', 'pgadmin.browser.node.ui'
], function(
gettext, $, _, S, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid, Backform
gettext, url_for, $, _, S, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid, Backform
) {
pgAdmin = pgAdmin || window.pgAdmin || {};
@@ -408,15 +408,14 @@ define([
'schema': treeInfo.schema._label,
'table': treeInfo.table._label
});
var self = this,
baseUrl = "{{ url_for('import_export.index') }}" +
"create_job/" + treeInfo.server._id,
args = this.view.model.toJSON();
var self = this;
$.ajax({
url: baseUrl,
url: url_for(
'import_export.create_job', {'sid': treeInfo.server._id}
),
method: 'POST',
data:{ 'data': JSON.stringify(args) },
data:{ 'data': JSON.stringify(this.view.model.toJSON()) },
success: function(res) {
if (res.success) {
Alertify.notify(gettext('Import/export job created.'), 'success', 5);