def add_photo_to_property(data): request_data = json.loads(data) prop_dict = {"user_id":request_data.get("user_id"), "sid":request_data.get("sid"), "property_id":request_data.get("property_id"), "fields":["thumbnails", "full_size_images", "property_photo"]} field_dict = {} prop_response = get_property_details(json.dumps(prop_dict)) if request_data.get("property_photos"): photo_dict = store_property_photos_in_propshikari(request_data.get("property_photos"),request_data.get("property_id")) photo_dict.get("full_size").extend(prop_response.get("data").get("full_size_images", [])) photo_dict.get("thumbnails").extend(prop_response.get("data").get("thumbnails", [])) field_dict["full_size_images"] = photo_dict.get("full_size") field_dict["thumbnails"] = photo_dict.get("thumbnails") field_dict["property_photo"] = field_dict.get("thumbnails")[0] if len(field_dict.get("thumbnails")) else "" search_query = {"doc": field_dict } es = ElasticSearchController() update_response = es.update_docuemnt("property", request_data.get("property_id"), search_query) prop_response = get_property_details(json.dumps(prop_dict)) return { "message":"Property Photos Updated successfully", "full_size_images":prop_response.get("data").get("full_size_images", []), "thumbnails":prop_response.get("data").get("thumbnails", []), "property_photo":prop_response.get("data").get("property_photo", []) } else: raise DoesNotExistError("Images not Attached")
def add_photo_to_property(data): request_data = json.loads(data) prop_dict = {"user_id":request_data.get("user_id"), "sid":request_data.get("sid"), "property_id":request_data.get("property_id"), "fields":["thumbnails", "full_size_images", "property_photo"]} field_dict = {} prop_response = get_property_details(json.dumps(prop_dict)) if request_data.get("property_photos"): photo_dict = store_property_photos_in_propshikari(request_data.get("property_photos"),request_data.get("property_id")) photo_dict.get("full_size").extend(prop_response.get("data").get("full_size_images", [])) photo_dict.get("thumbnails").extend(prop_response.get("data").get("thumbnails", [])) field_dict["full_size_images"] = photo_dict.get("full_size") field_dict["thumbnails"] = photo_dict.get("thumbnails") field_dict["property_photo"] = field_dict.get("thumbnails")[0] if len(field_dict.get("thumbnails")) else "" search_query = {"doc": field_dict } es = ElasticSearchController() update_response = es.update_docuemnt("property", request_data.get("property_id"), search_query) prop_response = get_property_details(json.dumps(prop_dict)) return { "message":"Property Photos Updated successfully", "full_size_images":prop_response.get("data").get("full_size_images", []), "thumbnails":prop_response.get("data").get("thumbnails", []), "property_photo":prop_response.get("data").get("property_photo", []) } else: raise DoesNotExistError("Images not Attached")
def update_project_photos(field_dict, property_fields, custom_id, es): if property_fields.get("project_photos"): photo_dict = store_property_photos_in_propshikari(property_fields.get("project_photos"), custom_id) photo_dict.get("full_size").extend(property_fields.get("full_size_images", [])) photo_dict.get("thumbnails").extend(property_fields.get("thumbnails", [])) field_dict["full_size_images"] = photo_dict.get("full_size") field_dict["thumbnails"] = photo_dict.get("thumbnails") field_dict["project_photo"] = field_dict.get("thumbnails")[0] if len(field_dict.get("thumbnails")) else "" add_photo_to_properties(field_dict, custom_id, es)
def update_project_photos(field_dict, property_fields, custom_id, es): if property_fields.get("project_photos"): photo_dict = store_property_photos_in_propshikari(property_fields.get("project_photos"), custom_id) photo_dict.get("full_size").extend(property_fields.get("full_size_images", [])) photo_dict.get("thumbnails").extend(property_fields.get("thumbnails", [])) field_dict["full_size_images"] = photo_dict.get("full_size") field_dict["thumbnails"] = photo_dict.get("thumbnails") field_dict["project_photo"] = field_dict.get("thumbnails")[0] if len(field_dict.get("thumbnails")) else "" add_photo_to_properties(field_dict, custom_id, es)
def init_for_project_photo_upload(request_data, project_data): property_photo_url_dict = store_property_photos_in_propshikari( request_data.get("project_photos"), project_data.get("project_id")) project_data["full_size_images"] = property_photo_url_dict.get( "full_size", []) project_data["thumbnails"] = property_photo_url_dict.get("thumbnails", []) project_data["project_photo"] = property_photo_url_dict.get( "thumbnails")[0] if len( property_photo_url_dict.get("thumbnails")) else "" project_data["percent_completion"] = putil.calculate_percent_completion( project_data, project_mandatory_fields)
def init_for_project_photo_upload(request_data, project_data): property_photo_url_dict = store_property_photos_in_propshikari(request_data.get("project_photos"), project_data.get("project_id")) project_data["full_size_images"] = property_photo_url_dict.get("full_size",[]) project_data["thumbnails"] = property_photo_url_dict.get("thumbnails",[]) project_data["project_photo"] = property_photo_url_dict.get("thumbnails")[0] if len(property_photo_url_dict.get("thumbnails")) else "" project_data["percent_completion"] = putil.calculate_percent_completion(project_data, project_mandatory_fields)