fixed bug with user
This commit is contained in:
parent
8f8a936693
commit
34f0ab2d15
|
|
@ -28,15 +28,22 @@ def finalize(language, company_name):
|
|||
company_name = (company_name or "").strip() or "Test Company AZ"
|
||||
year = date.today().year
|
||||
|
||||
# Emulate what the default wizard passes: the email of the current session user.
|
||||
# Frappe's create_or_update_user uses this to either update the existing user (if the
|
||||
# row already exists) or create one. Passing blanks here caused downstream hooks that
|
||||
# assume a real user-record to misbehave.
|
||||
session_user = frappe.db.get_value(
|
||||
"User", frappe.session.user, ["full_name", "email"], as_dict=True
|
||||
) or frappe._dict()
|
||||
|
||||
args = {
|
||||
"language": language_name,
|
||||
"country": "Azerbaijan",
|
||||
"timezone": "Asia/Baku",
|
||||
"currency": "AZN",
|
||||
"enable_telemetry": 0,
|
||||
# Leave email blank → create_or_update_user is a no-op and Administrator stays.
|
||||
"full_name": "",
|
||||
"email": "",
|
||||
"full_name": session_user.full_name or "Administrator",
|
||||
"email": session_user.email or "",
|
||||
"password": "",
|
||||
"company_name": company_name,
|
||||
"company_abbr": _make_abbr(company_name),
|
||||
|
|
@ -48,7 +55,21 @@ def finalize(language, company_name):
|
|||
|
||||
from frappe.desk.page.setup_wizard.setup_wizard import setup_complete
|
||||
|
||||
return setup_complete(args)
|
||||
try:
|
||||
result = setup_complete(args)
|
||||
except Exception:
|
||||
# Surface the traceback to the client so we can see exactly where setup fell over,
|
||||
# instead of the generic "Setup failed" wrapper.
|
||||
tb = frappe.get_traceback(with_context=True)
|
||||
frappe.log_error(title="Jey Wizard finalize failed", message=tb)
|
||||
return {
|
||||
"status": "error",
|
||||
"failure_message": frappe.response.get("setup_wizard_failure_message")
|
||||
or "Setup failed — see traceback",
|
||||
"traceback": tb,
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def _make_abbr(name: str) -> str:
|
||||
|
|
|
|||
|
|
@ -142,31 +142,41 @@ frappe.setup.SetupWizard = class JeySetupWizard {
|
|||
},
|
||||
freeze: true,
|
||||
callback: (r) => {
|
||||
if (r.message && r.message.status === "ok") {
|
||||
const m = r.message || {};
|
||||
if (m.status === "ok") {
|
||||
this.$wrap.find(".jey-body").html(
|
||||
`<p>Setup complete! Redirecting...</p>`
|
||||
);
|
||||
setTimeout(() => {
|
||||
window.location.href = "/app";
|
||||
}, 1500);
|
||||
} else if (m.status === "error") {
|
||||
this.show_error(m.failure_message || "Setup failed", m.traceback);
|
||||
} else {
|
||||
this.show_error(
|
||||
"Setup returned unexpected response: " +
|
||||
JSON.stringify(r.message || {})
|
||||
"Setup returned unexpected response",
|
||||
JSON.stringify(m, null, 2)
|
||||
);
|
||||
}
|
||||
},
|
||||
error: () => {
|
||||
const msg =
|
||||
(frappe.last_response && frappe.last_response.setup_wizard_failure_message) ||
|
||||
"Setup failed — check server logs.";
|
||||
this.show_error(msg);
|
||||
const resp = frappe.last_response || {};
|
||||
this.show_error(
|
||||
resp.setup_wizard_failure_message || "Setup failed",
|
||||
resp.exc || resp.exception || ""
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
show_error(msg) {
|
||||
this.$wrap.find(".jey-status").text(msg);
|
||||
show_error(summary, detail) {
|
||||
this.$wrap.find(".jey-body").html(`
|
||||
<h3 style="color:#c00;margin-bottom:8px">${frappe.utils.escape_html(summary)}</h3>
|
||||
<pre style="max-height:360px;overflow:auto;background:#f7f7f7;padding:12px;border-radius:4px;font-size:12px;white-space:pre-wrap">${
|
||||
detail ? frappe.utils.escape_html(String(detail)) : "(no details)"
|
||||
}</pre>
|
||||
`);
|
||||
this.$wrap.find(".jey-status").empty();
|
||||
this.$wrap.find(".jey-nav")
|
||||
.empty()
|
||||
.html(`<button class="btn btn-default jey-retry">Retry</button>`)
|
||||
|
|
|
|||
Loading…
Reference in New Issue