def post_project(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 """ doc = json.loads(doc) doc["user_id"] = frappe.db.get_value("User",{"name":frappe.session.user},"user_id") doc["sid"] = sid doc["amenities"] = doc.get('amenities').split(',') if doc.get("amenities") else [] doc["flat_facilities"] = doc.get('flat_facilities').split(',') if doc.get("flat_facilities") else [] doc_rec = api.post_project(doc) frappe.errprint(doc_rec)
def post_project(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 """ 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["distance_from_imp_locations"] = { "airport": doc.get("airport"), "railway_station":doc.get("railway_station") , "central_bus_stand":doc.get("central_bus_stand") } validate_for_possesion_date(doc) try: doc_rec = api.post_project(doc) except Exception,e: frappe.throw(e)
def post_project(data): return projt.post_project(data)