Add a @ckeck_bourse decorator for a clean redirect
This commit is contained in:
parent
cee106a0e5
commit
aab2e341f9
1 changed files with 17 additions and 1 deletions
|
|
@ -29,6 +29,16 @@ from .pages import AccountsList, LoginPage, TitrePage, TitreHistory,\
|
||||||
__all__ = ['IngBrowser']
|
__all__ = ['IngBrowser']
|
||||||
|
|
||||||
|
|
||||||
|
def check_bourse(f):
|
||||||
|
def wrapper(*args):
|
||||||
|
browser = args[0]
|
||||||
|
if browser.where == u"titre":
|
||||||
|
browser.location("https://bourse.ingdirect.fr/priv/redirectIng.php?pageIng=COMPTE")
|
||||||
|
browser.where = u"start"
|
||||||
|
return f(*args)
|
||||||
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
class IngBrowser(LoginBrowser):
|
class IngBrowser(LoginBrowser):
|
||||||
BASEURL = 'https://secure.ingdirect.fr'
|
BASEURL = 'https://secure.ingdirect.fr'
|
||||||
|
|
||||||
|
|
@ -71,12 +81,14 @@ class IngBrowser(LoginBrowser):
|
||||||
raise BrowserIncorrectPassword('Please login on website to fill the form and retry')
|
raise BrowserIncorrectPassword('Please login on website to fill the form and retry')
|
||||||
|
|
||||||
@need_login
|
@need_login
|
||||||
|
@check_bourse
|
||||||
def get_accounts_list(self):
|
def get_accounts_list(self):
|
||||||
self.accountspage.go()
|
self.accountspage.go()
|
||||||
self.where = "start"
|
self.where = "start"
|
||||||
return self.page.get_list()
|
return self.page.get_list()
|
||||||
|
|
||||||
@need_login
|
@need_login
|
||||||
|
@check_bourse
|
||||||
def get_coming(self, account):
|
def get_coming(self, account):
|
||||||
if account.type != Account.TYPE_CHECKING and\
|
if account.type != Account.TYPE_CHECKING and\
|
||||||
account.type != Account.TYPE_SAVINGS:
|
account.type != Account.TYPE_SAVINGS:
|
||||||
|
|
@ -102,6 +114,7 @@ class IngBrowser(LoginBrowser):
|
||||||
return self.page.get_coming()
|
return self.page.get_coming()
|
||||||
|
|
||||||
@need_login
|
@need_login
|
||||||
|
@check_bourse
|
||||||
def get_history(self, account):
|
def get_history(self, account):
|
||||||
if account.type == Account.TYPE_MARKET:
|
if account.type == Account.TYPE_MARKET:
|
||||||
for result in self.get_history_titre(account):
|
for result in self.get_history_titre(account):
|
||||||
|
|
@ -160,6 +173,7 @@ class IngBrowser(LoginBrowser):
|
||||||
self.accountspage.go(data=data)
|
self.accountspage.go(data=data)
|
||||||
|
|
||||||
@need_login
|
@need_login
|
||||||
|
@check_bourse
|
||||||
def get_recipients(self, account):
|
def get_recipients(self, account):
|
||||||
self.transferpage.stay_or_go()
|
self.transferpage.stay_or_go()
|
||||||
if self.page.ischecked(account.id):
|
if self.page.ischecked(account.id):
|
||||||
|
|
@ -171,6 +185,7 @@ class IngBrowser(LoginBrowser):
|
||||||
self.transferpage.stay_or_go()
|
self.transferpage.stay_or_go()
|
||||||
return self.page.get_recipients()
|
return self.page.get_recipients()
|
||||||
|
|
||||||
|
@check_bourse
|
||||||
def transfer(self, account, recipient, amount, reason):
|
def transfer(self, account, recipient, amount, reason):
|
||||||
found = False
|
found = False
|
||||||
# Automatically get the good transfer page
|
# Automatically get the good transfer page
|
||||||
|
|
@ -197,6 +212,7 @@ class IngBrowser(LoginBrowser):
|
||||||
else:
|
else:
|
||||||
raise TransferError('Recipient not found')
|
raise TransferError('Recipient not found')
|
||||||
|
|
||||||
|
|
||||||
def go_investments(self, account):
|
def go_investments(self, account):
|
||||||
if self.where != "start":
|
if self.where != "start":
|
||||||
self.accountspage.go()
|
self.accountspage.go()
|
||||||
|
|
@ -212,7 +228,7 @@ class IngBrowser(LoginBrowser):
|
||||||
self.accountspage.go(data=data)
|
self.accountspage.go(data=data)
|
||||||
|
|
||||||
self.starttitre.go()
|
self.starttitre.go()
|
||||||
self.where = "titre"
|
self.where = u"titre"
|
||||||
self.titrepage.go()
|
self.titrepage.go()
|
||||||
|
|
||||||
def get_investments(self, account):
|
def get_investments(self, account):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue