Add prefix SMS with service name to service model

If the service is sending messages from GOVUK, then its messages should
be prefixed with the service name. Right now this logic is:
- worked out separately in the admin app and API
- isn’t aware of multiple senders

This commit moves the logic to one place (the service model). It does
this in a slightly naive way, in that it only looks at the default
sender, not the actual sender of the message.

In the future this will go away because we’ll move it to being a setting
that’s controlled independently of the service name. But this is the
first step towards that.

fixup! Add prefix SMS with service name to service model
This commit is contained in:
Chris Hill-Scott
2017-11-03 09:54:04 +00:00
parent b0f58a8dcb
commit 92b605833f
3 changed files with 38 additions and 0 deletions

View File

@@ -280,6 +280,9 @@ class Service(db.Model, Versioned):
default_letter_contact = [x for x in self.letter_contacts if x.is_default]
return default_letter_contact[0].contact_block if default_letter_contact else None
def prefix_sms_with_service_name(self):
return self.get_default_sms_sender() == current_app.config['FROM_NUMBER']
class AnnualBilling(db.Model):
__tablename__ = "annual_billing"