blob: 8edd830d471f078ec6691dc96e1cc5620fc0c0f7 [file] [log] [blame]
Anand Doshib0d996f2013-09-10 18:29:39 +05301# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
2# 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
10
11def get_context():
12 from selling.utils.cart import get_lead_or_customer
13 party = get_lead_or_customer()
14 if party.doctype == "Lead":
15 mobile_no = party.mobile_no
16 phone = party.phone
17 else:
18 mobile_no, phone = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user,
19 "customer": party.name}, ["mobile_no", "phone"])
20
21 return {
22 "company_name": cstr(party.customer_name if party.doctype == "Customer" else party.company_name),
23 "mobile_no": cstr(mobile_no),
24 "phone": cstr(phone)
25 }
26
27@webnotes.whitelist()
28def update_profile(fullname, password=None, company_name=None, mobile_no=None, phone=None):
29 from selling.utils.cart import update_party
30 update_party(fullname, company_name, mobile_no, phone)
31
Anand Doshi3966c4c2013-09-16 19:28:06 +053032 if not fullname:
33 return _("Name is required")
34
35 webnotes.conn.set_value("Profile", webnotes.session.user, "first_name", fullname)
36 webnotes.add_cookies["full_name"] = fullname
37
38 return _("Updated")
39