Skip to content
Commits on Source (5)
......@@ -116,7 +116,10 @@ def get_amount(self, instructions, account):
if ('nomDispositif' in ins and 'montantNet' in ins and 'codeDispositif' in ins
and '%s%s' % (ins['nomDispositif'], ins['codeDispositif'])
== '%s%s' % (account.label, account.id)):
amount += ins['montantNet']
if ins['type'] == 'RACH_TIT':
amount -= ins['montantNet']
else:
amount += ins['montantNet']
return CleanDecimal().filter(amount)
......
......@@ -68,10 +68,10 @@ def obj_type(self):
elif 'location' in url:
isFurnished = False
for li in XPath('//ul[@itemprop="description"]/li')(self):
label = CleanText('./div[has-class("criteria-label")]')(li)
label = CleanText('./span[has-class("criteria-label")]')(li)
if label.lower() == "meublé":
isFurnished = (
CleanText('./div[has-class("criteria-value")]')(li).lower() == 'oui'
CleanText('./span[has-class("criteria-value")]')(li).lower() == 'oui'
)
if isFurnished:
return POSTS_TYPES.FURNISHED_RENT
......@@ -186,8 +186,8 @@ def obj_details(self):
)
for li in XPath('//ul[@itemprop="description"]/li')(self):
label = CleanText('./div[has-class("criteria-label")]')(li)
value = CleanText('./div[has-class("criteria-value")]')(li)
label = CleanText('./span[has-class("criteria-label")]')(li)
value = CleanText('./span[has-class("criteria-value")]')(li)
details[label] = value
return details
......@@ -252,7 +252,7 @@ class iter_housings(ListElement):
class item(ItemElement):
offer_details_wrapper = (
'./div/div/div[has-class("offer-details-wrapper")]'
'.//div[has-class("offer-details-wrapper")]'
)
klass = Housing
......@@ -265,7 +265,7 @@ class item(ItemElement):
obj_advert_type = ADVERT_TYPES.PROFESSIONAL
def obj_house_type(self):
house_type = CleanText('.//p[has-class("offer-type")]')(self).lower()
house_type = CleanText('.//div[has-class("offer-details-type")]/a')(self).split(' ')[0].lower()
if house_type == "appartement":
return HOUSE_TYPES.APART
elif house_type == "maison":
......@@ -277,14 +277,11 @@ def obj_house_type(self):
else:
return HOUSE_TYPES.OTHER
obj_title = Attr(
offer_details_wrapper + '/div/div/p[@class="offer-type"]/a',
'title'
)
obj_title = CleanText('.//div[has-class("offer-details-type")]/a/@title')
obj_url = Format(u'%s%s',
CleanText('./div/div/div/div/div/p/a[@class="offer-link"]/@href'),
CleanText('./div/div/div/div/div/p/a[@class="offer-link"]/\
CleanText('.//div/a[@class="offer-link"]/@href'),
CleanText('.//div/a[@class="offer-link"]/\
@data-orpi', default=""))
obj_area = CleanDecimal(
......@@ -304,15 +301,14 @@ def obj_house_type(self):
'/span[has-class("offer-rooms")]' +
'/span[has-class("offer-rooms-number")]'
),
default=NotLoaded
default=NotAvailable
)
obj_price_per_meter = PricePerMeterFilter()
obj_cost = CleanDecimal(
Regexp(
CleanText(
(
offer_details_wrapper +
'/div/div/p[@class="offer-price"]/span'
'/div/p[@class="offer-price"]/span'
),
default=NotLoaded
),
......@@ -322,22 +318,16 @@ def obj_house_type(self):
default=NotLoaded
)
obj_currency = Currency(
offer_details_wrapper + '/div/div/p[has-class("offer-price")]/span'
offer_details_wrapper + '/div/p[has-class("offer-price")]/span'
)
obj_price_per_meter = PricePerMeterFilter()
obj_utilities = UTILITIES.UNKNOWN
obj_date = Date(
Regexp(
CleanText(
'./div/div/div[has-class("offer-picture-more")]/div/p[has-class("offer-update")]'
),
".*(\d{2}/\d{2}/\d{4}).*")
)
obj_text = CleanText(
offer_details_wrapper + '/div/div/div/p[has-class("offer-description")]/span'
)
obj_location = CleanText(
offer_details_wrapper +
'//div[has-class("offer-places-block")]'
offer_details_wrapper + '/div[@class="offer-details-location"]',
replace=[('Voir sur la carte','')]
)
def obj_photos(self):
......
......@@ -28,11 +28,10 @@ class LogicimmoTest(BackendTest, HousingTest):
FIELDS_ALL_HOUSINGS_LIST = [
"id", "type", "advert_type", "house_type", "url", "title", "area",
"cost", "currency", "utilities", "date", "location", "text",
"details"
"details", "rooms"
]
FIELDS_ANY_HOUSINGS_LIST = [
"photos",
"rooms"
]
FIELDS_ALL_SINGLE_HOUSING = [
"id", "url", "type", "advert_type", "house_type", "title", "area",
......@@ -47,6 +46,7 @@ class LogicimmoTest(BackendTest, HousingTest):
"DPE",
"GES"
]
DO_NOT_DISTINGUISH_FURNISHED_RENT = True
def test_logicimmo_rent(self):
query = Query()
......
......@@ -58,6 +58,7 @@ class get_account(ItemElement):
obj_label = obj_id
obj_currency = u'EUR'
obj_balance = MyDecimal('//p[@class="num"]/a')
obj_cardlimit = MyDecimal('//div[has-class("solde_actu")]')
# Every subscription a product token and a type ex: card = 240
obj__product_token = Regexp(CleanText('//div[contains(@id, "product")]/@id'), r'productLine_(\d*)')
......
......@@ -180,14 +180,14 @@ def filter(self, el):
if el.attrib.get('type') in ('radio', 'checkbox'):
return 'checked' in el.attrib
# regular text input
elif el.attrib.get('type', '') in ('', 'text', 'email', 'search', 'tel', 'url'):
elif el.attrib.get('type', '') in ('', 'text', 'email', 'search', 'tel', 'url', 'password', 'hidden'):
try:
return unicode(el.attrib['value'])
except KeyError:
return self.default_or_raise(AttributeNotFound('Element %s does not have attribute value' % el))
# TODO handle html5 number, datetime, etc.
else:
raise UnrecognizedElement('Element %s is recognized' % el)
raise UnrecognizedElement('Element %s is not recognized' % el)
elif el.tag == 'textarea':
return unicode(el.text)
elif el.tag == 'select':
......@@ -197,7 +197,7 @@ def filter(self, el):
options = el.xpath('.//option[1]')
return u'\n'.join([unicode(o.text) for o in options])
else:
raise UnrecognizedElement('Element %s is recognized' % el)
raise UnrecognizedElement('Element %s is not recognized' % el)
class HasElement(Filter):
......