Commit 03ad81a7 authored by Jerome Berthier's avatar Jerome Berthier Committed by Romain Bignon

[cmes] Remove ProxyBrowser and inheritance between CmesBrowser and CmesBrowserNew

parent 540d894e
......@@ -23,7 +23,7 @@ from weboob.tools.value import ValueBackendPassword
from weboob.capabilities.bank import CapBankPockets, AccountNotFound
from weboob.capabilities.base import find_object
from .proxy_browser import ProxyBrowser
from .new_website.browser import CmesBrowserNew
__all__ = ['CmesModule']
......@@ -40,7 +40,7 @@ class CmesModule(Module, CapBankPockets):
ValueBackendPassword('login', label='Identifiant', masked=False),
ValueBackendPassword('password', label='Mot de passe'))
BROWSER = ProxyBrowser
BROWSER = CmesBrowserNew
def create_default_browser(self):
return self.create_browser(
......
......@@ -18,14 +18,17 @@
# along with this weboob module. If not, see <http://www.gnu.org/licenses/>.
from weboob.browser import URL, need_login
from ..browser import CmesBrowser
from weboob.browser import LoginBrowser, URL, need_login
from weboob.exceptions import BrowserIncorrectPassword
from .pages import (
NewAccountsPage, OperationsListPage, OperationPage,
LoginPage, NewAccountsPage, OperationsListPage, OperationPage,
)
class CmesBrowserNew(CmesBrowser):
class CmesBrowserNew(LoginBrowser):
BASEURL = 'https://www.cic-epargnesalariale.fr'
login = URL('r(?P<client_space>.*)fr/identification/authentification.html', LoginPage)
accounts = URL(r'(?P<subsite>.*)espace-client/fr/epargnants/mon-epargne/situation-financiere-detaillee/index.html',
r'(?P<subsite>.*)espace-client/fr/epargnants/tableau-de-bord/index.html',
......@@ -37,9 +40,33 @@ class CmesBrowserNew(CmesBrowser):
operation = URL(r'(?P<subsite>.*)espace-client/fr/epargnants/operations/consulter-une-operation/index.html\?param_=(?P<idx>\d+)',
OperationPage)
def __init__(self, username, password, website, subsite="", *args, **kwargs):
super(LoginBrowser, self).__init__(*args, **kwargs)
self.BASEURL = website
self.username = username
self.password = password
self.subsite = subsite
@property
def logged(self):
return 'IdSes' in self.session.cookies
def do_login(self):
self.login.go()
self.page.login(self.username, self.password)
if self.login.is_here():
raise BrowserIncorrectPassword
@need_login
def iter_accounts(self):
self.accounts.go(subsite=self.subsite)
return self.page.iter_accounts()
@need_login
def iter_investment(self, account):
return self.accounts.stay_or_go(subsite=self.subsite).iter_investment(account=account)
self.accounts.stay_or_go(subsite=self.subsite, client_space=self.client_space)
return self.page.iter_investment(account=account)
@need_login
def iter_history(self, account):
......
......@@ -19,17 +19,25 @@
from __future__ import unicode_literals
import re
from weboob.browser.pages import HTMLPage, LoggedPage
from weboob.browser.elements import ListElement, ItemElement, method
from weboob.browser.filters.standard import (
CleanText, Date, Regexp, Field, Currency, Upper, MapIn, Eval,
CleanText, CleanDecimal, Date, Regexp, Field, Currency, Upper, MapIn, Eval
)
from weboob.capabilities.bank import Account, Investment, Pocket
from weboob.capabilities.bank import Account, Investment, Pocket, Transaction, NotAvailable
def MyDecimal(*args, **kwargs):
kwargs.update(replace_dots=True, default=NotAvailable)
return CleanDecimal(*args, **kwargs)
from ..pages import MyDecimal, Transaction
class LoginPage(HTMLPage):
def login(self, login, password):
form = self.get_form(name="bloc_ident")
form['_cm_user'] = login
form['_cm_pwd'] = password
form.submit()
ACCOUNTS_TYPES = {
"pargne entreprise": Account.TYPE_PEE,
......
# -*- coding: utf-8 -*-
# Copyright(C) 2019 Budget Insight
#
# This file is part of a weboob module.
#
# This weboob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This weboob module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this weboob module. If not, see <http://www.gnu.org/licenses/>.
from weboob.browser.switch import SwitchingBrowser
from .browser import CmesBrowser
from .new_website.browser import CmesBrowserNew
class ProxyBrowser(SwitchingBrowser):
BROWSERS = {
'main': CmesBrowser,
'cmes_new': CmesBrowserNew,
}
KEEP_SESSION = True
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment