mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	i18n: Add missing strings for custom profile fields and fix capitalization.
The "Short/Long Text" option for custom profile fields wasn't properly capitalized (i.e. "Text" should have been all lowercase), and also wasn't properly tagged for translation. For the sake of consistency, the change to proper capitalization has also been applied to the models and any tests involving this feature. Due to a bug in Django, it complained about the models having changed and thus not being consistent with the migrations. That isn't actually true (since the database stores the numeric values for each key), but the migrations have been modified to avoid this error. This does not affect the migrations' behaviour in any way.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							6e149a7594
						
					
				
				
					commit
					6837fc5d56
				
			@@ -203,7 +203,7 @@ casper.then(function () {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
    casper.waitUntilVisible('.profile-field-row span.profile_field_name', function () {
 | 
					    casper.waitUntilVisible('.profile-field-row span.profile_field_name', function () {
 | 
				
			||||||
        casper.test.assertSelectorHasText('.profile-field-row span.profile_field_name', 'Teams');
 | 
					        casper.test.assertSelectorHasText('.profile-field-row span.profile_field_name', 'Teams');
 | 
				
			||||||
        casper.test.assertSelectorHasText('.profile-field-row span.profile_field_type', 'Short Text');
 | 
					        casper.test.assertSelectorHasText('.profile-field-row span.profile_field_type', 'Short text');
 | 
				
			||||||
        casper.click('.profile-field-row button.open-edit-form');
 | 
					        casper.click('.profile-field-row button.open-edit-form');
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
@@ -223,7 +223,7 @@ casper.then(function () {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
    casper.waitForSelectorTextChange('.profile-field-row span.profile_field_name', function () {
 | 
					    casper.waitForSelectorTextChange('.profile-field-row span.profile_field_name', function () {
 | 
				
			||||||
        casper.test.assertSelectorHasText('.profile-field-row span.profile_field_name', 'team');
 | 
					        casper.test.assertSelectorHasText('.profile-field-row span.profile_field_name', 'team');
 | 
				
			||||||
        casper.test.assertSelectorHasText('.profile-field-row span.profile_field_type', 'Short Text');
 | 
					        casper.test.assertSelectorHasText('.profile-field-row span.profile_field_type', 'Short text');
 | 
				
			||||||
        casper.click('.profile-field-row button.delete');
 | 
					        casper.click('.profile-field-row button.delete');
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -194,7 +194,7 @@ function render(template_name, args) {
 | 
				
			|||||||
    var args = {
 | 
					    var args = {
 | 
				
			||||||
        profile_field: {
 | 
					        profile_field: {
 | 
				
			||||||
            name: "teams",
 | 
					            name: "teams",
 | 
				
			||||||
            type: "Long Text",
 | 
					            type: "Long text",
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        can_modify: true,
 | 
					        can_modify: true,
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
@@ -209,14 +209,14 @@ function render(template_name, args) {
 | 
				
			|||||||
    var td = $(html).find('tr.profile-field-row:first td');
 | 
					    var td = $(html).find('tr.profile-field-row:first td');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    assert.equal(field_name.text(), 'teams');
 | 
					    assert.equal(field_name.text(), 'teams');
 | 
				
			||||||
    assert.equal(field_type.text(), 'Long Text');
 | 
					    assert.equal(field_type.text(), 'Long text');
 | 
				
			||||||
    assert.equal(td.length, 4);
 | 
					    assert.equal(td.length, 4);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // When the logged in user is not admin
 | 
					    // When the logged in user is not admin
 | 
				
			||||||
    args = {
 | 
					    args = {
 | 
				
			||||||
        profile_field: {
 | 
					        profile_field: {
 | 
				
			||||||
            name: "teams",
 | 
					            name: "teams",
 | 
				
			||||||
            type: "Long Text",
 | 
					            type: "Long text",
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        can_modify: false,
 | 
					        can_modify: false,
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
@@ -231,7 +231,7 @@ function render(template_name, args) {
 | 
				
			|||||||
    td = $(html).find('tr.profile-field-row:first td');
 | 
					    td = $(html).find('tr.profile-field-row:first td');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    assert.equal(field_name.text(), 'teams');
 | 
					    assert.equal(field_name.text(), 'teams');
 | 
				
			||||||
    assert.equal(field_type.text(), 'Long Text');
 | 
					    assert.equal(field_type.text(), 'Long text');
 | 
				
			||||||
    assert.equal(td.length, 3);
 | 
					    assert.equal(td.length, 3);
 | 
				
			||||||
}());
 | 
					}());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -60,11 +60,11 @@ exports.add_custom_profile_fields_to_settings = function () {
 | 
				
			|||||||
        var field_type = settings_profile_fields.field_type_id_to_string(field.type);
 | 
					        var field_type = settings_profile_fields.field_type_id_to_string(field.type);
 | 
				
			||||||
        var type;
 | 
					        var type;
 | 
				
			||||||
        var value = people.my_custom_profile_data(field.id);
 | 
					        var value = people.my_custom_profile_data(field.id);
 | 
				
			||||||
        var is_long_text = field_type === "Long Text";
 | 
					        var is_long_text = field_type === "Long text";
 | 
				
			||||||
        var is_choice_field = field_type === "Choice";
 | 
					        var is_choice_field = field_type === "Choice";
 | 
				
			||||||
        var field_choices = [];
 | 
					        var field_choices = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (field_type === "Long Text" || field_type === "Short Text") {
 | 
					        if (field_type === "Long text" || field_type === "Short text") {
 | 
				
			||||||
            type = "text";
 | 
					            type = "text";
 | 
				
			||||||
        } else if (field_type === "Choice") {
 | 
					        } else if (field_type === "Choice") {
 | 
				
			||||||
            type = "choice";
 | 
					            type = "choice";
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -280,7 +280,7 @@ def process_customprofilefields(customprofilefield: List[ZerverFieldsT],
 | 
				
			|||||||
    for field in customprofilefield:
 | 
					    for field in customprofilefield:
 | 
				
			||||||
        for field_value in customprofilefield_value:
 | 
					        for field_value in customprofilefield_value:
 | 
				
			||||||
            if field_value['field'] == field['id'] and len(field_value['value']) > 50:
 | 
					            if field_value['field'] == field['id'] and len(field_value['value']) > 50:
 | 
				
			||||||
                field['field_type'] = 2  # corresponding to Long Text
 | 
					                field['field_type'] = 2  # corresponding to Long text
 | 
				
			||||||
                break
 | 
					                break
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_user_email(user: ZerverFieldsT, domain_name: str) -> str:
 | 
					def get_user_email(user: ZerverFieldsT, domain_name: str) -> str:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,7 +17,7 @@ class Migration(migrations.Migration):
 | 
				
			|||||||
            fields=[
 | 
					            fields=[
 | 
				
			||||||
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
 | 
					                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
 | 
				
			||||||
                ('name', models.CharField(max_length=100)),
 | 
					                ('name', models.CharField(max_length=100)),
 | 
				
			||||||
                ('field_type', models.PositiveSmallIntegerField(choices=[(1, 'Integer'), (2, 'Float'), (3, 'Short Text'), (4, 'Long Text')], default=3)),
 | 
					                ('field_type', models.PositiveSmallIntegerField(choices=[(1, 'Integer'), (2, 'Float'), (3, 'Short text'), (4, 'Long text')], default=3)),
 | 
				
			||||||
                ('realm', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='zerver.Realm')),
 | 
					                ('realm', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='zerver.Realm')),
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
        ),
 | 
					        ),
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,6 +15,6 @@ class Migration(migrations.Migration):
 | 
				
			|||||||
        migrations.AlterField(
 | 
					        migrations.AlterField(
 | 
				
			||||||
            model_name='customprofilefield',
 | 
					            model_name='customprofilefield',
 | 
				
			||||||
            name='field_type',
 | 
					            name='field_type',
 | 
				
			||||||
            field=models.PositiveSmallIntegerField(choices=[(1, 'Short Text'), (2, 'Long Text')], default=1),
 | 
					            field=models.PositiveSmallIntegerField(choices=[(1, 'Short text'), (2, 'Long text')], default=1),
 | 
				
			||||||
        ),
 | 
					        ),
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,6 +20,6 @@ class Migration(migrations.Migration):
 | 
				
			|||||||
        migrations.AlterField(
 | 
					        migrations.AlterField(
 | 
				
			||||||
            model_name='customprofilefield',
 | 
					            model_name='customprofilefield',
 | 
				
			||||||
            name='field_type',
 | 
					            name='field_type',
 | 
				
			||||||
            field=models.PositiveSmallIntegerField(choices=[(1, 'Short Text'), (2, 'Long Text'), (3, 'Choice')], default=1),
 | 
					            field=models.PositiveSmallIntegerField(choices=[(1, 'Short text'), (2, 'Long text'), (3, 'Choice')], default=1),
 | 
				
			||||||
        ),
 | 
					        ),
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,6 +15,6 @@ class Migration(migrations.Migration):
 | 
				
			|||||||
        migrations.AlterField(
 | 
					        migrations.AlterField(
 | 
				
			||||||
            model_name='customprofilefield',
 | 
					            model_name='customprofilefield',
 | 
				
			||||||
            name='field_type',
 | 
					            name='field_type',
 | 
				
			||||||
            field=models.PositiveSmallIntegerField(choices=[(1, 'Short Text'), (2, 'Long Text'), (4, 'Date'), (3, 'Choice')], default=1),
 | 
					            field=models.PositiveSmallIntegerField(choices=[(1, 'Short text'), (2, 'Long text'), (4, 'Date'), (3, 'Choice')], default=1),
 | 
				
			||||||
        ),
 | 
					        ),
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,6 +15,6 @@ class Migration(migrations.Migration):
 | 
				
			|||||||
        migrations.AlterField(
 | 
					        migrations.AlterField(
 | 
				
			||||||
            model_name='customprofilefield',
 | 
					            model_name='customprofilefield',
 | 
				
			||||||
            name='field_type',
 | 
					            name='field_type',
 | 
				
			||||||
            field=models.PositiveSmallIntegerField(choices=[(1, 'Short Text'), (2, 'Long Text'), (4, 'Date'), (5, 'URL'), (3, 'Choice')], default=1),
 | 
					            field=models.PositiveSmallIntegerField(choices=[(1, 'Short text'), (2, 'Long text'), (4, 'Date'), (5, 'URL'), (3, 'Choice')], default=1),
 | 
				
			||||||
        ),
 | 
					        ),
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1905,7 +1905,7 @@ class CustomProfileField(models.Model):
 | 
				
			|||||||
    # These are the fields whose validators require field_data
 | 
					    # These are the fields whose validators require field_data
 | 
				
			||||||
    # argument as well.
 | 
					    # argument as well.
 | 
				
			||||||
    EXTENDED_FIELD_TYPE_DATA = [
 | 
					    EXTENDED_FIELD_TYPE_DATA = [
 | 
				
			||||||
        (CHOICE, 'Choice', validate_choice_field, str),
 | 
					        (CHOICE, str(_('Choice')), validate_choice_field, str),
 | 
				
			||||||
    ]  # type: FieldTypeData
 | 
					    ]  # type: FieldTypeData
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    EXTENDED_FIELD_VALIDATORS = {
 | 
					    EXTENDED_FIELD_VALIDATORS = {
 | 
				
			||||||
@@ -1914,10 +1914,10 @@ class CustomProfileField(models.Model):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    FIELD_TYPE_DATA = [
 | 
					    FIELD_TYPE_DATA = [
 | 
				
			||||||
        # Type, Name, Validator, Converter
 | 
					        # Type, Name, Validator, Converter
 | 
				
			||||||
        (SHORT_TEXT, u'Short Text', check_short_string, str),
 | 
					        (SHORT_TEXT, str(_('Short text')), check_short_string, str),
 | 
				
			||||||
        (LONG_TEXT, u'Long Text', check_long_string, str),
 | 
					        (LONG_TEXT, str(_('Long text')), check_long_string, str),
 | 
				
			||||||
        (DATE, u'Date', check_date, str),
 | 
					        (DATE, str(_('Date')), check_date, str),
 | 
				
			||||||
        (URL, u'URL', check_url, str),
 | 
					        (URL, str(_('URL')), check_url, str),
 | 
				
			||||||
    ]  # type: FieldTypeData
 | 
					    ]  # type: FieldTypeData
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ALL_FIELD_TYPES = FIELD_TYPE_DATA + EXTENDED_FIELD_TYPE_DATA
 | 
					    ALL_FIELD_TYPES = FIELD_TYPE_DATA + EXTENDED_FIELD_TYPE_DATA
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user