Anand Doshi | 885e074 | 2015-03-03 14:55:30 +0530 | [diff] [blame] | 1 | # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors |
Rushabh Mehta | 3daa49a | 2014-10-21 16:16:30 +0530 | [diff] [blame] | 2 | # License: GNU General Public License v3. See license.txt |
| 3 | |
| 4 | from __future__ import unicode_literals |
| 5 | import frappe |
| 6 | from frappe import _ |
| 7 | from frappe.utils import cstr |
Anand Doshi | 06ad308 | 2015-09-23 12:46:59 +0530 | [diff] [blame] | 8 | from erpnext.shopping_cart.cart import get_customer |
Rushabh Mehta | 3daa49a | 2014-10-21 16:16:30 +0530 | [diff] [blame] | 9 | |
| 10 | no_cache = 1 |
| 11 | no_sitemap = 1 |
| 12 | |
| 13 | def get_context(context): |
Anand Doshi | 06ad308 | 2015-09-23 12:46:59 +0530 | [diff] [blame] | 14 | party = get_customer() |
| 15 | mobile_no, phone = frappe.db.get_value("Contact", {"email_id": frappe.session.user, |
| 16 | "customer": party.name}, ["mobile_no", "phone"]) |
| 17 | |
Rushabh Mehta | 3daa49a | 2014-10-21 16:16:30 +0530 | [diff] [blame] | 18 | return { |
| 19 | "company_name": cstr(party.customer_name if party.doctype == "Customer" else party.company_name), |
| 20 | "mobile_no": cstr(mobile_no), |
| 21 | "phone": cstr(phone) |
| 22 | } |
Anand Doshi | 06ad308 | 2015-09-23 12:46:59 +0530 | [diff] [blame] | 23 | |
Rushabh Mehta | 3daa49a | 2014-10-21 16:16:30 +0530 | [diff] [blame] | 24 | @frappe.whitelist() |
| 25 | def update_user(fullname, password=None, company_name=None, mobile_no=None, phone=None): |
| 26 | from erpnext.shopping_cart.cart import update_party |
| 27 | update_party(fullname, company_name, mobile_no, phone) |
Anand Doshi | 06ad308 | 2015-09-23 12:46:59 +0530 | [diff] [blame] | 28 | |
Rushabh Mehta | 3daa49a | 2014-10-21 16:16:30 +0530 | [diff] [blame] | 29 | if not fullname: |
| 30 | return _("Name is required") |
Anand Doshi | 06ad308 | 2015-09-23 12:46:59 +0530 | [diff] [blame] | 31 | |
Rushabh Mehta | 3daa49a | 2014-10-21 16:16:30 +0530 | [diff] [blame] | 32 | frappe.db.set_value("User", frappe.session.user, "first_name", fullname) |
| 33 | frappe.local.cookie_manager.set_cookie("full_name", fullname) |
Anand Doshi | 06ad308 | 2015-09-23 12:46:59 +0530 | [diff] [blame] | 34 | |
Rushabh Mehta | 3daa49a | 2014-10-21 16:16:30 +0530 | [diff] [blame] | 35 | return _("Updated") |