From 4c729836e8147aaf383a43ff7f506d9bf3b590da Mon Sep 17 00:00:00 2001 From: Cassidy Symons Date: Wed, 2 Nov 2022 16:24:09 -0700 Subject: [PATCH] Changes for THDMI Japan signups --- microsetta_interface/implementation.py | 13 +- microsetta_interface/model_i18n.py | 4 +- .../jquery-validation/messages_ja_jp.js | 24 + .../templates/account_details.jinja2 | 8 +- .../templates/admin_campaign_edit.jinja2 | 12 +- .../templates/submit_interest.jinja2 | 56 +- .../ja_JP/LC_MESSAGES/messages.po | 3023 +++++++++++++++++ 7 files changed, 3119 insertions(+), 21 deletions(-) create mode 100644 microsetta_interface/static/vendor/jquery-validation/messages_ja_jp.js create mode 100644 microsetta_interface/translations/ja_JP/LC_MESSAGES/messages.po diff --git a/microsetta_interface/implementation.py b/microsetta_interface/implementation.py index 94846b52..81751821 100644 --- a/microsetta_interface/implementation.py +++ b/microsetta_interface/implementation.py @@ -16,7 +16,7 @@ import functools from microsetta_interface.model_i18n import translate_source, \ translate_sample, translate_survey_template, EN_US_KEY, LANGUAGES, \ - ES_MX_KEY, ES_ES_KEY + ES_MX_KEY, ES_ES_KEY, JA_JP_KEY # Authrocket uses RS256 public keys, so you can validate anywhere and safely # store the key in code. Obviously using this mechanism, we'd have to push code @@ -95,7 +95,8 @@ class Source: "going_down": { EN_US_KEY: "The system is going down at ", ES_MX_KEY: "El sistema se apaga a las ", - ES_ES_KEY: "El sistema se apaga a las " + ES_ES_KEY: "El sistema se apaga a las ", + JA_JP_KEY: "システムは にダウンしています " } } @@ -2015,6 +2016,7 @@ def get_campaign_edit(campaign_id=None): campaign_info['language_key_alt'] = None campaign_info['title_alt'] = None campaign_info['instructions_alt'] = None + campaign_info['send_thdmi_confirmaion'] = None permitted_countries = [] if campaign_info['permitted_countries'] is not None: @@ -2054,6 +2056,7 @@ def post_campaign_edit(body): language_key_alt = request.form['language_key_alt'] title_alt = request.form['title_alt'] instructions_alt = request.form['instructions_alt'] + send_thdmi_confirmation = request.form['send_thdmi_confirmation'] if 'campaign_id' in request.form: do_return, campaign_info, _ = ApiRequest.put( @@ -2068,7 +2071,8 @@ def post_campaign_edit(body): "language_key_alt": language_key_alt, "title_alt": title_alt, "instructions_alt": instructions_alt, - "extension": extension + "extension": extension, + "send_thdmi_confirmation": send_thdmi_confirmation } ) else: @@ -2087,7 +2091,8 @@ def post_campaign_edit(body): "language_key_alt": language_key_alt, "title_alt": title_alt, "instructions_alt": instructions_alt, - "extension": extension + "extension": extension, + "send_thdmi_confirmation": send_thdmi_confirmation } ) diff --git a/microsetta_interface/model_i18n.py b/microsetta_interface/model_i18n.py index 1ab3faa2..74fb128e 100644 --- a/microsetta_interface/model_i18n.py +++ b/microsetta_interface/model_i18n.py @@ -7,12 +7,14 @@ EN_US_KEY = "en_us" ES_MX_KEY = "es_mx" ES_ES_KEY = "es_es" +JA_JP_KEY = "ja_jp" Lang = namedtuple('Lang', ['value', 'display_text']) LANGUAGES = { EN_US_KEY: Lang("en_US", "English"), ES_MX_KEY: Lang("es_MX", "Español (México)"), - ES_ES_KEY: Lang("es_ES", "Español (España)") + ES_ES_KEY: Lang("es_ES", "Español (España)"), + JA_JP_KEY: Lang("ja_JP", "日本語") } diff --git a/microsetta_interface/static/vendor/jquery-validation/messages_ja_jp.js b/microsetta_interface/static/vendor/jquery-validation/messages_ja_jp.js new file mode 100644 index 00000000..89978c8f --- /dev/null +++ b/microsetta_interface/static/vendor/jquery-validation/messages_ja_jp.js @@ -0,0 +1,24 @@ +/* + * Translated default messages for the jQuery validation plugin. + * Locale: JA (Japanese; 日本語) + */ + $.extend( $.validator.messages, { + required: "このフィールドは必須です。", + remote: "このフィールドを修正してください。", + email: "有効なEメールアドレスを入力してください。", + url: "有効なURLを入力してください。", + date: "有効な日付を入力してください。", + dateISO: "有効な日付(ISO)を入力してください。", + number: "有効な数字を入力してください。", + digits: "数字のみを入力してください。", + creditcard: "有効なクレジットカード番号を入力してください。", + equalTo: "同じ値をもう一度入力してください。", + extension: "有効な拡張子を含む値を入力してください。", + maxlength: $.validator.format( "{0} 文字以内で入力してください。" ), + minlength: $.validator.format( "{0} 文字以上で入力してください。" ), + rangelength: $.validator.format( "{0} 文字から {1} 文字までの値を入力してください。" ), + range: $.validator.format( "{0} から {1} までの値を入力してください。" ), + step: $.validator.format( "{0} の倍数を入力してください。" ), + max: $.validator.format( "{0} 以下の値を入力してください。" ), + min: $.validator.format( "{0} 以上の値を入力してください。" ) +} ); \ No newline at end of file diff --git a/microsetta_interface/templates/account_details.jinja2 b/microsetta_interface/templates/account_details.jinja2 index b3c53555..5099171c 100644 --- a/microsetta_interface/templates/account_details.jinja2 +++ b/microsetta_interface/templates/account_details.jinja2 @@ -374,9 +374,11 @@
diff --git a/microsetta_interface/templates/admin_campaign_edit.jinja2 b/microsetta_interface/templates/admin_campaign_edit.jinja2 index c6678f7e..4b016d13 100644 --- a/microsetta_interface/templates/admin_campaign_edit.jinja2 +++ b/microsetta_interface/templates/admin_campaign_edit.jinja2 @@ -92,11 +92,12 @@ - + @@ -109,6 +110,15 @@ + + + + + + diff --git a/microsetta_interface/templates/submit_interest.jinja2 b/microsetta_interface/templates/submit_interest.jinja2 index 6404ff48..804cc66e 100644 --- a/microsetta_interface/templates/submit_interest.jinja2 +++ b/microsetta_interface/templates/submit_interest.jinja2 @@ -47,9 +47,13 @@ $(document).ready(function(){ required: true, phoneUS: true }); - } - - else if (selected_country == "ES") { + $("#city").rules( "add", { + required: true + }); + $("#state").rules( "add", { + required: true + }); + } else if (selected_country == "ES") { for (var state of SPAIN_STATES) { var option = $('') @@ -63,7 +67,17 @@ $(document).ready(function(){ required: true, phoneSPAIN: true }); - + $("#city").rules( "add", { + required: true + }); + $("#state").rules( "add", { + required: true + }); + } else if (selected_country == "JP") { + $("#form_group_address_3").show(); + $("#form_group_city, #form_group_state").hide(); + $("#city").rules("remove"); + $("#state").rules("remove"); } else { for (var country of COUNTRIES_LIST) { @@ -78,6 +92,12 @@ $(document).ready(function(){ $("#state").append(option); } } + $("#city").rules( "add", { + required: true + }); + $("#state").rules( "add", { + required: true + }); } } }); @@ -113,7 +133,15 @@ $(document).ready(function(){ active_section = new_active_section; } - $.validator.addMethod("countryValidation", function(value, element) { + jQuery.validator.addMethod("over18", function(value, element) { + if(value == "true") { + return true; + } else { + return false; + } + }, "{{ _('Sorry, you must be 18 or older to participate in this study.') }}"); + + jQuery.validator.addMethod("countryValidation", function(value, element) { var permitted_countries = '{{ campaign_info['permitted_countries'] |e }}'; permitted_countries = permitted_countries.split(','); var country_found = false; @@ -137,7 +165,10 @@ $(document).ready(function(){ onkeyup: false, onfocusout: false, rules: { - over_18: "required", + over_18: { + required: true, + over18: true + }, first_name: "required", last_name: "required", email: { @@ -153,8 +184,6 @@ $(document).ready(function(){ countryValidation: true }, address_1: "required", - city: "required", - state: "required", postal: { required: true, /* remote: { @@ -186,7 +215,10 @@ $(document).ready(function(){ confirm_consent: "required", }, messages: { - over_18: "{{ _('Please select whether you are at least 18 years of age.') }}", + over_18: { + required: "{{ _('Please select whether you are at least 18 years of age.') }}", + over18: "{{ _('Sorry, you must be 18 or older to participate in this study.') }}" + }, first_name: "{{ _('Please enter your first name.') }}", last_name: "{{ _('Please enter your last name.') }}", email: "{{ _('Please enter a valid email address.') }}", @@ -518,7 +550,7 @@ $(document).ready(function(){
{{ _('Please fill in the address you would like your kit delivered to. Example:') }}

- {{ _('9500 Gilman Dr.
San Diego, CA 920932') }}

+ {{ _('9500 Gilman Dr.
San Diego, CA 92093') }}

@@ -531,11 +563,11 @@ $(document).ready(function(){
-
+
-
+