0001-juste-un-exemple-pour-blablater.patch
passerelle/apps/ovh/models.py | ||
---|---|---|
8 | 8 |
from django.db import models |
9 | 9 |
from django.core.urlresolvers import reverse |
10 | 10 | |
11 |
from passerelle.messages.models import MessageGateway |
|
11 |
from passerelle.base.models import BaseResource |
|
12 |
from passerelle.sms import SMSGatewayMixin |
|
12 | 13 | |
13 |
logger = logging.getLogger('passerelle.messages.ovh')
|
|
14 |
logger = logging.getLogger('passerelle.sms.ovh')
|
|
14 | 15 | |
15 | 16 | |
16 | 17 |
class OVHError(Exception): |
17 | 18 |
pass |
18 | 19 | |
19 | ||
20 |
class OVHSMSGateway(MessageGateway): |
|
20 |
class OVHSMSGateway(BaseResource, SMSGatewayMixin): |
|
21 | 21 |
URL = 'https://www.ovh.com/cgi-bin/sms/http2sms.cgi' |
22 | 22 |
MESSAGES_CLASSES = ( |
23 | 23 |
(0, _('Message are directly shown to users on phone screen ' |
passerelle/sms.py | ||
---|---|---|
1 |
import re |
|
2 |
from django.utils.translation import ugettext_lazy as _ |
|
3 | ||
4 |
class SMSGatewayMixin(object): |
|
5 |
category = _('SMS Providers') |
|
6 | ||
7 |
@classmethod |
|
8 |
def clean_numbers(cls, destinations, default_country_code, prefix='+'): |
|
9 |
numbers = [] |
|
10 |
for dest in destinations: |
|
11 |
# most gateways needs the number prefixed by the country code, this is |
|
12 |
# really unfortunate. |
|
13 |
number = ''.join(re.findall('[0-9]', dest)) |
|
14 |
if dest.startswith('+'): |
|
15 |
pass # it already is fully qualified |
|
16 |
elif number.startswith('00'): |
|
17 |
# assumes 00 is international access code, remove it |
|
18 |
number = number[2:] |
|
19 |
elif number.startswith('0'): |
|
20 |
# local prefix, remove 0 and add default country code |
|
21 |
number = default_country_code + number[1:] |
|
22 |
numbers.append(prefix + number) |
|
23 |
return numbers |
|
24 | ||
25 |
def send(self, message, sender, destinations): |
|
26 |
raise NotImplementedError |
|
27 | ||
28 |
def status(self): |
|
29 |
return u'' |
|
30 | ||
0 |
- |