Exemplo n.º 1
0
def shortlist_property(request_data):
	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")
		property_name = frappe.db.get_value("Shortlisted Property", {"property_id":request_data.get("property_id"), "user_id":request_data.get("user_id")} ,["name","status"], as_dict=1)
		if property_name:
			if property_name.get("status") == 'Active':	
				raise DuplicateEntryError("Property {0} already Shortlisted".format(request_data.get("property_id")))
			elif property_name.get("status") == 'Inactive':
				sp_doc = frappe.get_doc("Shortlisted Property", property_name.get("name"))
				sp_doc.status = "Active"
				sp_doc.save(ignore_permissions=True)
		else:
			try:
				sp_doc = frappe.new_doc("Shortlisted Property")
				sp_doc.user_id = request_data.get("user_id")
				sp_doc.property_id = request_data.get("property_id")
				sp_doc.status = "Active"
				sp_doc.save()
				es = ElasticSearchController()
				es.refresh_index()
			except frappe.MandatoryError,e:
				raise MandatoryError("Mandatory Field {0} missing".format(e.message))
			except (frappe.LinkValidationError, frappe.ValidationError)  as e:
				raise InvalidDataError(e.message)
			except Exception,e:
				raise OperationFailed("Shortlist Property Operation Failed")
Exemplo n.º 2
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)
Exemplo n.º 3
0
def update_unpublished_property_flag(request_data):
	if request_data:
		try:
			property_data = prepare_query_of_published_properties(request_data.get("property_ids"))
			es = ElasticSearchController()
			response = es.bulk_upload(property_data)
			es.refresh_index()
			return {"operation":"Update" , "message":"Unpublished property status changed" if response else "upublished Status not changed", "user_id":request_data.get("user_id")}
		except elasticsearch.TransportError:
			raise DoesNotExistError("Property Id does not exists")
		except elasticsearch.ElasticsearchException,e:
			raise e	
		except Exception,e:
			raise OperationFailed("Update Property Status Operation Failed")
def update_unpublished_property_flag(request_data):
	if request_data:
		try:
			property_data = prepare_query_of_published_properties(request_data.get("property_ids"))
			es = ElasticSearchController()
			response = es.bulk_upload(property_data)
			es.refresh_index()
			return {"operation":"Update" , "message":"Unpublished property status changed" if response else "upublished Status not changed", "user_id":request_data.get("user_id")}
		except elasticsearch.TransportError:
			raise DoesNotExistError("Property Id does not exists")
		except elasticsearch.ElasticsearchException,e:
			raise e	
		except Exception,e:
			raise OperationFailed("Update Property Status Operation Failed")
Exemplo n.º 5
0
def shortlist_property(request_data):
    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")
        property_name = frappe.db.get_value(
            "Shortlisted Property", {
                "property_id": request_data.get("property_id"),
                "user_id": request_data.get("user_id")
            }, ["name", "status"],
            as_dict=1)
        if property_name:
            if property_name.get("status") == 'Active':
                raise DuplicateEntryError(
                    "Property {0} already Shortlisted".format(
                        request_data.get("property_id")))
            elif property_name.get("status") == 'Inactive':
                sp_doc = frappe.get_doc("Shortlisted Property",
                                        property_name.get("name"))
                sp_doc.status = "Active"
                sp_doc.save(ignore_permissions=True)
        else:
            try:
                sp_doc = frappe.new_doc("Shortlisted Property")
                sp_doc.user_id = request_data.get("user_id")
                sp_doc.property_id = request_data.get("property_id")
                sp_doc.status = "Active"
                sp_doc.save()
                es = ElasticSearchController()
                es.refresh_index()
            except frappe.MandatoryError, e:
                raise MandatoryError("Mandatory Field {0} missing".format(
                    e.message))
            except (frappe.LinkValidationError, frappe.ValidationError) as e:
                raise InvalidDataError(e.message)
            except Exception, e:
                raise OperationFailed("Shortlist Property Operation Failed")
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)