def _create_estate(self, item, origin_id, client_id, estate_type): history = HistoryMeta() history.created = datetime.datetime.now() history.created_by_id = self.USER_ID history.save() e = Estate() e.history = history e.estate_category_id = estate_type.estate_type_category_id e._estate_type_id = estate_type.id e.origin_id = origin_id e.agency_price = self.clean_price_digit(item['price_digit']) e.estate_status_id = EstateStatus.NEW e.description = self.get_description(item) e.region_id = item['region_id'] if 'locality_id' in item: e.locality_id = item['locality_id'] e.save() if item.has_extra_bidg(): bidg = e.basic_bidg for field in item.BIDG_FIELDS: if field in item: setattr(bidg, field, item[field]) bidg.save() EstateClient.objects.create(client_id=client_id, estate_client_status_id=EstateClient.ESTATE_CLIENT_STATUS, estate=e) return e
def _create_estate(self, spider_data, client_id): history = HistoryMeta() history.created = datetime.datetime.now() history.created_by_id = self.USER_ID history.save() e = Estate() e.history = history estate_type = EstateType.objects.get(pk=spider_data.item.estate_type_id) e.estate_category_id = estate_type.estate_type_category_id e._estate_type_id = estate_type.id e.origin_id = spider_data.item.origin_id e.agency_price = spider_data.item.price_digit e.estate_status_id = EstateStatus.NEW e.description = spider_data.item.note e.region_id = Locality.objects.get(pk=spider_data.item.locality_id).region_id e.locality_id = spider_data.item.locality_id e.save() if spider_data.has_bidg(): bidg = e.basic_bidg for k,v in spider_data._bidg.iteritems(): if v: setattr(bidg, k, v) bidg.save() EstateClient.objects.create(client_id=client_id, estate_client_status_id=EstateClient.ESTATE_CLIENT_STATUS, estate=e) return e
def _create_estate(self, spider_data, client_id): history = HistoryMeta() history.created = datetime.datetime.now() history.created_by_id = self.USER_ID history.save() e = Estate() e.history = history estate_type = EstateType.objects.get( pk=spider_data.item.estate_type_id) e.estate_category_id = estate_type.estate_type_category_id e._estate_type_id = estate_type.id e.origin_id = spider_data.item.origin_id e.agency_price = spider_data.item.price_digit e.estate_status_id = EstateStatus.NEW e.description = spider_data.item.note e.region_id = Locality.objects.get( pk=spider_data.item.locality_id).region_id e.locality_id = spider_data.item.locality_id e.save() if spider_data.has_bidg(): bidg = e.basic_bidg for k, v in spider_data._bidg.iteritems(): if v: setattr(bidg, k, v) bidg.save() EstateClient.objects.create( client_id=client_id, estate_client_status_id=EstateClient.ESTATE_CLIENT_STATUS, estate=e) return e
def _create_client(self, name, origin_id): CLIENT_TYPE_ID = 3 #Частное лицо history = HistoryMeta() history.created = datetime.datetime.now() history.created_by_id = self.USER_ID history.save() client = Client.objects.create(history=history, name=name, client_type_id = CLIENT_TYPE_ID, origin_id=origin_id) return client