diff --git a/modules/creditmutuel/pages.py b/modules/creditmutuel/pages.py index f09d8ef6d3388aec9b6cc8547a68da9d5602ad95..4022d55f6b7785fd5e26fbd378a569e6612a6d7f 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"]'):