Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for THDMI Japan signups #252

Merged
merged 1 commit into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions microsetta_interface/implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: "システムは にダウンしています "
}
}

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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(
Expand All @@ -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:
Expand All @@ -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
}
)

Expand Down
4 changes: 3 additions & 1 deletion microsetta_interface/model_i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", "日本語")
}


Expand Down
Original file line number Diff line number Diff line change
@@ -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} 以上の値を入力してください。" )
} );
8 changes: 5 additions & 3 deletions microsetta_interface/templates/account_details.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,11 @@
<br>
<select id="language" name="language">
{% for lang_key in languages %}
{% set lang_val = languages[lang_key].value %}
{% set lang_display = languages[lang_key].display_text %}
<option value={{ lang_val }} {% if account.language == lang_val %} selected {% endif %} >{{ lang_display }}</option>
{% if languages[lang_key].value != "ja_JP" %}
{% set lang_val = languages[lang_key].value %}
{% set lang_display = languages[lang_key].display_text %}
<option value={{ lang_val }} {% if account.language == lang_val %} selected {% endif %} >{{ lang_display }}</option>
{% endif %}
{% endfor %}
</select>
</div>
Expand Down
12 changes: 11 additions & 1 deletion microsetta_interface/templates/admin_campaign_edit.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,12 @@
<tr>
<td><label for="permitted_countries">{{ _('Permitted Countries') }}:</label></td>
<td>
<select name="permitted_countries" id="permitted_countries" multiple size="4">
<select name="permitted_countries" id="permitted_countries" multiple size="5">
<option value="US" {% if "US" in permitted_countries %}SELECTED{% endif %}>{{ _('United States') }}</option>
<option value="GB" {% if "GB" in permitted_countries %}SELECTED{% endif %}>{{ _('United Kingdom') }}</option>
<option value="MX" {% if "MX" in permitted_countries %}SELECTED{% endif %}>{{ _('Mexico') }}</option>
<option value="ES" {% if "ES" in permitted_countries %}SELECTED{% endif %}>{{ _('Spain') }}</option>
<option value="JP" {% if "JP" in permitted_countries %}SELECTED{% endif %}>{{ _('Japan') }}</option>
</select>
</td>
</tr>
Expand All @@ -109,6 +110,15 @@
</select>
</td>
</tr>
<tr>
<td><label for="send_thdmi_confirmation">{{ _('Send THDMI Confirmation Email') }}:</label></td>
<td>
<select name="send_thdmi_confirmation" id="send_thdmi_confirmation">
<option value="False"{% if campaign_info.send_thdmi_confirmation is false %}selected{% endif %}>No</option>
<option value="True" {% if campaign_info.send_thdmi_confirmation is true %}selected{% endif %}>Yes</option>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="{{ _('Submit') }}"></td>
</tr>
Expand Down
56 changes: 44 additions & 12 deletions microsetta_interface/templates/submit_interest.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -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 = $('<option></option>')
Expand All @@ -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();
wasade marked this conversation as resolved.
Show resolved Hide resolved
$("#form_group_city, #form_group_state").hide();
$("#city").rules("remove");
$("#state").rules("remove");
} else {
for (var country of COUNTRIES_LIST)
{
Expand All @@ -78,6 +92,12 @@ $(document).ready(function(){
$("#state").append(option);
}
}
$("#city").rules( "add", {
required: true
});
$("#state").rules( "add", {
required: true
});
}
}
});
Expand Down Expand Up @@ -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) {
wasade marked this conversation as resolved.
Show resolved Hide resolved
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;
Expand All @@ -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: {
Expand All @@ -153,8 +184,6 @@ $(document).ready(function(){
countryValidation: true
},
address_1: "required",
city: "required",
state: "required",
postal: {
required: true,
/* remote: {
Expand Down Expand Up @@ -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.') }}",
Expand Down Expand Up @@ -518,7 +550,7 @@ $(document).ready(function(){
</fieldset>
<fieldset id="submit_interest_3">
{{ _('Please fill in the address you would like your kit delivered to. Example:') }}<br /><br />
{{ _('9500 Gilman Dr.<br />San Diego, CA 920932') }}<br /><br />
{{ _('9500 Gilman Dr.<br />San Diego, CA 92093') }}<br /><br />
<div class="form-group">
<label for="address_1" name="address_1_label">{{ _('Address 1') }}*</label>
<input id="address_1" name="address_1" class="form-control" type="text" />
Expand All @@ -531,11 +563,11 @@ $(document).ready(function(){
<label for="address_3" name="address_3_label">{{ _('Address 3') }}</label>
<input id="address_3" name="address_3" class="form-control" type="text">
</div>
<div class="form-group">
<div class="form-group" id="form_group_city">
<label for="city" name="city_label">{{ _('City') }}*</label>
<input id="city" name="city" class="form-control" type="text" />
</div>
<div class="form-group">
<div class="form-group" id="form_group_state">
<label for="state" name="state_label">{{ _('State') }}*</label>
<select id="state" name="state" class="form-control">
<option value="">-- {{ _('SELECT') }}</option>
Expand Down
Loading