Skip to content

Commit

Permalink
Merge branch 'main' into fix/pinpoint-to-opted-out-numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
sastels authored Jul 8, 2024
2 parents 288b134 + 447c69d commit 18edb08
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 1 deletion.
2 changes: 1 addition & 1 deletion migrations/versions/0454_add_template_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from flask import current_app
from sqlalchemy.dialects import postgresql

revision = "0454_add_template_categories"
revision = "0454_add_template_category"
down_revision = "0453_set_supports_international"


Expand Down
100 changes: 100 additions & 0 deletions migrations/versions/0455_add_starter_category.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
"""
Revision ID: 0455_add_starter_category
Revises: 0454_add_template_category
Create Date: 2024-06-11 13:32:00
"""
from alembic import op

revision = "0455_add_starter_category"
down_revision = "0454_add_template_category"

CAT_ALERT_ID = "1d8ce435-a7e5-431b-aaa2-a418bc4d14f9"
CAT_AUTH_ID = "b6c42a7e-2a26-4a07-802b-123a5c3198a9"
CAT_AUTO_ID = "977e2a00-f957-4ff0-92f2-ca3286b24786"
CAT_DECISION_ID = "e81678c0-4897-4111-b9d0-172f6b595f89"
CAT_INFO_ID = "207b293c-2ae5-48e8-836d-fcabd60b2153"
CAT_REMINDER_ID = "edb966f3-4a4c-47a4-96ab-05ff259b919c"
CAT_REQUEST_ID = "e0b8fbe5-f435-4977-8fc8-03f13d9296a5"
CAT_STATUS_ID = "55eb1137-6dc6-4094-9031-f61124a279dc"
CAT_TEST_ID = "7c16aa95-e2e1-4497-81d6-04c656520fe4"

# List of category IDs
category_ids = [
CAT_ALERT_ID,
CAT_AUTH_ID,
CAT_AUTO_ID,
CAT_DECISION_ID,
CAT_INFO_ID,
CAT_REMINDER_ID,
CAT_REQUEST_ID,
CAT_STATUS_ID,
CAT_TEST_ID,
]

# Corresponding English and French names and descriptions and process_type
category_data = [
("Alert", "Alerte", "System checks and monitoring", "Contrôles et suivi du système", "medium", "medium"),
(
"Authentication",
"Authentification",
"Password resets and two factor verification",
"Réinitialisations de mots de passe et vérification à deux facteurs",
"priority",
"priority",
),
(
"Automatic reply",
"Réponse automatique",
"No-reply and confirmation messages",
"Messages auxquels il est impossible de répondre et messages de confirmation",
"priority",
"priority",
),
("Decision", "Décision", "Permits, documents and results", "Permis, documents et résultats", "low", "low"),
(
"Information blast",
"Information de masse",
"Newsletters, surveys and general information",
"Infolettres, sondages et renseignements généraux",
"bulk",
"bulk",
),
("Reminder", "Rappel", "Appointments and deadlines", "Rendez-vous et échéances", "normal", "normal"),
("Request", "Demande", "Request: Follow up and next steps", "Suivis et prochaines étapes", "normal", "normal"),
("Status update", "État d’avancement", "Changes and progress", "Changements et progrès", "normal", "normal"),
("Test", "Test", "Practice messages", "Messages à titre d’entraînement", "bulk", "bulk"),
]


def upgrade():
# Insert new process_type
op.execute("INSERT INTO template_process_type (name) VALUES ('low')")
op.execute("INSERT INTO template_process_type (name) VALUES ('medium')")
op.execute("INSERT INTO template_process_type (name) VALUES ('high')")

def insert_statement(id, name_en, name_fr, description_en, description_fr, sms_process_type, email_process_type):
# Escape single quotes in string values
name_fr = name_fr.replace("'", "''")
description_fr = description_fr.replace("'", "''")

return f"""
INSERT INTO template_categories
(id, name_en, name_fr, description_en, description_fr, sms_process_type, email_process_type, hidden, created_at)
VALUES
('{id}', '{name_en}', '{name_fr}', '{description_en}', '{description_fr}', '{sms_process_type}', '{email_process_type}', false, now())
"""

for id, (name_en, name_fr, desc_en, desc_fr, sms_process_type, email_process_type) in zip(category_ids, category_data):
stmt = insert_statement(id, name_en, name_fr, desc_en, desc_fr, sms_process_type, email_process_type)
op.execute(stmt)


def downgrade():
for id in category_ids:
op.execute(f"DELETE FROM template_categories WHERE id = '{id}'")

# Delete process_type
op.execute("DELETE FROM template_process_type WHERE name = 'low'")
op.execute("DELETE FROM template_process_type WHERE name = 'medium'")
op.execute("DELETE FROM template_process_type WHERE name = 'high'")

0 comments on commit 18edb08

Please sign in to comment.