Browse Source

Rename Channel.sms_number property to Channel.phone_number. It is now used for SMS, WhatsApp and phone call notifications, so "sms_number" is not accurate any more.

pull/409/head
Pēteris Caune 4 years ago
parent
commit
2ed9a8fd30
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
8 changed files with 18 additions and 18 deletions
  1. +2
    -2
      hc/api/models.py
  2. +3
    -3
      hc/api/transports.py
  3. +2
    -2
      hc/front/tests/test_add_call.py
  4. +2
    -2
      hc/front/tests/test_add_sms.py
  5. +2
    -2
      hc/front/tests/test_add_whatsapp.py
  6. +1
    -1
      hc/front/tests/test_channels.py
  7. +3
    -3
      templates/front/channels.html
  8. +3
    -3
      templates/front/event_summary.html

+ 2
- 2
hc/api/models.py View File

@ -377,7 +377,7 @@ class Channel(models.Model):
if self.kind == "email":
return "Email to %s" % self.email_value
elif self.kind == "sms":
return "SMS to %s" % self.sms_number
return "SMS to %s" % self.phone_number
elif self.kind == "slack":
return "Slack %s" % self.slack_channel
elif self.kind == "telegram":
@ -642,7 +642,7 @@ class Channel(models.Model):
return Notification.objects.filter(channel=self).latest()
@property
def sms_number(self):
def phone_number(self):
assert self.kind in ("call", "sms", "whatsapp")
if self.value.startswith("{"):
doc = json.loads(self.value)


+ 3
- 3
hc/api/transports.py View File

@ -471,7 +471,7 @@ class Sms(HttpTransport):
data = {
"From": settings.TWILIO_FROM,
"To": self.channel.sms_number,
"To": self.channel.phone_number,
"Body": text,
}
@ -496,7 +496,7 @@ class Call(HttpTransport):
data = {
"From": settings.TWILIO_FROM,
"To": self.channel.sms_number,
"To": self.channel.phone_number,
"Twiml": twiml,
}
@ -524,7 +524,7 @@ class WhatsApp(HttpTransport):
data = {
"From": "whatsapp:%s" % settings.TWILIO_FROM,
"To": "whatsapp:%s" % self.channel.sms_number,
"To": "whatsapp:%s" % self.channel.phone_number,
"Body": text,
}


+ 2
- 2
hc/front/tests/test_add_call.py View File

@ -32,7 +32,7 @@ class AddCallTestCase(BaseTestCase):
c = Channel.objects.get()
self.assertEqual(c.kind, "call")
self.assertEqual(c.sms_number, "+1234567890")
self.assertEqual(c.phone_number, "+1234567890")
self.assertEqual(c.name, "My Phone")
self.assertEqual(c.project, self.project)
@ -50,7 +50,7 @@ class AddCallTestCase(BaseTestCase):
self.client.post(self.url, form)
c = Channel.objects.get()
self.assertEqual(c.sms_number, "+1234567890")
self.assertEqual(c.phone_number, "+1234567890")
@override_settings(TWILIO_AUTH=None)
def test_it_requires_credentials(self):


+ 2
- 2
hc/front/tests/test_add_sms.py View File

@ -32,7 +32,7 @@ class AddSmsTestCase(BaseTestCase):
c = Channel.objects.get()
self.assertEqual(c.kind, "sms")
self.assertEqual(c.sms_number, "+1234567890")
self.assertEqual(c.phone_number, "+1234567890")
self.assertEqual(c.name, "My Phone")
self.assertEqual(c.project, self.project)
@ -50,7 +50,7 @@ class AddSmsTestCase(BaseTestCase):
self.client.post(self.url, form)
c = Channel.objects.get()
self.assertEqual(c.sms_number, "+1234567890")
self.assertEqual(c.phone_number, "+1234567890")
@override_settings(TWILIO_AUTH=None)
def test_it_requires_credentials(self):


+ 2
- 2
hc/front/tests/test_add_whatsapp.py View File

@ -44,7 +44,7 @@ class AddWhatsAppTestCase(BaseTestCase):
c = Channel.objects.get()
self.assertEqual(c.kind, "whatsapp")
self.assertEqual(c.sms_number, "+1234567890")
self.assertEqual(c.phone_number, "+1234567890")
self.assertEqual(c.name, "My Phone")
self.assertTrue(c.whatsapp_notify_down)
self.assertTrue(c.whatsapp_notify_up)
@ -59,7 +59,7 @@ class AddWhatsAppTestCase(BaseTestCase):
c = Channel.objects.get()
self.assertEqual(c.kind, "whatsapp")
self.assertEqual(c.sms_number, "+1234567890")
self.assertEqual(c.phone_number, "+1234567890")
self.assertEqual(c.name, "My Phone")
self.assertFalse(c.whatsapp_notify_down)
self.assertFalse(c.whatsapp_notify_up)


+ 1
- 1
hc/front/tests/test_channels.py View File

@ -1,6 +1,6 @@
import json
from hc.api.models import Check, Channel, Notification
from hc.api.models import Channel
from hc.test import BaseTestCase


+ 3
- 3
templates/front/channels.html View File

@ -67,9 +67,9 @@
user <span>{{ ch.telegram_name }}</span>
{% endif %}
{% elif ch.kind == "sms" %}
SMS to <span>{{ ch.sms_number }}</span>
SMS to <span>{{ ch.phone_number }}</span>
{% elif ch.kind == "call" %}
Phone call to <span>{{ ch.sms_number }}</span>
Phone call to <span>{{ ch.phone_number }}</span>
{% elif ch.kind == "trello" %}
Trello
board <span>{{ ch.trello_board_list|first }}</span>,
@ -77,7 +77,7 @@
{% elif ch.kind == "matrix" %}
Matrix <span>{{ ch.value }}</span>
{% elif ch.kind == "whatsapp" %}
WhatsApp to <span>{{ ch.sms_number }}</span>
WhatsApp to <span>{{ ch.phone_number }}</span>
{% if ch.whatsapp_notify_down and not ch.whatsapp_notify_up %}
(down only)
{% endif %}


+ 3
- 3
templates/front/event_summary.html View File

@ -18,12 +18,12 @@
({{ event.channel.name }})
{% endif %}
{% elif event.channel.kind == "sms" %}
Sent SMS to {{ event.channel.sms_number }}
Sent SMS to {{ event.channel.phone_number }}
{% if event.channel.name %}
({{ event.channel.name }})
{% endif %}
{% elif event.channel.kind == "whatsapp" %}
Sent WhatsApp message to {{ event.channel.sms_number }}
Sent WhatsApp message to {{ event.channel.phone_number }}
{% if event.channel.name %}
({{ event.channel.name }})
{% endif %}
@ -36,7 +36,7 @@
({{ event.channel.name }})
{% endif %}
{% elif event.channel.kind == "call" %}
Made a phone call to {{ event.channel.sms_number }}
Made a phone call to {{ event.channel.phone_number }}
{% if event.channel.name %}
({{ event.channel.name }})
{% endif %}


Loading…
Cancel
Save