Skip to content

Commit

Permalink
fix(data_import): use absolute url (#6875)
Browse files Browse the repository at this point in the history
there is no need to prepend the sitename to the url, since browsers/html are/is smart enough to handle absolute urls.

Signed-off-by: Chinmay Pai <chinmaydpai@gmail.com>
  • Loading branch information
Thunderbottom authored and nabinhait committed Feb 5, 2019
1 parent 9373125 commit 6377bdf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 6 additions & 6 deletions frappe/core/doctype/data_import/importer.py
Expand Up @@ -16,7 +16,7 @@
from frappe.utils.dateutils import parse_date
from frappe.utils.file_manager import save_url

from frappe.utils import cint, cstr, flt, getdate, get_datetime, get_url, get_url_to_form
from frappe.utils import cint, cstr, flt, getdate, get_datetime, get_url, get_absolute_url
from six import text_type, string_types


Expand Down Expand Up @@ -411,16 +411,16 @@ def publish_progress(achieved, reload=False):
# log errors
if parentfield:
log(**{"row": doc.idx, "title": 'Inserted row for "%s"' % (as_link(parenttype, doc.parent)),
"link": get_url_to_form(parenttype, doc.parent), "message": 'Document successfully saved', "indicator": "green"})
"link": get_absolute_url(parenttype, doc.parent), "message": 'Document successfully saved', "indicator": "green"})
elif submit_after_import:
log(**{"row": row_idx + 1, "title":'Submitted row for "%s"' % (as_link(doc.doctype, doc.name)),
"message": "Document successfully submitted", "link": get_url_to_form(doc.doctype, doc.name), "indicator": "blue"})
"message": "Document successfully submitted", "link": get_absolute_url(doc.doctype, doc.name), "indicator": "blue"})
elif original:
log(**{"row": row_idx + 1,"title":'Updated row for "%s"' % (as_link(doc.doctype, doc.name)),
"message": "Document successfully updated", "link": get_url_to_form(doc.doctype, doc.name), "indicator": "green"})
"message": "Document successfully updated", "link": get_absolute_url(doc.doctype, doc.name), "indicator": "green"})
elif not update_only:
log(**{"row": row_idx + 1, "title":'Inserted row for "%s"' % (as_link(doc.doctype, doc.name)),
"message": "Document successfully saved", "link": get_url_to_form(doc.doctype, doc.name), "indicator": "green"})
"message": "Document successfully saved", "link": get_absolute_url(doc.doctype, doc.name), "indicator": "green"})
else:
log(**{"row": row_idx + 1, "title":'Ignored row for %s' % (row[1]), "link": None,
"message": "Document updation ignored", "indicator": "orange"})
Expand All @@ -437,7 +437,7 @@ def publish_progress(achieved, reload=False):
error_trace = frappe.get_traceback()
if error_trace:
error_log_doc = frappe.log_error(error_trace)
error_link = get_url_to_form("Error Log", error_log_doc.name)
error_link = get_absolute_url("Error Log", error_log_doc.name)
else:
error_link = None

Expand Down
3 changes: 3 additions & 0 deletions frappe/utils/data.py
Expand Up @@ -745,6 +745,9 @@ def get_link_to_form(doctype, name, label=None):

return """<a href="{0}">{1}</a>""".format(get_url_to_form(doctype, name), label)

def get_absolute_url(doctype, name):
return "desk#Form/{0}/{1}".format(quoted(doctype), quoted(name))

def get_url_to_form(doctype, name):
return get_url(uri = "desk#Form/{0}/{1}".format(quoted(doctype), quoted(name)))

Expand Down

0 comments on commit 6377bdf

Please sign in to comment.