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 | 330dae9 | 2013-09-10 13:46:15 +0530 | [diff] [blame] | 2 | # License: GNU General Public License v3. See license.txt |
| 3 | |
| 4 | from __future__ import unicode_literals |
| 5 | import webnotes |
| 6 | from webnotes.utils import cint |
| 7 | |
Anand Doshi | b0d996f | 2013-09-10 18:29:39 +0530 | [diff] [blame] | 8 | no_cache = True |
| 9 | |
Anand Doshi | 330dae9 | 2013-09-10 13:46:15 +0530 | [diff] [blame] | 10 | def get_context(): |
| 11 | def _get_fields(fieldnames): |
| 12 | return [webnotes._dict(zip(["label", "fieldname", "fieldtype", "options"], |
| 13 | [df.label, df.fieldname, df.fieldtype, df.options])) |
| 14 | for df in webnotes.get_doctype("Address", processed=True).get({"fieldname": ["in", fieldnames]})] |
| 15 | |
| 16 | bean = None |
| 17 | if webnotes.form_dict.name: |
| 18 | bean = webnotes.bean("Address", webnotes.form_dict.name) |
| 19 | |
| 20 | return { |
| 21 | "doc": bean.doc if bean else None, |
| 22 | "meta": webnotes._dict({ |
| 23 | "left_fields": _get_fields(["address_title", "address_type", "address_line1", "address_line2", |
| 24 | "city", "state", "pincode", "country"]), |
| 25 | "right_fields": _get_fields(["email_id", "phone", "fax", "is_primary_address", |
| 26 | "is_shipping_address"]) |
| 27 | }), |
| 28 | "cint": cint |
| 29 | } |
| 30 | |