View | Details | Raw Unified | Return to bug 23473
Collapse All | Expand All

(-)a/Koha/Patrons/Import.pm (-1 / +1 lines)
Lines 303-309 sub import_patrons { Link Here
303
                    );
303
                    );
304
                }
304
                }
305
            }
305
            }
306
            if ($overwrite_passwords){
306
            if ($overwrite_passwords && defined $borrower{password} && $borrower{password} ne ''){
307
                try {
307
                try {
308
                    $patron->set_password({ password => $borrower{password} });
308
                    $patron->set_password({ password => $borrower{password} });
309
                }
309
                }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt (-1 / +1 lines)
Lines 248-254 Link Here
248
                    <ul>
248
                    <ul>
249
                        <li>
249
                        <li>
250
                            <input class="overwrite_passwords" type="checkbox" id="overwrite_passwords" name="overwrite_passwords" disabled/>
250
                            <input class="overwrite_passwords" type="checkbox" id="overwrite_passwords" name="overwrite_passwords" disabled/>
251
                            <label class="overwrite_passwords" for="overwrite_passwords">Replace patron passwords with those in the file</label>
251
                            <label class="overwrite_passwords" for="overwrite_passwords">Replace patron passwords with those in the file (blank passwords will be ignored)</label>
252
                        </li
252
                        </li
253
                    </ul>
253
                    </ul>
254
                </li>
254
                </li>
(-)a/t/db_dependent/Koha/Patrons/Import.t (-2 / +14 lines)
Lines 435-441 subtest 'test_import_with_cardnumber_0' => sub { Link Here
435
};
435
};
436
436
437
subtest 'test_import_with_password_overwrite' => sub {
437
subtest 'test_import_with_password_overwrite' => sub {
438
    plan tests => 4;
438
    plan tests => 6;
439
439
440
    #Remove possible existing user to avoid clashes
440
    #Remove possible existing user to avoid clashes
441
    my $ernest = Koha::Patrons->find({ userid => 'ErnestP' });
441
    my $ernest = Koha::Patrons->find({ userid => 'ErnestP' });
Lines 447-452 subtest 'test_import_with_password_overwrite' => sub { Link Here
447
    my $csv_headers  = 'surname,userid,branchcode,categorycode,password';
447
    my $csv_headers  = 'surname,userid,branchcode,categorycode,password';
448
    my $csv_password = "Worrell,ErnestP,$branchcode,$categorycode,Ernest1";
448
    my $csv_password = "Worrell,ErnestP,$branchcode,$categorycode,Ernest1";
449
    my $csv_password_change = "Worrell,ErnestP,$branchcode,$categorycode,Vern1";
449
    my $csv_password_change = "Worrell,ErnestP,$branchcode,$categorycode,Vern1";
450
    my $csv_blank_password = "Worel,ErnestP,$branchcode,$categorycode,";
450
    my $defaults = { cardnumber => "" }; #currently all the defaults come as "" if not filled
451
    my $defaults = { cardnumber => "" }; #currently all the defaults come as "" if not filled
451
452
452
    #Make the test files for importing
453
    #Make the test files for importing
Lines 457-462 subtest 'test_import_with_password_overwrite' => sub { Link Here
457
    open(my $handle_2, "<", $filename_2) or die "cannot open < $filename_2: $!";
458
    open(my $handle_2, "<", $filename_2) or die "cannot open < $filename_2: $!";
458
    my $params_2 = { file => $handle_2, matchpoint => 'userid', overwrite_passwords => 1, overwrite_cardnumber => 1};
459
    my $params_2 = { file => $handle_2, matchpoint => 'userid', overwrite_passwords => 1, overwrite_cardnumber => 1};
459
460
461
    my $filename_3 = make_csv($temp_dir, $csv_headers, $csv_blank_password);
462
    open(my $handle_3, "<", $filename_3) or die "cannot open < $filename_3: $!";
463
    my $params_3 = { file => $handle_3, matchpoint => 'userid', overwrite_passwords => 1, overwrite_cardnumber => 1};
464
460
465
461
    my $result = $patrons_import->import_patrons($params_1, $defaults);
466
    my $result = $patrons_import->import_patrons($params_1, $defaults);
462
    like($result->{feedback}->[1]->{value}, qr/^Worrell \/ \d+/, 'First borrower imported as expected');
467
    like($result->{feedback}->[1]->{value}, qr/^Worrell \/ \d+/, 'First borrower imported as expected');
Lines 471-476 subtest 'test_import_with_password_overwrite' => sub { Link Here
471
    isnt($ernest->password,$orig_pass,"New patron is overwritten, password is overwritten");
476
    isnt($ernest->password,$orig_pass,"New patron is overwritten, password is overwritten");
472
    isnt($ernest->password,'Vern',"Password is overwritten and is encrypted from value provided");
477
    isnt($ernest->password,'Vern',"Password is overwritten and is encrypted from value provided");
473
478
479
    #Save info to check not changed
480
    $orig_pass = $ernest->password;
481
482
    $result = $patrons_import->import_patrons($params_3, $defaults);
483
    $ernest = Koha::Patrons->find({ userid => 'ErnestP' });
484
    is($ernest->surname,'Worel',"Patron is overwritten, surname changed");
485
    is($ernest->password,$orig_pass,"Patron was overwritten but password is not overwritten if blank");
486
474
};
487
};
475
488
476
489
477
- 

Return to bug 23473