Rushabh Mehta | ad45e31 | 2013-11-20 12:59:58 +0530 | [diff] [blame] | 1 | # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors |
Anand Doshi | b0d996f | 2013-09-10 18:29:39 +0530 | [diff] [blame] | 2 | # License: GNU General Public License v3. See license.txt |
| 3 | |
| 4 | from __future__ import unicode_literals |
| 5 | import webnotes |
Anand Doshi | 3966c4c | 2013-09-16 19:28:06 +0530 | [diff] [blame] | 6 | from webnotes import _ |
Anand Doshi | b0d996f | 2013-09-10 18:29:39 +0530 | [diff] [blame] | 7 | from webnotes.utils import cstr |
| 8 | |
| 9 | no_cache = True |
Rushabh Mehta | 915eda9 | 2013-10-11 10:56:49 +0530 | [diff] [blame] | 10 | no_sitemap = True |
Anand Doshi | b0d996f | 2013-09-10 18:29:39 +0530 | [diff] [blame] | 11 | |
| 12 | def get_context(): |
Rushabh Mehta | 1f84799 | 2013-12-12 19:12:19 +0530 | [diff] [blame] | 13 | from erpnext.selling.utils.cart import get_lead_or_customer |
Anand Doshi | b0d996f | 2013-09-10 18:29:39 +0530 | [diff] [blame] | 14 | party = get_lead_or_customer() |
| 15 | if party.doctype == "Lead": |
| 16 | mobile_no = party.mobile_no |
| 17 | phone = party.phone |
| 18 | else: |
| 19 | mobile_no, phone = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user, |
| 20 | "customer": party.name}, ["mobile_no", "phone"]) |
| 21 | |
| 22 | return { |
| 23 | "company_name": cstr(party.customer_name if party.doctype == "Customer" else party.company_name), |
| 24 | "mobile_no": cstr(mobile_no), |
| 25 | "phone": cstr(phone) |
| 26 | } |
| 27 | |
| 28 | @webnotes.whitelist() |
| 29 | def update_profile(fullname, password=None, company_name=None, mobile_no=None, phone=None): |
Rushabh Mehta | 1f84799 | 2013-12-12 19:12:19 +0530 | [diff] [blame] | 30 | from erpnext.selling.utils.cart import update_party |
Anand Doshi | b0d996f | 2013-09-10 18:29:39 +0530 | [diff] [blame] | 31 | update_party(fullname, company_name, mobile_no, phone) |
| 32 | |
Anand Doshi | 3966c4c | 2013-09-16 19:28:06 +0530 | [diff] [blame] | 33 | if not fullname: |
| 34 | return _("Name is required") |
| 35 | |
| 36 | webnotes.conn.set_value("Profile", webnotes.session.user, "first_name", fullname) |
Anand Doshi | de8b6aa | 2013-09-24 17:17:39 +0530 | [diff] [blame] | 37 | webnotes._response.set_cookie("full_name", fullname) |
Anand Doshi | 3966c4c | 2013-09-16 19:28:06 +0530 | [diff] [blame] | 38 | |
| 39 | return _("Updated") |
| 40 | |