Пример #1
0
def get_property_contact(request_data):

	"""
		Get Contact person name, contact_no form property &
		generate lead & enquiry against that user. 

	"""

	if request_data:
		request_data = json.loads(request_data)
		email = putil.validate_for_user_id_exists(request_data.get("user_id"))	
		if not request_data.get("property_id"):
			raise MandatoryError("Mandatory Field Property Id missing")
		try:
			es = ElasticSearchController()
			response = es.search_document_for_given_id("property",request_data.get("property_id"),[],[])
			new_response = { "contact_no": response.get("contact_no"), "contact_person":response.get("contact_person")}
			create_lead_from_userid(request_data, email, response)
			return {	
						"operation":"Search",
						"message":"Contact Details found" if len(new_response) else "Contact Details Not Found", 
						"user_id":request_data.get("user_id"), 
						"data":new_response
					}
		except elasticsearch.TransportError:
			raise DoesNotExistError("Property Id does not exists")
		except Exception,e:
			raise e
Пример #2
0
def get_property_contact(request_data):

	"""
		Get Contact person name, contact_no form property &
		generate lead & enquiry against that user. 

	"""

	if request_data:
		request_data = json.loads(request_data)
		email = putil.validate_for_user_id_exists(request_data.get("user_id"))	
		if not request_data.get("property_id"):
			raise MandatoryError("Mandatory Field Property Id missing")
		try:
			es = ElasticSearchController()
			response = es.search_document_for_given_id("property",request_data.get("property_id"),[],[])
			mapper = {"Owner":["contact_person", "contact_no"], "Agent":["agent_name", "agent_no"], "Broker":["agent_name", "agent_no"] }
			person_key = response.get("listed_by") if response.get("listed_by") else "Owner" 
			person_no_key = response.get("listed_by") if response.get("listed_by") else "Owner" 
			new_response = { 
								"contact_person": response.get(mapper.get(person_key)[0] ), 
								"contact_no":response.get(mapper.get(person_no_key)[1] ),
								"listed_by":person_key  
							}
			create_lead_from_userid(request_data, email, response)
			return {	
						"operation":"Search",
						"message":"Contact Details found" if len(new_response) else "Contact Details Not Found", 
						"user_id":request_data.get("user_id"), 
						"data":new_response
					}
		except elasticsearch.TransportError:
			raise DoesNotExistError("Property Id does not exists")
		except Exception,e:
			print frappe.get_traceback()
			raise e
def get_property_contact(request_data):

	"""
		Get Contact person name, contact_no form property &
		generate lead & enquiry against that user. 

	"""

	if request_data:
		request_data = json.loads(request_data)
		email = putil.validate_for_user_id_exists(request_data.get("user_id"))	
		if not request_data.get("property_id"):
			raise MandatoryError("Mandatory Field Property Id missing")
		try:
			es = ElasticSearchController()
			response = es.search_document_for_given_id("property",request_data.get("property_id"),[],[])
			mapper = {"Owner":["contact_person", "contact_no"], "Agent":["agent_name", "agent_no"], "Broker":["agent_name", "agent_no"] }
			person_key = response.get("listed_by") if response.get("listed_by") else "Owner" 
			person_no_key = response.get("listed_by") if response.get("listed_by") else "Owner" 
			new_response = { 
								"contact_person": response.get(mapper.get(person_key)[0] ), 
								"contact_no":response.get(mapper.get(person_no_key)[1] ),
								"listed_by":person_key  
							}
			create_lead_from_userid(request_data, email, response)
			return {	
						"operation":"Search",
						"message":"Contact Details found" if len(new_response) else "Contact Details Not Found", 
						"user_id":request_data.get("user_id"), 
						"data":new_response
					}
		except elasticsearch.TransportError:
			raise DoesNotExistError("Property Id does not exists")
		except Exception,e:
			print frappe.get_traceback()
			raise e