mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 15:31:15 -05:00
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.
34 lines
829 B
Python
34 lines
829 B
Python
from app import db
|
|
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,
|
|
archived=False,
|
|
).one()
|
|
|
|
return contact_list
|
|
|
|
|
|
def dao_get_contact_lists(service_id):
|
|
contact_lists = ServiceContactList.query.filter_by(
|
|
service_id=service_id,
|
|
archived=False,
|
|
).order_by(
|
|
ServiceContactList.created_at.desc()
|
|
)
|
|
return contact_lists.all()
|
|
|
|
|
|
def save_service_contact_list(service_contact_list):
|
|
db.session.add(service_contact_list)
|
|
db.session.commit()
|
|
|
|
|
|
def dao_archive_contact_list(service_contact_list):
|
|
service_contact_list.archived = True
|
|
db.session.add(service_contact_list)
|
|
db.session.commit()
|