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.

parent 48b4e42b
...@@ -120,11 +120,17 @@ class BouyguesBrowser(LoginBrowser): ...@@ -120,11 +120,17 @@ class BouyguesBrowser(LoginBrowser):
try: try:
self.subscriptions_details.go(, headers=self.headers) self.subscriptions_details.go(, headers=self.headers)
sub.label = sub.label =
sub._is_holder =
except ClientError: except ClientError:
# if another person pay for your subscription you may not have access to this page with your credentials # if another person pay for your subscription you may not have access to this page with your credentials
sub.label = phone_list sub.label = phone_list
if not sub.label: if not sub.label:
sub.label = subscriber if not sub._is_holder:
sub.label = subscriber
# 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
yield sub yield sub
@need_login @need_login
...@@ -86,12 +86,18 @@ class SubscriptionPage(LoggedPage, JsonPage): ...@@ -86,12 +86,18 @@ class SubscriptionPage(LoggedPage, JsonPage):
class SubscriptionDetailPage(LoggedPage, JsonPage): class SubscriptionDetailPage(LoggedPage, JsonPage):
def get_label(self): def get_label(self):
num_tel_list = [] label_list = []
for s in self.doc['items']: for s in self.doc['items']:
phone = re.sub(r'^\+\d{2}', '0', s['numeroTel']) if 'numeroTel' in s:
num_tel_list.append(' '.join([phone[i:i + 2] for i in range(0, len(phone), 2)])) 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)]))
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): 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