コード例 #1
0
def update_project(request_data):
    user_email = putil.validate_for_user_id_exists(
        request_data.get("fields").get("user_id"))
    try:
        field_dict = putil.validate_property_posting_data(
            request_data.get("fields"),
            "property_json/project_post_mapper.json")
        get_modified_datetime(field_dict, user_email)

        es = ElasticSearchController()
        update_project_photos(field_dict, request_data.get("fields"),
                              request_data.get("project_id"), es)
        field_dict["possession_status"] = "Immediate" if field_dict.get(
            "possession") else field_dict.get("possession_date")
        search_query = {"doc": field_dict}
        update_response = es.update_docuemnt("project",
                                             request_data.get("project_id"),
                                             search_query)
        percent_script = get_percent_completion_script(
            project_mandatory_fields)
        per_response = es.update_docuemnt("project",
                                          request_data.get("project_id"),
                                          percent_script)
        return {"opeartion": "Update", "message": "Project details Updated"}
    except elasticsearch.TransportError:
        raise DoesNotExistError("Project Id does not exists")
    except elasticsearch.ElasticsearchException, e:
        raise ElasticSearchException(e.error)
コード例 #2
0
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")
コード例 #3
0
def delete_multiple_photos(data):
	data = json.loads(data)
	full_size_img = [img_url.replace("thumbnail", "regular") for img_url in data.get("img_list")]
	
	prop_dict = {"user_id":data.get("user_id"), "sid":data.get("sid"), "property_id":data.get("property_id")}
	
	doc = get_property_details(json.dumps(prop_dict))
	property_photo = get_property_photo(data.get("img_list"),doc.get("data").get("thumbnails"))
	
	update_query = get_script_query_for_multiple(full_size_img,data.get("img_list"),property_photo)
	
	if not doc.get("data").get("project_id",""):
		map(lambda img_url:delete_photo_from_propshikari(img_url),data.get("img_list")) 
	es = ElasticSearchController()
	response = es.update_docuemnt("property", data.get("property_id"), update_query)
	prop_dict = {"user_id":data.get("user_id"), "sid":data.get("sid"), "property_id":data.get("property_id"), 
					"fields":["thumbnails", "full_size_images", "property_photo"]}
	prop_response = get_property_details(json.dumps(prop_dict))
	
	return { 
				"message":"Property Photo deleted 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", [])
			}
コード例 #4
0
def remove_tag_of_property(data):
    request_data = json.loads(data)
    user_email = putil.validate_for_user_id_exists(request_data.get("user_id"))
    user_data = frappe.db.get_value("User", {"email": user_email},
                                    "user_type",
                                    as_dict=True)
    if user_data.get("user_type") == "System User":
        try:
            es = ElasticSearchController()
            response = es.search_document_for_given_id(
                "property", request_data.get("property_id"), [], [])
            get_modified_datetime(response, user_email)
            update_query = get_update_tag_query(request_data,
                                                request_data.get('tags')[0],
                                                response)
            es = ElasticSearchController()
            update_response = es.update_docuemnt(
                "property", request_data.get("property_id"), update_query)
            es = ElasticSearchController()
            es.refresh_index()
            return {
                "operation": "update",
                "user_id": request_data.get("user_id"),
                "message": "Property Tags Updated Successfully"
            }
        except elasticsearch.TransportError:
            raise DoesNotExistError("Property Id does not exists")
        except elasticsearch.ElasticsearchException, e:
            raise ElasticSearchException(e.error)
コード例 #5
0
def delete_property_photo(doc, img_url):
    full_size_img = img_url.replace("thumbnail", "regular")
    update_query = get_script_query(full_size_img, img_url)
    if not doc.get("project_id", "") or (img_url.find("PROP") != -1):
        delete_photo_from_propshikari(img_url)
    es = ElasticSearchController()
    response = es.update_docuemnt("property", doc.get("property_id"),
                                  update_query)
    prop_dict = {
        "user_id": doc.get("user_id"),
        "sid": doc.get("sid"),
        "property_id": doc.get("property_id"),
        "fields": ["thumbnails", "full_size_images", "property_photo"]
    }
    prop_response = get_property_details(json.dumps(prop_dict))
    return {
        "message":
        "Property Photo deleted successfully",
        "full_size":
        ','.join(prop_response.get("data").get("full_size_images", [])),
        "thumbnails":
        ','.join(prop_response.get("data").get("thumbnails", [])),
        "photo":
        prop_response.get("data").get("property_photo", [])
    }
