Remove create_or_update_email_reply_to and create_or_update_letter_contact - no longer needed.

Remove Services.reply_to_email_address and Services.letter_contact_block
This commit is contained in:
Rebecca Law
2017-11-20 14:33:15 +00:00
parent f3f8225dfe
commit 577463b0ac
7 changed files with 0 additions and 213 deletions

View File

@@ -25,22 +25,6 @@ def dao_get_reply_to_by_id(service_id, reply_to_id):
return reply_to
def create_or_update_email_reply_to(service_id, email_address):
reply_to = dao_get_reply_to_by_service_id(service_id)
if len(reply_to) == 0:
reply_to = ServiceEmailReplyTo(service_id=service_id, email_address=email_address)
dao_create_reply_to_email_address(reply_to)
elif len(reply_to) == 1:
reply_to[0].email_address = email_address
dao_update_reply_to_email(reply_to[0])
else:
# Once we move allowing multiple email address this methods will be removed
raise InvalidRequest(
"Multiple reply to email addresses were found, this method should not be used.",
status_code=500
)
@transactional
def dao_create_reply_to_email_address(reply_to_email):
db.session.add(reply_to_email)

View File

@@ -29,25 +29,6 @@ def dao_get_letter_contact_by_id(service_id, letter_contact_id):
return letter_contact
def create_or_update_letter_contact(service_id, contact_block):
letter_contacts = dao_get_letter_contacts_by_service_id(service_id)
if len(letter_contacts) == 0:
letter_contact = ServiceLetterContact(
service_id=service_id,
contact_block=contact_block
)
dao_create_letter_contact(letter_contact)
elif len(letter_contacts) == 1:
letter_contacts[0].contact_block = contact_block
dao_update_letter_contact(letter_contacts[0])
else:
# TODO: Once we move allowing letter contact blocks, this method will be removed
raise InvalidRequest(
"Multiple letter contacts were found, this method should not be used.",
status_code=500
)
@transactional
def dao_create_letter_contact(letter_contact):
db.session.add(letter_contact)

View File

@@ -224,8 +224,6 @@ class Service(db.Model, Versioned):
email_from = db.Column(db.Text, index=False, unique=True, nullable=False)
created_by = db.relationship('User')
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)
_letter_contact_block = db.Column('letter_contact_block', db.Text, index=False, unique=False, nullable=True)
prefix_sms = db.Column(db.Boolean, nullable=True, default=True)
organisation_id = db.Column(UUID(as_uuid=True), db.ForeignKey('organisation.id'), index=True, nullable=True)
free_sms_fragment_limit = db.Column(db.BigInteger, index=False, unique=False, nullable=True)

View File

@@ -57,14 +57,12 @@ from app.dao.service_whitelist_dao import (
)
from app.dao.service_email_reply_to_dao import (
add_reply_to_email_address_for_service,
create_or_update_email_reply_to,
dao_get_reply_to_by_id,
dao_get_reply_to_by_service_id,
update_reply_to_email_address
)
from app.dao.service_letter_contact_dao import (
dao_get_letter_contacts_by_service_id,
create_or_update_letter_contact,
dao_get_letter_contact_by_id,
add_letter_contact_for_service,
update_letter_contact
@@ -175,8 +173,6 @@ def create_service():
errors = {'user_id': ['Missing data for required field.']}
raise InvalidRequest(errors, status_code=400)
# TODO: to be removed when front-end is updated
# validate json with marshmallow
service_schema.load(request.get_json())
@@ -200,12 +196,6 @@ def update_service(service_id):
update_dict = service_schema.load(current_data).data
dao_update_service(update_dict)
if 'reply_to_email_address' in req_json:
create_or_update_email_reply_to(fetched_service.id, req_json['reply_to_email_address'])
if 'letter_contact_block' in req_json:
create_or_update_letter_contact(fetched_service.id, req_json['letter_contact_block'])
# bridging code between frontend is deployed and data has not been migrated yet. Can only update current year
if 'free_sms_fragment_limit' in req_json:
update_free_sms_fragment_limit_data(fetched_service.id, req_json['free_sms_fragment_limit'])