From f3bc8d3ebb0bbed8d2f52fe24a1c915b00df1339 Mon Sep 17 00:00:00 2001
From: Nicolas ROCHE <nroche@entrouvert.com>
Date: Tue, 11 Aug 2020 11:48:10 +0200
Subject: [PATCH] sms: set a default template for SMS connectors (#45814)

---
 passerelle/apps/mobyt/models.py  | 2 --
 passerelle/apps/orange/models.py | 2 --
 passerelle/apps/ovh/models.py    | 2 --
 passerelle/apps/oxyd/models.py   | 2 --
 passerelle/sms/models.py         | 2 ++
 5 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/passerelle/apps/mobyt/models.py b/passerelle/apps/mobyt/models.py
index 93b9bf78..70dc072e 100644
--- a/passerelle/apps/mobyt/models.py
+++ b/passerelle/apps/mobyt/models.py
@@ -14,18 +14,16 @@ class MobytSMSGateway(SMSResource):
         ('ll', _('sms low-cost')),
         ('n', _('sms top')),
     )
     username = models.CharField(verbose_name=_('Username'), max_length=64)
     password = models.CharField(verbose_name=_('Password'), max_length=64)
     quality = models.CharField(max_length=4, choices=MESSAGES_QUALITIES, default='l',
                                verbose_name=_('Message quality'))
 
-    manager_view_template_name = 'passerelle/manage/messages_service_view.html'
-
     TEST_DEFAULTS = {
         'create_kwargs': {
             'username': 'john',
             'password': 'doe',
         },
         'test_vectors': [
             {
                 'response': '',
diff --git a/passerelle/apps/orange/models.py b/passerelle/apps/orange/models.py
index fb6da58c..614558dc 100644
--- a/passerelle/apps/orange/models.py
+++ b/passerelle/apps/orange/models.py
@@ -43,18 +43,16 @@ def get_json(response):
         raise OrangeError('Orange returned Invalid JSON content: %s' % response.text)
 
 
 class OrangeSMSGateway(SMSResource):
     username = models.CharField(verbose_name=_('Identifier'), max_length=64)
     password = models.CharField(verbose_name=_('Password'), max_length=64)
     groupname = models.CharField(verbose_name=_('Group'), max_length=64)
 
-    manager_view_template_name = 'passerelle/manage/messages_service_view.html'
-
     class Meta:
         verbose_name = _('Orange')
         db_table = 'sms_orange'
 
     def get_access_token(self):
         headers = {'content-type': 'application/x-www-form-urlencoded'}
         params = {'username': self.username, 'password': self.password}
         response = self.requests.post(URL_TOKEN, data=params, headers=headers)
diff --git a/passerelle/apps/ovh/models.py b/passerelle/apps/ovh/models.py
index 6a2f70a5..eb4ad7f7 100644
--- a/passerelle/apps/ovh/models.py
+++ b/passerelle/apps/ovh/models.py
@@ -65,18 +65,16 @@ class OVHSMSGateway(SMSResource):
         ),
     )
     msg_class = models.IntegerField(choices=MESSAGES_CLASSES, default=1,
                                     verbose_name=_('Message class'))
     credit_threshold_alert = models.PositiveIntegerField(verbose_name=_('Credit alert threshold'),
                                                          default=100)
     credit_left = models.PositiveIntegerField(verbose_name=_('Credit left'), default=0)
 
-    manager_view_template_name = 'passerelle/manage/messages_service_view.html'
-
     TEST_DEFAULTS = {
         'create_kwargs': {
             'account': '1234',
             'username': 'john',
             'password': 'doe',
         },
         'test_vectors': [
             {
diff --git a/passerelle/apps/oxyd/models.py b/passerelle/apps/oxyd/models.py
index 69babc9f..46cb6afa 100644
--- a/passerelle/apps/oxyd/models.py
+++ b/passerelle/apps/oxyd/models.py
@@ -7,18 +7,16 @@ from django.utils.translation import ugettext_lazy as _
 from passerelle.utils.jsonresponse import APIError
 from passerelle.sms.models import SMSResource
 
 
 class OxydSMSGateway(SMSResource):
     username = models.CharField(verbose_name=_('Username'), max_length=64)
     password = models.CharField(verbose_name=_('Password'), max_length=64)
 
-    manager_view_template_name = 'passerelle/manage/messages_service_view.html'
-
     TEST_DEFAULTS = {
         'create_kwargs': {
             'username': 'john',
             'password': 'doe',
         },
         'test_vectors': [
             {
                 'response': '',
diff --git a/passerelle/sms/models.py b/passerelle/sms/models.py
index 7651d98d..8afd2349 100644
--- a/passerelle/sms/models.py
+++ b/passerelle/sms/models.py
@@ -34,16 +34,18 @@ class SMSResource(BaseResource):
 
     default_country_code = models.CharField(verbose_name=_('Default country code'), max_length=3,
                                             default=u'33')
     default_trunk_prefix = models.CharField(verbose_name=_('Default trunk prefix'), max_length=2,
                                             default=u'0')  # Yeah France first !
     # FIXME: add regexp field, to check destination and from format
     max_message_length = models.IntegerField(_('Maximum message length'), default=160)
 
+    manager_view_template_name = 'passerelle/manage/messages_service_view.html'
+
     def clean_numbers(self, destinations):
         numbers = []
         for dest in destinations:
             # most gateways needs the number prefixed by the country code, this is
             # really unfortunate.
             dest = dest.strip()
             number = ''.join(re.findall('[0-9]', dest))
             if dest.startswith('+'):
-- 
2.28.0

