Esempio n. 1
0
def post_property(doc, sid):
    """
		1. Either pop up the keys that are not needed or make and mapper and map the fields
		2. Create json doc for uploading
		3. Return Response
	"""
    agent_flag = get_user_roles(
    ) if frappe.session.user != "Administrator" else False
    doc = json.loads(doc)
    doc["user_id"] = frappe.db.get_value("User", {"name": frappe.session.user},
                                         "user_id")
    doc["sid"] = sid
    doc["amenities"] = [
        amenity.get("amenity_name") for amenity in doc.get("amenities")
        if amenity.get("status") == "Yes"
    ]
    doc["flat_facilities"] = [
        facility.get("facility_name")
        for facility in doc.get("flat_facilities")
        if facility.get("status") == "Yes"
    ]

    validate_for_possesion_date(doc)
    doc["distance_from_imp_locations"] = {
        "airport": doc.get("airport"),
        "central_bus_stand": doc.get("central_bus_stand"),
        "railway_station": doc.get("railway_station")
    }
    data = json.dumps(doc)

    try:
        doc_rec = api.post_property(data)
        update_agent_package() if agent_flag else ""
    except Exception, e:
        frappe.throw(e)
Esempio n. 2
0
def post_property(doc,sid):
	"""
		1. Either pop up the keys that are not needed or make and mapper and map the fields
		2. Create json doc for uploading
		3. Return Response
	"""
	agent_flag = get_user_roles()
	doc = json.loads(doc)
	doc["user_id"] = frappe.db.get_value("User",{"name":frappe.session.user},"user_id")
	doc["sid"] = sid
	doc["amenities"] = [ amenity.get("amenity_name") for amenity in doc.get("amenities") if amenity.get("status") == "Yes" ]
	doc["flat_facilities"] = [ facility.get("facility_name") for facility in doc.get("flat_facilities") if facility.get("status") == "Yes" ]
	
	validate_for_possesion_date(doc)
	doc["distance_from_imp_locations"] = {"airport" :doc.get("airport"), "central_bus_stand":doc.get("central_bus_stand"), "railway_station":doc.get("railway_station")}
	data = json.dumps(doc)
	
	try:
		doc_rec = api.post_property(data)
		update_agent_package() if agent_flag else ""
	except Exception,e:
		frappe.throw(e)
Esempio n. 3
0
def post_property(data):
    return api.post_property(data)
Esempio n. 4
0
def post_property(data):
	return api.post_property(data)