Bugzilla – Attachment 51371 Details for
Bug 12598
New misc/import_borrowers.pl command line tool
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12598 - Rebase + backport of 16426 plus fixing 16426
Bug-12598---Rebase--backport-of-16426-plus-fixing-.patch (text/plain), 4.84 KB, created by
Florent Mara
on 2016-05-10 03:50:01 UTC
(
hide
)
Description:
Bug 12598 - Rebase + backport of 16426 plus fixing 16426
Filename:
MIME Type:
Creator:
Florent Mara
Created:
2016-05-10 03:50:01 UTC
Size:
4.84 KB
patch
obsolete
>From e88c9d36310e56538721f608081252c25000309f Mon Sep 17 00:00:00 2001 >From: Florent Mara <florent.mara@gmail.com> >Date: Tue, 10 May 2016 14:28:30 +1200 >Subject: [PATCH] Bug 12598 - Rebase + backport of 16426 plus fixing 16426 > >--- > Koha/Patrons/Import.pm | 20 +++++++++++--------- > t/db_dependent/Koha/Patrons/Import.t | 17 +++++++++++------ > 2 files changed, 22 insertions(+), 15 deletions(-) > >diff --git a/Koha/Patrons/Import.pm b/Koha/Patrons/Import.pm >index e53bbac..65fae71 100644 >--- a/Koha/Patrons/Import.pm >+++ b/Koha/Patrons/Import.pm >@@ -138,7 +138,6 @@ sub import_patrons { > # Popular spreadsheet applications make it difficult to force date outputs to be zero-padded, but we require it. > $self->format_dates({borrower => \%borrower, lineraw => $borrowerline, line => $line_number, missing_criticals => \@missing_criticals, }); > >- > if (@missing_criticals) { > foreach (@missing_criticals) { > $_->{borrowernumber} = $borrower{borrowernumber} || 'UNDEF'; >@@ -189,14 +188,16 @@ sub import_patrons { > $invalid++; > next; > } >- >- # generate a proper login if none provided >- if ( $borrower{userid} eq '' || !Check_Userid( $borrower{userid} ) ) { >- push @errors, { duplicate_userid => 1, userid => $borrower{userid} }; >- $invalid++; >- next LINE; >- } >- >+ >+ # Check if the userid provided does not exist yet >+ if ( exists $borrower{userid} >+ and $borrower{userid} >+ and not Check_Userid( $borrower{userid}, $borrower{borrowernumber} ) ) { >+ push @errors, { duplicate_userid => 1, userid => $borrower{userid} }; >+ $invalid++; >+ next LINE; >+ } >+ > if ($borrowernumber) { > > # borrower exists >@@ -224,6 +225,7 @@ sub import_patrons { > $borrower{$col} = $member->{$col} if ( $member->{$col} ); > } > } >+ > unless ( ModMember(%borrower) ) { > $invalid++; > >diff --git a/t/db_dependent/Koha/Patrons/Import.t b/t/db_dependent/Koha/Patrons/Import.t >index 8714968..abcca11 100644 >--- a/t/db_dependent/Koha/Patrons/Import.t >+++ b/t/db_dependent/Koha/Patrons/Import.t >@@ -19,8 +19,9 @@ > > use Modern::Perl; > use Test::More tests => 122; >-use Test::MockModule; > >+# To be replaced by t::lib::Mock >+use Test::MockModule; > use Koha::Database; > > use File::Temp qw(tempfile tempdir); >@@ -73,6 +74,14 @@ my $result_0 = $patrons_import->import_patrons($params_0); > is($result_0, undef, 'Got the expected undef from import_patrons with no file handle'); > > # Given ... a file handle to file with headers only. >+my $ExtendedPatronAttributes = 0; >+my $context = Test::MockModule->new('C4::Context'); # Necessary mocking for consistent test results. >+$context->mock('preference', sub { my ($mod, $meth) = @_; >+ if ( $meth eq 'ExtendedPatronAttributes' ) { return $ExtendedPatronAttributes; } >+ if ( $meth eq 'dateformat' ) { return 'us'; } >+ }); >+ >+ > my $csv_headers = 'cardnumber,surname,firstname,title,othernames,initials,streetnumber,streettype,address,address2,city,state,zipcode,country,email,phone,mobile,fax,dateofbirth,branchcode,categorycode,dateenrolled,dateexpiry,userid,password'; > my $res_header = 'cardnumber, surname, firstname, title, othernames, initials, streetnumber, streettype, address, address2, city, state, zipcode, country, email, phone, mobile, fax, dateofbirth, branchcode, categorycode, dateenrolled, dateexpiry, userid, password'; > my $csv_one_line = '1000,Nancy,Jenkins,Dr,,NJ,78,Circle,Bunting,El Paso,Henderson,Texas,79984,United States,ajenkins0@sourceforge.net,7-(388)559-6763,3-(373)151-4471,8-(509)286-4001,10/16/1965,CPL,PT,12/28/2014,07/01/2015,jjenkins0,DPQILy'; >@@ -144,11 +153,7 @@ is($result_3->{invalid}, 1, 'Got the expected 1 invalid result from import_patro > is($result_3->{overwritten}, 0, 'Got the expected 0 overwritten result from import_patrons with duplicate userid'); > > # Given ... a new input and mocked C4::Context >-my $context = Test::MockModule->new('C4::Context'); >-$context->mock('preference', sub { my ($mod, $meth) = @_; >- if ( $meth eq 'ExtendedPatronAttributes' ) { return 1; } >- if ( $meth eq 'dateformat' ) { return 'us'; } >- }); >+$ExtendedPatronAttributes = 1; # Updates mocked C4::Preferences result. > > my $new_input_line = '1001,Donna,Sullivan,Mrs,Henry,DS,59,Court,Burrows,Reading,Salt Lake City,Pennsylvania,19605,United States,hsullivan1@purevolume.com,3-(864)009-3006,7-(291)885-8423,1-(879)095-5038,09/19/1970,LPL,PT,03/04/2015,07/01/2015,hsullivan1,8j6P6Dmap'; > my $filename_4 = make_csv($temp_dir, $csv_headers, $new_input_line); >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12598
:
29807
|
29808
|
29809
|
29939
|
30755
|
30780
|
35557
|
35558
|
35559
|
35560
|
35848
|
35849
|
35850
|
35851
|
35964
|
36684
|
36685
|
36687
|
36688
|
36690
|
36692
|
36693
|
36694
|
36695
|
36696
|
39124
|
39125
|
39126
|
39127
|
39128
|
41790
|
41791
|
41792
|
41793
|
41794
|
44065
|
44066
|
44067
|
44068
|
44069
|
48753
|
48754
|
48755
|
48756
|
48757
|
50693
|
50694
|
50695
|
50696
|
50697
|
50698
|
50699
|
50700
|
50704
|
51122
|
51357
|
51358
|
51359
|
51360
|
51361
|
51362
|
51363
|
51364
|
51365
|
51366
|
51367
|
51368
|
51369
|
51370
|
51371
|
51372
|
52323
|
52324
|
52325
|
52326
|
52327
|
52328
|
52329
|
52330
|
52331
|
52332
|
52333
|
52540
|
64437
|
64438
|
64855
|
65214
|
65215
|
65216
|
65217
|
65218
|
65819
|
65820
|
65821
|
65822
|
65823
|
65824
|
66353
|
66354
|
66355
|
66356
|
66357
|
66358
|
66359
|
66575
|
66576
|
66577
|
66578
|
66579
|
66580
|
66581
|
66582
|
67276
|
67277
|
70265
|
70266
|
71755
|
71756
|
71757
|
71758
|
71759
|
71760
|
71761
|
71762
|
71763
|
71764
|
71765
|
71766