From 5ffe581aa108c6386949876c699df18e27f98312 Mon Sep 17 00:00:00 2001 From: wbanks Date: Mon, 8 Jul 2024 10:58:41 -0400 Subject: [PATCH 1/4] Change process type values to be consistent --- migrations/versions/0454_add_template_category.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/migrations/versions/0454_add_template_category.py b/migrations/versions/0454_add_template_category.py index b98339fb9f..9d61f39e89 100644 --- a/migrations/versions/0454_add_template_category.py +++ b/migrations/versions/0454_add_template_category.py @@ -35,17 +35,17 @@ def upgrade(): # Insert the generic low, medium, and high categories op.execute( - "INSERT INTO template_categories (id, name_en, name_fr, sms_process_type, email_process_type, hidden, created_at) VALUES ('{}', 'Low Category (Bulk)', 'Catégorie Basse (En Vrac)', 'low', 'low', true, now())".format( + "INSERT INTO template_categories (id, name_en, name_fr, sms_process_type, email_process_type, hidden, created_at) VALUES ('{}', 'Low Category (Bulk)', 'Catégorie Basse (En Vrac)', 'bulk', 'bulk', true, now())".format( current_app.config["DEFAULT_TEMPLATE_CATEGORY_LOW"], ) ) op.execute( - "INSERT INTO template_categories (id, name_en, name_fr, sms_process_type, email_process_type, hidden, created_at) VALUES ('{}', 'Medium Category (Normal)', 'Catégorie Moyenne (Normale)', 'low', 'low', true, now())".format( + "INSERT INTO template_categories (id, name_en, name_fr, sms_process_type, email_process_type, hidden, created_at) VALUES ('{}', 'Medium Category (Normal)', 'Catégorie Moyenne (Normale)', 'normal', 'normal', true, now())".format( current_app.config["DEFAULT_TEMPLATE_CATEGORY_MEDIUM"] ) ) op.execute( - "INSERT INTO template_categories (id, name_en, name_fr, sms_process_type, email_process_type, hidden, created_at) VALUES ('{}', 'High Category (Priority)', 'Catégorie Haute (Priorité)', 'low', 'low', true, now())".format( + "INSERT INTO template_categories (id, name_en, name_fr, sms_process_type, email_process_type, hidden, created_at) VALUES ('{}', 'High Category (Priority)', 'Catégorie Haute (Priorité)', 'priority', 'priority', true, now())".format( current_app.config["DEFAULT_TEMPLATE_CATEGORY_HIGH"] ) ) From ac51d95529a91d5f5d0826313351397efd6e88a7 Mon Sep 17 00:00:00 2001 From: wbanks Date: Mon, 8 Jul 2024 11:17:45 -0400 Subject: [PATCH 2/4] Remove low, med, high, template_process_types --- .../versions/0455_add_starter_category.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/migrations/versions/0455_add_starter_category.py b/migrations/versions/0455_add_starter_category.py index efe74bf2d0..46b01c6d60 100644 --- a/migrations/versions/0455_add_starter_category.py +++ b/migrations/versions/0455_add_starter_category.py @@ -34,7 +34,7 @@ # 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"), + ("Alert", "Alerte", "System checks and monitoring", "Contrôles et suivi du système", "normal", "normal"), ( "Authentication", "Authentification", @@ -51,7 +51,7 @@ "priority", "priority", ), - ("Decision", "Décision", "Permits, documents and results", "Permis, documents et résultats", "low", "low"), + ("Decision", "Décision", "Permits, documents and results", "Permis, documents et résultats", "bulk", "bulk"), ( "Information blast", "Information de masse", @@ -68,10 +68,6 @@ 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 @@ -79,9 +75,9 @@ def insert_statement(id, name_en, name_fr, description_en, description_fr, sms_p description_fr = description_fr.replace("'", "''") return f""" - INSERT INTO template_categories + INSERT INTO template_categories (id, name_en, name_fr, description_en, description_fr, sms_process_type, email_process_type, hidden, created_at) - VALUES + VALUES ('{id}', '{name_en}', '{name_fr}', '{description_en}', '{description_fr}', '{sms_process_type}', '{email_process_type}', false, now()) """ @@ -93,8 +89,3 @@ def insert_statement(id, name_en, name_fr, description_en, description_fr, sms_p 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'") From add438954b90a4e6a1c94662aae663064f729434 Mon Sep 17 00:00:00 2001 From: wbanks Date: Mon, 8 Jul 2024 12:41:13 -0400 Subject: [PATCH 3/4] Revert "Remove low, med, high, template_process_types" This reverts commit ac51d95529a91d5f5d0826313351397efd6e88a7. --- .../versions/0455_add_starter_category.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/migrations/versions/0455_add_starter_category.py b/migrations/versions/0455_add_starter_category.py index 46b01c6d60..efe74bf2d0 100644 --- a/migrations/versions/0455_add_starter_category.py +++ b/migrations/versions/0455_add_starter_category.py @@ -34,7 +34,7 @@ # 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", "normal", "normal"), + ("Alert", "Alerte", "System checks and monitoring", "Contrôles et suivi du système", "medium", "medium"), ( "Authentication", "Authentification", @@ -51,7 +51,7 @@ "priority", "priority", ), - ("Decision", "Décision", "Permits, documents and results", "Permis, documents et résultats", "bulk", "bulk"), + ("Decision", "Décision", "Permits, documents and results", "Permis, documents et résultats", "low", "low"), ( "Information blast", "Information de masse", @@ -68,6 +68,10 @@ 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 @@ -75,9 +79,9 @@ def insert_statement(id, name_en, name_fr, description_en, description_fr, sms_p description_fr = description_fr.replace("'", "''") return f""" - INSERT INTO template_categories + INSERT INTO template_categories (id, name_en, name_fr, description_en, description_fr, sms_process_type, email_process_type, hidden, created_at) - VALUES + VALUES ('{id}', '{name_en}', '{name_fr}', '{description_en}', '{description_fr}', '{sms_process_type}', '{email_process_type}', false, now()) """ @@ -89,3 +93,8 @@ def insert_statement(id, name_en, name_fr, description_en, description_fr, sms_p 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'") From 7613512ed6689e09c9f1ef14b54307aee0897cd7 Mon Sep 17 00:00:00 2001 From: William B <7444334+whabanks@users.noreply.github.com> Date: Mon, 8 Jul 2024 13:42:23 -0300 Subject: [PATCH 4/4] Rename default categories --- migrations/versions/0454_add_template_category.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/migrations/versions/0454_add_template_category.py b/migrations/versions/0454_add_template_category.py index 9d61f39e89..980c8991a8 100644 --- a/migrations/versions/0454_add_template_category.py +++ b/migrations/versions/0454_add_template_category.py @@ -35,17 +35,17 @@ def upgrade(): # Insert the generic low, medium, and high categories op.execute( - "INSERT INTO template_categories (id, name_en, name_fr, sms_process_type, email_process_type, hidden, created_at) VALUES ('{}', 'Low Category (Bulk)', 'Catégorie Basse (En Vrac)', 'bulk', 'bulk', true, now())".format( + "INSERT INTO template_categories (id, name_en, name_fr, sms_process_type, email_process_type, hidden, created_at) VALUES ('{}', 'Low Category', 'Catégorie Basse', 'bulk', 'bulk', true, now())".format( current_app.config["DEFAULT_TEMPLATE_CATEGORY_LOW"], ) ) op.execute( - "INSERT INTO template_categories (id, name_en, name_fr, sms_process_type, email_process_type, hidden, created_at) VALUES ('{}', 'Medium Category (Normal)', 'Catégorie Moyenne (Normale)', 'normal', 'normal', true, now())".format( + "INSERT INTO template_categories (id, name_en, name_fr, sms_process_type, email_process_type, hidden, created_at) VALUES ('{}', 'Medium Category', 'Catégorie Moyenne', 'normal', 'normal', true, now())".format( current_app.config["DEFAULT_TEMPLATE_CATEGORY_MEDIUM"] ) ) op.execute( - "INSERT INTO template_categories (id, name_en, name_fr, sms_process_type, email_process_type, hidden, created_at) VALUES ('{}', 'High Category (Priority)', 'Catégorie Haute (Priorité)', 'priority', 'priority', true, now())".format( + "INSERT INTO template_categories (id, name_en, name_fr, sms_process_type, email_process_type, hidden, created_at) VALUES ('{}', 'High Category', 'Catégorie Haute', 'priority', 'priority', true, now())".format( current_app.config["DEFAULT_TEMPLATE_CATEGORY_HIGH"] ) )