Commit 90da4c02 authored by Célande Adrien's avatar Célande Adrien Committed by Romain Bignon

[bouygues] handle subscription labels with no telephone number

When there is no telephone number, it can mean two things.
The subscriber is not the holder of the subscription, so he does not hav access to this data.
Or the subscription is not activated yet.

29447@sibi
parent 48b4e42b
......@@ -120,11 +120,17 @@ class BouyguesBrowser(LoginBrowser):
try:
self.subscriptions_details.go(idSub=sub.id, headers=self.headers)
sub.label = self.page.get_label()
sub._is_holder = self.page.is_holder()
except ClientError:
# if another person pay for your subscription you may not have access to this page with your credentials
sub.label = phone_list
if not sub.label:
sub.label = subscriber
if not sub._is_holder:
sub.label = subscriber
else:
# If the subscriber is the holder but the subscription does not have a phone number anyway
# It means that the subscription has not been activated yet
continue
yield sub
@need_login
......
......@@ -86,12 +86,18 @@ class SubscriptionPage(LoggedPage, JsonPage):
class SubscriptionDetailPage(LoggedPage, JsonPage):
def get_label(self):
num_tel_list = []
label_list = []
for s in self.doc['items']:
phone = re.sub(r'^\+\d{2}', '0', s['numeroTel'])
num_tel_list.append(' '.join([phone[i:i + 2] for i in range(0, len(phone), 2)]))
if 'numeroTel' in s:
phone = re.sub(r'^\+\d{2}', '0', s['numeroTel'])
label_list.append(' '.join([phone[i:i + 2] for i in range(0, len(phone), 2)]))
else:
continue
return ' - '.join(num_tel_list)
return ' - '.join(label_list)
def is_holder(self):
return any(CleanText(Dict('utilisateur/libelleProfilDroits'), default=None)(s) == 'Accès titulaire' for s in self.doc['items'] if 'utilisateur' in s)
class SendSMSPage(HTMLPage):
......
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