From d1005c45b41b94c7ad8f824ebbaeb878575cc267 Mon Sep 17 00:00:00 2001 From: ayobi Date: Tue, 26 Mar 2024 20:38:28 -0300 Subject: [PATCH 1/8] added account lang change if ja_JP --- microsetta_private_api/api/_account.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/microsetta_private_api/api/_account.py b/microsetta_private_api/api/_account.py index 8d1c1107f..0f278adc4 100644 --- a/microsetta_private_api/api/_account.py +++ b/microsetta_private_api/api/_account.py @@ -101,6 +101,12 @@ def register_account(body, token_info): def read_account(account_id, token_info): acc = _validate_account_access(token_info, account_id) + if acc.language == "ja_JP": + with Transaction() as t: + acct_repo = AccountRepo(t) + acc.language = "en_US" + acct_repo.update_account(acc) + t.commit() return jsonify(acc.to_api()), 200 From bda33de2c01ac2c09c2240db32d07ce0ffdf795c Mon Sep 17 00:00:00 2001 From: ayobi Date: Thu, 28 Mar 2024 14:39:35 -0300 Subject: [PATCH 2/8] changed from hard to soft language change --- microsetta_private_api/api/_account.py | 6 ------ microsetta_private_api/model/account.py | 3 +++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/microsetta_private_api/api/_account.py b/microsetta_private_api/api/_account.py index 0f278adc4..8d1c1107f 100644 --- a/microsetta_private_api/api/_account.py +++ b/microsetta_private_api/api/_account.py @@ -101,12 +101,6 @@ def register_account(body, token_info): def read_account(account_id, token_info): acc = _validate_account_access(token_info, account_id) - if acc.language == "ja_JP": - with Transaction() as t: - acct_repo = AccountRepo(t) - acc.language = "en_US" - acct_repo.update_account(acc) - t.commit() return jsonify(acc.to_api()), 200 diff --git a/microsetta_private_api/model/account.py b/microsetta_private_api/model/account.py index a42f03ec9..a7d1b02dc 100644 --- a/microsetta_private_api/model/account.py +++ b/microsetta_private_api/model/account.py @@ -61,6 +61,9 @@ def __init__(self, account_id, email, self.creation_time = creation_time self.update_time = update_time self.language = language + if (self.language == "ja_JP"): + self.language = "en_US" + language = self.language self.consent_privacy_terms = consent_privacy_terms def to_api(self): From 92a1ee0f33e5f48727ed8414f423d9f87078913f Mon Sep 17 00:00:00 2001 From: ayobi Date: Thu, 28 Mar 2024 15:15:33 -0300 Subject: [PATCH 3/8] added language change jp to en for sending emails --- microsetta_private_api/tasks.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/microsetta_private_api/tasks.py b/microsetta_private_api/tasks.py index 152c631d3..6e3ef228a 100644 --- a/microsetta_private_api/tasks.py +++ b/microsetta_private_api/tasks.py @@ -8,7 +8,7 @@ from microsetta_private_api.repo.transaction import Transaction from microsetta_private_api.repo.admin_repo import AdminRepo from microsetta_private_api.repo.qiita_repo import QiitaRepo -from microsetta_private_api.localization import EN_US +from microsetta_private_api.localization import EN_US, JA_JP from microsetta_private_api.config_manager import SERVER_CONFIG import pandas as pd import tempfile @@ -22,6 +22,8 @@ @celery.task(ignore_result=True) def send_email(email, template_name, template_args, language): template = EmailMessage[template_name] + if language == JA_JP: + language = EN_US with flask_babel.force_locale(language): SendEmail.send(email, template, template_args) From 63c6c575c6466e16885224adc928ccba28d32616 Mon Sep 17 00:00:00 2001 From: ayobi Date: Fri, 26 Apr 2024 14:34:49 -0400 Subject: [PATCH 4/8] changed to using constants, removed useless line --- microsetta_private_api/model/account.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/microsetta_private_api/model/account.py b/microsetta_private_api/model/account.py index a7d1b02dc..fb54f68e4 100644 --- a/microsetta_private_api/model/account.py +++ b/microsetta_private_api/model/account.py @@ -1,6 +1,7 @@ from enum import Enum from microsetta_private_api.model.model_base import ModelBase from microsetta_private_api.model.address import Address +from microsetta_private_api.localization import EN_US, JA_JP class AuthorizationMatch(Enum): @@ -61,9 +62,8 @@ def __init__(self, account_id, email, self.creation_time = creation_time self.update_time = update_time self.language = language - if (self.language == "ja_JP"): - self.language = "en_US" - language = self.language + if (self.language == JA_JP): + self.language = EN_US self.consent_privacy_terms = consent_privacy_terms def to_api(self): From abb8e17d28aac1a319d0dca1933a5faa2d31d65c Mon Sep 17 00:00:00 2001 From: Cassidy Symons Date: Tue, 4 Jun 2024 09:18:49 -0700 Subject: [PATCH 5/8] Copy barcodes --- microsetta_private_api/db/patches/0139.sql | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 microsetta_private_api/db/patches/0139.sql diff --git a/microsetta_private_api/db/patches/0139.sql b/microsetta_private_api/db/patches/0139.sql new file mode 100644 index 000000000..e13acb508 --- /dev/null +++ b/microsetta_private_api/db/patches/0139.sql @@ -0,0 +1,64 @@ +-- This database patch copies two samples into new barcodes to reflect +-- adjustments that were necessary in the wet lab. We don't believe this +-- will be an ongoing need, but if it proves to be, check for new +-- barcode-related tables before using this as a template. + +-- Begin copying X00236845 to 0364352596 +INSERT INTO barcodes.barcode (barcode, assigned_on, status, sample_postmark_date, biomass_remaining, sequencing_status, obsolete, create_date_time, kit_id) + SELECT '0364352596', assigned_on, status, sample_postmark_date, biomass_remaining, sequencing_status, obsolete, create_date_time, kit_id + FROM barcodes.barcode + WHERE barcode = 'X00236845'; + +INSERT INTO barcodes.project_barcode (project_id, barcode) + SELECT project_id, '0364352596' + FROM barcodes.project_barcode + WHERE barcode = 'X00236845'; + +-- I'm omitting the sample_barcode_file and sample_barcode_file_md5 as they're +-- no longer used and it would be inappropriate to directly clone a different +-- barcode's associated file. +INSERT INTO ag.ag_kit_barcodes (ag_kit_id, barcode, site_sampled, sample_date, sample_time, notes, moldy, overloaded, other, other_text, date_of_last_email, results_ready, withdrawn, refunded, deposited, source_id, latest_sample_information_update) + SELECT ag_kit_id, '0364352596', site_sampled, sample_date, sample_time, notes, moldy, overloaded, other, other_text, date_of_last_email, results_ready, withdrawn, refunded, deposited, source_id, latest_sample_information_update + FROM ag.ag_kit_barcodes + WHERE barcode = 'X00236845'; + +INSERT INTO ag.source_barcodes_surveys (barcode, survey_id) + SELECT '0364352596', survey_id + FROM ag.source_barcodes_surveys + WHERE barcode = 'X00236845'; + +INSERT INTO barcodes.barcode_scans (barcode, scan_timestamp, sample_status, technician_notes) + SELECT '0364352596', scan_timestamp, sample_status, technician_notes + FROM barcodes.barcode_scans + WHERE barcode = 'X00236845'; +-- End copying X00236845 to 0364352596 + +-- Begin copying 000031307 to 0364406520 +INSERT INTO barcodes.barcode (barcode, assigned_on, status, sample_postmark_date, biomass_remaining, sequencing_status, obsolete, create_date_time, kit_id) + SELECT '0364406520', assigned_on, status, sample_postmark_date, biomass_remaining, sequencing_status, obsolete, create_date_time, kit_id + FROM barcodes.barcode + WHERE barcode = '000031307'; + +INSERT INTO barcodes.project_barcode (project_id, barcode) + SELECT project_id, '0364406520' + FROM barcodes.project_barcode + WHERE barcode = '000031307'; + +-- I'm omitting the sample_barcode_file and sample_barcode_file_md5 as they're +-- no longer used and it would be inappropriate to directly clone a different +-- barcode's associated file. +INSERT INTO ag.ag_kit_barcodes (ag_kit_id, barcode, site_sampled, sample_date, sample_time, notes, moldy, overloaded, other, other_text, date_of_last_email, results_ready, withdrawn, refunded, deposited, source_id, latest_sample_information_update) + SELECT ag_kit_id, '0364406520', site_sampled, sample_date, sample_time, notes, moldy, overloaded, other, other_text, date_of_last_email, results_ready, withdrawn, refunded, deposited, source_id, latest_sample_information_update + FROM ag.ag_kit_barcodes + WHERE barcode = '000031307'; + +INSERT INTO ag.source_barcodes_surveys (barcode, survey_id) + SELECT '0364406520', survey_id + FROM ag.source_barcodes_surveys + WHERE barcode = '000031307'; + +INSERT INTO barcodes.barcode_scans (barcode, scan_timestamp, sample_status, technician_notes) + SELECT '0364406520', scan_timestamp, sample_status, technician_notes + FROM barcodes.barcode_scans + WHERE barcode = '000031307'; +-- End copying 000031307 to 0364406520 From b205f2640bfc529b45cd66423efecf9fb252b3c2 Mon Sep 17 00:00:00 2001 From: Cassidy Symons <83246693+cassidysymons@users.noreply.github.com> Date: Tue, 4 Jun 2024 09:39:02 -0700 Subject: [PATCH 6/8] Update conda_requirements.txt Pin flask < 3.0.0 --- ci/conda_requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/conda_requirements.txt b/ci/conda_requirements.txt index 03bcdc5ff..2b6b201db 100644 --- a/ci/conda_requirements.txt +++ b/ci/conda_requirements.txt @@ -1,6 +1,6 @@ flake8 psycopg2 -flask +flask < 3.0.0 natsort pycryptodome pandas < 2.0.0 From 7812e42d662e0726de988c628f9650c5f92c80a4 Mon Sep 17 00:00:00 2001 From: Cassidy Symons <83246693+cassidysymons@users.noreply.github.com> Date: Tue, 4 Jun 2024 09:55:20 -0700 Subject: [PATCH 7/8] Update conda_requirements.txt --- ci/conda_requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/conda_requirements.txt b/ci/conda_requirements.txt index 2b6b201db..178e0cb60 100644 --- a/ci/conda_requirements.txt +++ b/ci/conda_requirements.txt @@ -4,3 +4,4 @@ flask < 3.0.0 natsort pycryptodome pandas < 2.0.0 +werkzeug < 3.0.0 From afebc88531a553c5139c4bc3324f7ed4a8765c29 Mon Sep 17 00:00:00 2001 From: Cassidy Symons Date: Tue, 4 Jun 2024 10:34:54 -0700 Subject: [PATCH 8/8] Add vioscreen_registry queries --- microsetta_private_api/db/patches/0139.sql | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/microsetta_private_api/db/patches/0139.sql b/microsetta_private_api/db/patches/0139.sql index e13acb508..1e9e7ce5e 100644 --- a/microsetta_private_api/db/patches/0139.sql +++ b/microsetta_private_api/db/patches/0139.sql @@ -31,6 +31,20 @@ INSERT INTO barcodes.barcode_scans (barcode, scan_timestamp, sample_status, tech SELECT '0364352596', scan_timestamp, sample_status, technician_notes FROM barcodes.barcode_scans WHERE barcode = 'X00236845'; + +INSERT INTO ag.vioscreen_registry (account_id, source_id, sample_id, vio_id, deleted, registration_code) + WITH temp_1 AS ( + SELECT vr.account_id, vr.source_id, vr.vio_id, vr.deleted, vr.registration_code + FROM ag.vioscreen_registry vr + INNER JOIN ag.ag_kit_barcodes akb ON vr.sample_id = akb.ag_kit_barcode_id + WHERE akb.barcode = 'X00236845' + ), + temp_2 AS ( + SELECT ag_kit_barcode_id + FROM ag.ag_kit_barcodes + WHERE barcode = '0364352596' + ) + SELECT temp_1.account_id, temp_1.source_id, temp_2.ag_kit_barcode_id, temp_1.vio_id, temp_1.deleted, temp_1.registration_code FROM temp_1, temp_2; -- End copying X00236845 to 0364352596 -- Begin copying 000031307 to 0364406520 @@ -61,4 +75,18 @@ INSERT INTO barcodes.barcode_scans (barcode, scan_timestamp, sample_status, tech SELECT '0364406520', scan_timestamp, sample_status, technician_notes FROM barcodes.barcode_scans WHERE barcode = '000031307'; + +INSERT INTO ag.vioscreen_registry (account_id, source_id, sample_id, vio_id, deleted, registration_code) + WITH temp_1 AS ( + SELECT vr.account_id, vr.source_id, vr.vio_id, vr.deleted, vr.registration_code + FROM ag.vioscreen_registry vr + INNER JOIN ag.ag_kit_barcodes akb ON vr.sample_id = akb.ag_kit_barcode_id + WHERE akb.barcode = '000031307' + ), + temp_2 AS ( + SELECT ag_kit_barcode_id + FROM ag.ag_kit_barcodes + WHERE barcode = '0364406520' + ) + SELECT temp_1.account_id, temp_1.source_id, temp_2.ag_kit_barcode_id, temp_1.vio_id, temp_1.deleted, temp_1.registration_code FROM temp_1, temp_2; -- End copying 000031307 to 0364406520