From 309ae667efa3c8f7192ef6b744c295fbb8a2d101 Mon Sep 17 00:00:00 2001 From: Maxime Gasselin Date: Thu, 22 Nov 2018 15:51:00 +0100 Subject: [PATCH] [creditmutuel] Skip immediate debit cards In the card space, we handle some immediate debit cards. For skipping them we have to reach the good page to discriminate which is deferred or immmediate card. --- modules/creditmutuel/pages.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/creditmutuel/pages.py b/modules/creditmutuel/pages.py index f09d8ef6d3..4022d55f6b 100644 --- a/modules/creditmutuel/pages.py +++ b/modules/creditmutuel/pages.py @@ -1849,6 +1849,7 @@ def condition(self): obj_type = Account.TYPE_CARD obj__new_space = True obj__is_inv = False + load_details = Field('_link_id') & AsyncLoad def obj_currency(self): curr = CleanText('.//tbody/tr[1]/td/span')(self) @@ -1886,6 +1887,20 @@ def obj__link_id(self): def obj__parent_id(self): return re.search(r'\d+', CleanText('./div/div/div/p', replace=[(' ', '')])(self)).group(0)[-16:] + def parse(self, el): + # We have to reach the good page with the information of the type of card + async_page = Async('details').loaded_page(self) + card_type_page = Link('//div/ul/li/a[contains(text(), "Fonctions")]')(async_page.doc) + doc = self.page.browser.open(card_type_page).page.doc + card_type_line = doc.xpath('//tbody/tr[th[contains(text(), "Débit des paiements")]]') + if card_type_line: + if CleanText('./td')(card_type_line[0]) != 'Différé': + raise SkipItem() + elif doc.xpath('//div/p[contains(text(), "Vous n\'avez pas l\'autorisation")]'): + self.logger.warning("The user can't reach this page") + else: + assert False, 'xpath for card type information could have changed' + def get_unavailable_cards(self): cards = [] for card in self.doc.xpath('//li[@class="item"]'): -- GitLab