コード例 #6
0
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")
コード例 #7
0
def delete_multiple_photos(data):
	data = json.loads(data)
	full_size_img = [img_url.replace("thumbnail", "regular") for img_url in data.get("img_list")]
	
	prop_dict = {"user_id":data.get("user_id"), "sid":data.get("sid"), "property_id":data.get("property_id")}
	
	doc = get_property_details(json.dumps(prop_dict))
	property_photo = get_property_photo(data.get("img_list"),doc.get("data").get("thumbnails"))
	
	update_query = get_script_query_for_multiple(full_size_img,data.get("img_list"),property_photo)
	
	if not doc.get("data").get("project_id",""):
		map(lambda img_url:delete_photo_from_propshikari(img_url),data.get("img_list")) 
	es = ElasticSearchController()
	response = es.update_docuemnt("property", data.get("property_id"), update_query)
	prop_dict = {"user_id":data.get("user_id"), "sid":data.get("sid"), "property_id":data.get("property_id"), 
					"fields":["thumbnails", "full_size_images", "property_photo"]}
	prop_response = get_property_details(json.dumps(prop_dict))
	
	return { 
				"message":"Property Photo deleted 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", [])
			}
コード例 #8
0
def update_project(request_data):
	user_email = putil.validate_for_user_id_exists(request_data.get("fields").get("user_id"))
	try:
		field_dict = putil.validate_property_posting_data(request_data.get("fields"), "property_json/project_post_mapper.json")
		get_modified_datetime(field_dict, user_email)
		
		es = ElasticSearchController()
		update_project_photos(field_dict, request_data.get("fields"), request_data.get("project_id"), es)
		field_dict["possession_status"] = "Immediate" if field_dict.get("possession") else field_dict.get("possession_date")
		search_query = {"doc": field_dict }
		update_response = es.update_docuemnt("project", request_data.get("project_id"), search_query)
		percent_script = get_percent_completion_script(project_mandatory_fields)
		per_response = es.update_docuemnt("project", request_data.get("project_id"), percent_script)
		return {"opeartion":"Update", "message":"Project details Updated"}
	except elasticsearch.TransportError:
		raise DoesNotExistError("Project Id does not exists")
	except elasticsearch.ElasticsearchException,e:
		raise ElasticSearchException(e.error)
コード例 #9
0
def delete_project_photo(doc, img_url):
	full, thumbnails, photo = init_for_photo_list_operation(doc, img_url)
	es = ElasticSearchController()
	search_query = {"doc":{ "full_size_images":full, "thumbnails":thumbnails, "project_photo":photo }}
	response = es.update_docuemnt("project", doc.get("project_id"), search_query)
	init_for_property_photo_update(es, img_url, doc.get("project_id"))
	return { 
				"message":"Project Photo deleted successfully",
				"full_size":','.join(full),
				"thumbnails":','.join(thumbnails),
				"photo":photo
			}
コード例 #10
0
def delete_project_photo(doc, img_url):
	full, thumbnails, photo = init_for_photo_list_operation(doc, img_url)
	es = ElasticSearchController()
	search_query = {"doc":{ "full_size_images":full, "thumbnails":thumbnails, "project_photo":photo }}
	response = es.update_docuemnt("project", doc.get("project_id"), search_query)
	init_for_property_photo_update(es, img_url, doc.get("project_id"))
	return { 
				"message":"Project Photo deleted successfully",
				"full_size":','.join(full),
				"thumbnails":','.join(thumbnails),
				"photo":photo
			}
コード例 #11
0
def update_property_fields(data):
	request_data = json.loads(data)
	user_email = putil.validate_for_user_id_exists(request_data.get("user_id"))
	try:
		field_dict = get_updated_fields_dict(request_data, user_email)
		search_query = {"doc": field_dict }
		es = ElasticSearchController()
		update_response = es.update_docuemnt("property", request_data.get("property_id"), search_query)
		return {"opeartion":"Update", "message":"Property details Updated"}
	except elasticsearch.TransportError:
		raise DoesNotExistError("Property Id does not exists")
	except elasticsearch.ElasticsearchException,e:
		raise ElasticSearchException(e.error)
