import os
from django.conf import settings

aws_storage_bucket_name = os.getenv('AWS_STORAGE_BUCKET_NAME')
aws_s3_region_name = os.getenv('AWS_S3_REGION_NAME')

def transfer_old_owner_builder(project_name, new_owner_email, old_owner_link, old_owner_email):
    """
    This function is responsible for building html content to sending in email for the old_owner of a transfer ownership.
    """
    with open(os.path.join(settings.BASE_DIR, 'institute/templates/email_ooc.html'), 'r', encoding="utf8") as f:
        transfer_old_owner_html = f.read()
        content = transfer_old_owner_html.replace('AWS_STORAGE_BUCKET_NAME', aws_storage_bucket_name).replace('AWS_S3_REGION_NAME', aws_s3_region_name).replace('__INSTITUTE_NAME__', project_name).replace('__NEW_OWNER_EMAIL__', new_owner_email).replace(
            '__OLD_OWNER_LINK__', old_owner_link).replace('__OLD_OWNER_EMAIL__', old_owner_email)
        return content


def transfer_new_owner_builder(project_name, new_owner_email, new_owner_link, old_owner_email):
    """
    This function is responsible for building html content to sending in email for the new_owner of a transfer ownership.
    """
    with open(os.path.join(settings.BASE_DIR, 'institute/templates/email_noc.html'), 'r', encoding="utf8") as f:
        transfer_new_owner_html = f.read()
        content = transfer_new_owner_html.replace('AWS_STORAGE_BUCKET_NAME', aws_storage_bucket_name).replace('AWS_S3_REGION_NAME', aws_s3_region_name).replace('__INSTITUTE_NAME__', project_name).replace('__NEW_OWNER_EMAIL__', new_owner_email).replace(
            '__NEW_OWNER_LINK__', new_owner_link).replace('__OLD_OWNER_EMAIL__', old_owner_email)
        return content
