blob: 241f95397423fceb882c738b6ea2a1ce423cd0a0 [file] [log] [blame]
Rushabh Mehtaad45e312013-11-20 12:59:58 +05301# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
Anand Doshib0d996f2013-09-10 18:29:39 +05302# License: GNU General Public License v3. See license.txt
3
4from __future__ import unicode_literals
5import webnotes
Anand Doshi3966c4c2013-09-16 19:28:06 +05306from webnotes import _
Anand Doshib0d996f2013-09-10 18:29:39 +05307from webnotes.utils import cstr
8
9no_cache = True
Rushabh Mehta915eda92013-10-11 10:56:49 +053010no_sitemap = True
Anand Doshib0d996f2013-09-10 18:29:39 +053011
12def get_context():
13 from selling.utils.cart import get_lead_or_customer
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()
29def update_profile(fullname, password=None, company_name=None, mobile_no=None, phone=None):
30 from selling.utils.cart import update_party
31 update_party(fullname, company_name, mobile_no, phone)
32
Anand Doshi3966c4c2013-09-16 19:28:06 +053033 if not fullname:
34 return _("Name is required")
35
36 webnotes.conn.set_value("Profile", webnotes.session.user, "first_name", fullname)
Anand Doshide8b6aa2013-09-24 17:17:39 +053037 webnotes._response.set_cookie("full_name", fullname)
Anand Doshi3966c4c2013-09-16 19:28:06 +053038
39 return _("Updated")
40