From 10d20e480f477e32e3b9feeab269345799fae723 Mon Sep 17 00:00:00 2001 From: Florent Viard Date: Fri, 9 Apr 2021 11:13:19 +0200 Subject: [PATCH] [creditmutuel] iter_documents: fixes formnotfound error when access is not allowed to documents --- modules/creditmutuel/browser.py | 18 ++++++++++++------ modules/creditmutuel/pages.py | 3 +++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/modules/creditmutuel/browser.py b/modules/creditmutuel/browser.py index d355ff2049..1b0cb6d765 100644 --- a/modules/creditmutuel/browser.py +++ b/modules/creditmutuel/browser.py @@ -1262,7 +1262,19 @@ def iter_subscriptions(self): def iter_documents(self, subscription): if self.currentSubBank is None: self.getCurrentSubBank() + + self.iban.go(subbank=self.currentSubBank) + iban_document = self.page.get_iban_document(subscription) + if iban_document: + yield iban_document + self.subscription.go(subbank=self.currentSubBank, params={'typ': 'doc'}) + + access_not_allowed_msg = "Vous ne disposez pas des droits nécessaires pour accéder à cette partie de l'application." + if access_not_allowed_msg in self.page.error_msg(): + self.logger.warning("Bank user account has insufficient right to access the documents page") + return + link_to_bank_statements = self.page.get_link_to_bank_statements() self.location(link_to_bank_statements) @@ -1287,12 +1299,6 @@ def iter_documents(self, subscription): if self.page.is_last_page(): break - self.iban.go(subbank=self.currentSubBank) - iban_document = self.page.get_iban_document(subscription) - if iban_document: - yield iban_document - - @need_login def iter_emitters(self): diff --git a/modules/creditmutuel/pages.py b/modules/creditmutuel/pages.py index 0e1aadf600..97b90a3af7 100644 --- a/modules/creditmutuel/pages.py +++ b/modules/creditmutuel/pages.py @@ -2651,6 +2651,9 @@ class RevolvingLoanDetails(LoggedPage, HTMLPage): class SubscriptionPage(LoggedPage, HTMLPage): + def error_msg(self): + return CleanText('//div[@id="errmsg"]/p')(self.doc) + def get_link_to_bank_statements(self): return Link('//a[@id="C:R1:N"]')(self.doc) -- GitLab