Archive, don’t delete contact lists

So we keep a record of who first uploaded a list it’s better to archive
a list than completely delete it.

The list in the database doesn’t contain any recipient info so this
isn’t a change to what data we’re retaining.

This means updating the endpoints that get contact lists to exclude ones
that are archived.
This commit is contained in:
Chris Hill-Scott
2020-03-26 11:38:04 +00:00
parent 4a6143aeb1
commit 5fe0fafadf
9 changed files with 77 additions and 25 deletions

View File

@@ -135,14 +135,6 @@ def dao_update_job(job):
db.session.commit()
def dao_unlink_jobs_from_contact_list_id(contact_list_id):
Job.query.filter(
Job.contact_list_id == contact_list_id,
).update({
'contact_list_id': None,
})
def dao_get_jobs_older_than_data_retention(notification_types):
flexible_data_retention = ServiceDataRetention.query.filter(
ServiceDataRetention.notification_type.in_(notification_types)

View File

@@ -5,7 +5,8 @@ from app.models import ServiceContactList
def dao_get_contact_list_by_id(service_id, contact_list_id):
contact_list = ServiceContactList.query.filter_by(
service_id=service_id,
id=contact_list_id
id=contact_list_id,
archived=False,
).one()
return contact_list
@@ -13,7 +14,8 @@ def dao_get_contact_list_by_id(service_id, contact_list_id):
def dao_get_contact_lists(service_id):
contact_lists = ServiceContactList.query.filter_by(
service_id=service_id
service_id=service_id,
archived=False,
).order_by(
ServiceContactList.created_at.desc()
)
@@ -25,6 +27,7 @@ def save_service_contact_list(service_contact_list):
db.session.commit()
def dao_delete_contact_list(service_contact_list):
db.session.delete(service_contact_list)
def dao_archive_contact_list(service_contact_list):
service_contact_list.archived = True
db.session.add(service_contact_list)
db.session.commit()