"""add carta ready notification

Revision ID: 9cb44d7ccb92
Revises: ff62e9b2399f
Create Date: 2021-08-13 15:29:10.358180

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "9cb44d7ccb92"
down_revision = "ff62e9b2399f"
branch_labels = None
depends_on = None


content = """ To: {{destination_email}}
Subject: NRAO CARTA Session Ready


Dear User,

Your CARTA session is now available.

Please use the following link to access your CARTA session:
{{carta_url}}

You will be notified when your session has expired.

Best regards,
NRAO Workspaces

"""


def upgrade():
    op.execute(
        f"""
        INSERT INTO notification_templates (name, description, template) 
        VALUES ('carta_ready', 'An email template for notifying a user that their carta session is ready', '{content}') 
        """
    )


def downgrade():
    op.execute(
        """
        DELETE FROM notification_templates WHERE name='carta_ready'
        """
    )