コード例 #12
0
def update_property_fields(data):
	request_data = json.loads(data)
	user_email = putil.validate_for_user_id_exists(request_data.get("user_id"))
	try:
		field_dict = get_updated_fields_dict(request_data, user_email)
		search_query = {"doc": field_dict }
		es = ElasticSearchController()
		update_response = es.update_docuemnt("property", request_data.get("property_id"), search_query)
		return {"opeartion":"Update", "message":"Property details Updated"}
	except elasticsearch.TransportError:
		raise DoesNotExistError("Property Id does not exists")
	except elasticsearch.ElasticsearchException,e:
		raise ElasticSearchException(e.error)
コード例 #13
0
def delete_property_photo(doc, img_url):
	full_size_img = img_url.replace("thumbnail", "regular")
	update_query = get_script_query(full_size_img, img_url)
	if not doc.get("project_id","") or (img_url.find("PROP")!= -1):
		delete_photo_from_propshikari(img_url)
	es = ElasticSearchController()	
	response = es.update_docuemnt("property", doc.get("property_id"), update_query)
	prop_dict = {"user_id":doc.get("user_id"), "sid":doc.get("sid"), "property_id":doc.get("property_id"), 
					"fields":["thumbnails", "full_size_images", "property_photo"]}
	prop_response =get_property_details(json.dumps(prop_dict))
	return { 
				"message":"Property Photo deleted successfully",
				"full_size":','.join(prop_response.get("data").get("full_size_images", [])),
				"thumbnails":','.join(prop_response.get("data").get("thumbnails", [])),
				"photo":prop_response.get("data").get("property_photo", [])
			}
コード例 #14
0
def upadate_project_status(request_data):
	email = putil.validate_for_user_id_exists(request_data.get("user_id"))
	putil.validate_property_data(request_data, ["project_id"])
	try:
		search_query = {"doc":{ "status":request_data.get("project_status") }}
		es = ElasticSearchController()
		response = es.update_docuemnt("project", request_data.get("project_id"), search_query)
		return {
				"operation":"Update" , 
				"message":"Project status changed" if response else "Project Status not changed", 
				"user_id":request_data.get("user_id")
				}
	except elasticsearch.TransportError:
		raise DoesNotExistError("Project Id does not exists")
	except elasticsearch.ElasticsearchException,e:
		raise ElasticSearchException(e.error)	
コード例 #15
0
def upadate_project_status(request_data):
	email = putil.validate_for_user_id_exists(request_data.get("user_id"))
	putil.validate_property_data(request_data, ["project_id"])
	try:
		search_query = {"doc":{ "status":request_data.get("project_status") }}
		es = ElasticSearchController()
		response = es.update_docuemnt("project", request_data.get("project_id"), search_query)
		return {
				"operation":"Update" , 
				"message":"Project status changed" if response else "Project Status not changed", 
				"user_id":request_data.get("user_id")
				}
	except elasticsearch.TransportError:
		raise DoesNotExistError("Project Id does not exists")
	except elasticsearch.ElasticsearchException,e:
		raise ElasticSearchException(e.error)	
コード例 #16
0
def remove_tag_of_property(data):
	request_data = json.loads(data)
	user_email = putil.validate_for_user_id_exists(request_data.get("user_id"))
	user_data = frappe.db.get_value("User",{"email":user_email}, "user_type", as_dict=True)
	if user_data.get("user_type") == "System User":
		try:
			es = ElasticSearchController()
			response = es.search_document_for_given_id("property",request_data.get("property_id"), [], [])
			get_modified_datetime(response, user_email)
			update_query = get_update_tag_query(request_data,request_data.get('tags')[0],response)
			es = ElasticSearchController()
			update_response = es.update_docuemnt("property", request_data.get("property_id"),update_query)
			es = ElasticSearchController()
			es.refresh_index()
			return {	
						"operation":"update", 
						"user_id":request_data.get("user_id"), 
						"message":"Property Tags Updated Successfully"
					}
		except elasticsearch.TransportError:
			raise DoesNotExistError("Property Id does not exists")
		except elasticsearch.ElasticsearchException,e:
			raise ElasticSearchException(e.error)