Remove the letter_contact_block from the Service model

This commit is contained in:
Imdad Ahad
2017-09-26 15:08:08 +01:00
committed by Katie Smith
parent d21d9cabd1
commit 4eebd9a83c
2 changed files with 2 additions and 9 deletions

View File

@@ -208,8 +208,7 @@ class Service(db.Model, Versioned):
created_by = db.relationship('User') created_by = db.relationship('User')
created_by_id = db.Column(UUID(as_uuid=True), db.ForeignKey('users.id'), index=True, nullable=False) created_by_id = db.Column(UUID(as_uuid=True), db.ForeignKey('users.id'), index=True, nullable=False)
_reply_to_email_address = db.Column("reply_to_email_address", db.Text, index=False, unique=False, nullable=True) _reply_to_email_address = db.Column("reply_to_email_address", db.Text, index=False, unique=False, nullable=True)
letter_contact_block = db.Column(db.Text, index=False, unique=False, nullable=True) _letter_contact_block = db.Column('letter_contact_block', db.Text, index=False, unique=False, nullable=True)
# This column is now deprecated
sms_sender = db.Column(db.String(11), nullable=False, default=lambda: current_app.config['FROM_NUMBER']) sms_sender = db.Column(db.String(11), nullable=False, default=lambda: current_app.config['FROM_NUMBER'])
organisation_id = db.Column(UUID(as_uuid=True), db.ForeignKey('organisation.id'), index=True, nullable=True) organisation_id = db.Column(UUID(as_uuid=True), db.ForeignKey('organisation.id'), index=True, nullable=True)
organisation = db.relationship('Organisation') organisation = db.relationship('Organisation')
@@ -268,8 +267,7 @@ class Service(db.Model, Versioned):
if len(default_letter_contact) > 1: if len(default_letter_contact) > 1:
raise Exception("There should only ever be one default") raise Exception("There should only ever be one default")
else: else:
return default_letter_contact[0].contact_block if default_letter_contact else \ return default_letter_contact[0].contact_block if default_letter_contact else None
self.letter_contact_block # need to update this to None after dropping the letter_contact_block column
class InboundNumber(db.Model): class InboundNumber(db.Model):

View File

@@ -274,8 +274,3 @@ def test_service_get_default_contact_letter(sample_service):
create_letter_contact(service=sample_service, contact_block='London,\nNW1A 1AA') create_letter_contact(service=sample_service, contact_block='London,\nNW1A 1AA')
assert sample_service.get_default_letter_contact() == 'London,\nNW1A 1AA' assert sample_service.get_default_letter_contact() == 'London,\nNW1A 1AA'
# this test will need to be removed after letter_contact_block is dropped
def test_service_get_default_letter_contact_block_from_service(sample_service):
assert sample_service.get_default_letter_contact() == sample_service.letter_contact_block