New command to populate the go live user and date from the beta partners spreadsheet.

This commit is contained in:
Rebecca Law
2019-04-24 10:52:51 +01:00
parent d8ea30f414
commit c989310ac5

View File

@@ -36,7 +36,7 @@ from app.dao.services_dao import (
dao_fetch_service_by_id,
dao_update_service
)
from app.dao.users_dao import delete_model_user, delete_user_verify_codes
from app.dao.users_dao import delete_model_user, delete_user_verify_codes, get_user_by_email
from app.models import PROVIDERS, User, Notification, Organisation, Domain, Service
from app.performance_platform.processing_time import send_processing_time_for_start_and_end
from app.utils import get_london_midnight_in_utc, get_midnight_for_day_before
@@ -804,3 +804,32 @@ def populate_service_volume_intentions(file_name):
service.volume_letter = columns[3]
dao_update_service(service)
print("populate-service-volume-intentions complete")
@notify_command(name='populate-go-live')
@click.option('-f', '--file_name', required=True, help='CSV file containing live service data')
def populate_go_live(file_name):
# 0 - count, 1- Link, 2- Service ID, 3- DEPT, 4- Service Name, 5- Main contact,
# 6- Contact detail, 7-MOU, 8- LIVE date, 9- SMS, 10 - Email, 11 - Letters, 12 -CRM, 13 - Blue badge
print("Populate go live user and date")
with open(file_name, 'r') as f:
for line in itertools.islice(f, 1, None):
columns = line.split(',')
print(columns)
service_id = columns[2]
go_live_email = columns[6]
go_live_date = datetime.strptime(columns[8], '%d/%m/%Y') + timedelta(hours=12)
try:
go_live_user = get_user_by_email(go_live_email)
except NoResultFound:
print("No user found for email address: ", go_live_email)
break
try:
service = dao_fetch_service_by_id(service_id)
except NoResultFound:
print("No service found for: ", service_id)
break
service.go_live_user = go_live_user
service.go_live_at = go_live_date
dao_update_service(service)