Entangle the required and editable properties of Profile fields.

Add tests.  Update i18n for required property hover help.
Upgrade script to set editable=1 on all required fields.
fixes #10781
This commit is contained in:
Colin Kuskie 2009-08-17 19:28:04 +00:00
parent 5baf75bb19
commit 0762ce1730
5 changed files with 53 additions and 11 deletions

View file

@ -1,4 +1,5 @@
7.7.18
- fixed #10781: User Profile Editable/Required gotcha
- fixed #10786: Matrix navigation: search screen to view screen
- fixed #10766: Matrix search: search dropdowns do not match what is displayed when search form opens.
- fixed #10783: Inbox Copy Sender broken

View file

@ -33,9 +33,9 @@ my $session = start(); # this line required
# upgrade functions go here
addSmsGatewaySubjectSetting($session);
addInboxNotificationsSubjectSetting($session);
profileFieldRequiredEditable($session);
finish($session); # this line required
#----------------------------------------------------------------------------
# Describe what our function does
#sub exampleFunction {
@ -45,6 +45,18 @@ finish($session); # this line required
# print "DONE!\n" unless $quiet;
#}
sub profileFieldRequiredEditable {
my $session = shift;
print "\tTurn on the editable bit for all Profile Fields which are required... " unless $quiet;
FIELD: foreach my $field (@{ WebGUI::ProfileField->getRequiredFields($session) } ) {
my $properties = $field->get();
next FIELD unless !$properties->{editable};
$properties->{editable} = 1;
$field->set($properties);
}
print "DONE!\n" unless $quiet;
}
sub addSmsGatewaySubjectSetting {
my $session = shift;
print "\tAdding smsGatewaySubject setting... " unless $quiet;

View file

@ -877,13 +877,15 @@ sub set {
my $db = $session->db;
# Set the defaults
$properties->{visible} = 0 unless ($properties->{visible} == 1);
$properties->{editable} = 0 unless ($properties->{editable} == 1);
$properties->{protected} = 0 unless ($properties->{protected} == 1);
$properties->{required} = 0 unless ($properties->{required} == 1);
$properties->{label} = 'Undefined' if ($properties->{label} =~ /^[\"\']*$/);
$properties->{fieldType} = 'text' unless ($properties->{fieldType});
$properties->{extras} = '' unless ($properties->{extras});
$properties->{visible} = 0 unless ($properties->{visible} == 1);
$properties->{protected} = 0 unless ($properties->{protected} == 1);
$properties->{required} = 0 unless ($properties->{required} == 1);
$properties->{editable} = $properties->{required} == 1 ? 1
: $properties->{editable} == 1 ? 1
: 0;
$properties->{label} = 'Undefined' if ($properties->{label} =~ /^[\"\']*$/);
$properties->{fieldType} = 'text' unless ($properties->{fieldType});
$properties->{extras} = '' unless ($properties->{extras});
if ($properties->{dataDefault} && $properties->{fieldType}=~/List$/) {
unless ($properties->{dataDefault} =~ /^\[/) {
$properties->{dataDefault} = "[".$properties->{dataDefault};

View file

@ -69,8 +69,8 @@ Internationalization system if labels need to be localized.|,
},
'474 description' => {
message => q|Should the user be required to fill out this field?|,
lastUpdated => 1122316558,
message => q|Should the user be required to fill out this field? If this option is set to yes, then the field will automatically be set to be editable as well.|,
lastUpdated => 1250537322,
},
'486 description' => {

View file

@ -33,7 +33,7 @@ WebGUI::Test->usersToDelete($newUser);
#----------------------------------------------------------------------------
# Tests
plan tests => 37; # Increment this number for each test you create
plan tests => 45; # Increment this number for each test you create
#----------------------------------------------------------------------------
# Test the creation of ProfileField
@ -147,11 +147,38 @@ ok( !WebGUI::ProfileField->isReservedFieldName('shop'), '... shop is not');
ok( WebGUI::ProfileField->exists($session, 'email'), 'exists: email');
ok( !WebGUI::ProfileField->exists($session, 'userId'), '... userId (not)');
###########################################################
#
# set
#
###########################################################
my $newProfileField3 = WebGUI::ProfileField->create($session, 'testField3', {
label => q|WebGUI::International::get('webgui','WebGUI')|,
fieldName => 'Text',
});
is ($newProfileField3->get('editable'), 0, 'default editable = 0');
is ($newProfileField3->get('required'), 0, 'default required = 0');
$newProfileField3->set({ editable => 1});
is ($newProfileField3->get('editable'), 1, 'set editable=1');
is ($newProfileField3->get('required'), 0, '... required=0');
$newProfileField3->set({ editable => 0});
is ($newProfileField3->get('editable'), 0, 'set editable = 0');
is ($newProfileField3->get('required'), 0, '... required = 0');
$newProfileField3->set({ required => 1});
is ($newProfileField3->get('required'), 1, 'set required = 1');
is ($newProfileField3->get('editable'), 1, '... editable = 1');
#----------------------------------------------------------------------------
# Cleanup
END {
$newProfileField->delete;
$newProfileField2->delete;
$newProfileField3->delete;
}