Commit 66be4f54 authored by Quentin Defenouillere's avatar Quentin Defenouillere Committed by Vincent A

[cragr/regions] Handle history for cards that have only one coming line

Some cards have only one coming line and the tr[position()=last() -1]
returns an empty URL, therefore when trying a self.location() on it we
get logged out.
We must verify if there is only one line of coming before returning the
card's URL.

Closes: 42215@sibi
parent 77a26acf
......@@ -490,8 +490,11 @@ class MultipleCardsPage(CardsPage):
def get_transactions_link(self, raw_number):
# We cannot use Link() because the @href attribute contains line breaks and spaces.
# Always take the <tr> before the last to include the latest transactions
# (the last <td> is just card information).
# Always take the <tr> before the last to include the latest transactions,
# except if there is only one line of coming (then take the last).
if len(self.doc.xpath('//table[@class="ca-table"][caption[span[text()="%s"]]]//tr' % raw_number)) == 1:
return CleanText('//table[@class="ca-table"][caption[span[text()="%s"]]]//tr[position()=last()]/th/a/@href'
% raw_number, replace=[(' ', '')])(self.doc)
return CleanText('//table[@class="ca-table"][caption[span[text()="%s"]]]//tr[position()=last()-1]/th/a/@href'
% raw_number, replace=[(' ', '')])(self.doc)
......
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