Bugzilla – Attachment 61816 Details for
Bug 10382
collection and location not returning to null when removed from course reserves
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 10382 - Course reserves: handle empty values
SIGNED-OFF-Bug-10382---Course-reserves-handle-empt.patch (text/plain), 6.62 KB, created by
Josef Moravec
on 2017-04-04 12:17:32 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 10382 - Course reserves: handle empty values
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2017-04-04 12:17:32 UTC
Size:
6.62 KB
patch
obsolete
>From eed98a43fad064dfc6efa2a15bf27861b6f79ba6 Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Fri, 10 Mar 2017 09:43:56 +0000 >Subject: [PATCH] [SIGNED-OFF] Bug 10382 - Course reserves: handle empty values > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > C4/CourseReserves.pm | 4 ++-- > .../atomicupdate/bug_10382-changes-on-courseitems-table.sql | 4 ++++ > .../prog/en/modules/course_reserves/add_items-step2.tt | 8 ++++---- > t/db_dependent/CourseReserves/CourseItems.t | 12 ++++++++---- > 4 files changed, 18 insertions(+), 10 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_10382-changes-on-courseitems-table.sql > >diff --git a/C4/CourseReserves.pm b/C4/CourseReserves.pm >index 9fea72c..cfd11d7 100644 >--- a/C4/CourseReserves.pm >+++ b/C4/CourseReserves.pm >@@ -642,7 +642,7 @@ sub _RevertFields { > my @fields_to_null; > foreach my $field (@fields) { > foreach (@FIELDS) { >- if ( $field eq $_ && $course_item->{$_} ) { >+ if ( $field eq $_ && $course_item->{$_} ne '<UNCHANGED>' ) { > $mod_item_params->{$_} = $course_item->{$_}; > push( @fields_to_null, $_ ); > } >@@ -671,7 +671,7 @@ sub _SwapAllFields { > my %course_item_fields; > my %item_fields; > foreach (@FIELDS) { >- if ( defined( $course_item->{$_} ) ) { >+ if ( defined( $course_item->{$_} ) && $course_item->{$_} ne '<UNCHANGED>' ) { > $course_item_fields{$_} = $course_item->{$_}; > $item_fields{$_} = $item->{$_} || q{}; > } >diff --git a/installer/data/mysql/atomicupdate/bug_10382-changes-on-courseitems-table.sql b/installer/data/mysql/atomicupdate/bug_10382-changes-on-courseitems-table.sql >new file mode 100644 >index 0000000..3aaacc0 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_10382-changes-on-courseitems-table.sql >@@ -0,0 +1,4 @@ >+ALTER TABLE course_items DROP FOREIGN KEY course_items_ibfk_2; >+ALTER TABLE course_items MODIFY itype VARCHAR(20); >+ALTER TABLE course_items MODIFY ccode VARCHAR(20); >+ALTER TABLE course_items MODIFY holdingbranch VARCHAR(20); >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt >index ef22421..28a0563 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt >@@ -35,7 +35,7 @@ > <li> > <label class="required" for="itype">Item type:</label> > <select id="itype" name="itype"> >- <option value="">LEAVE UNCHANGED</option> >+ <option value="<UNCHANGED>">LEAVE UNCHANGED</option> > > [% FOREACH it IN itypes %] > [% IF course_item.itype.defined && ( ( course.enabled == 'yes' && it.itemtype == item.itype ) || ( course.enabled == 'no' && it.itemtype == course_item.itype ) ) %] >@@ -51,7 +51,7 @@ > <li> > <label class="required" for="ccode">Collection code:</label> > <select id="ccode" name="ccode"> >- <option value="">LEAVE UNCHANGED</option> >+ <option value="<UNCHANGED>">LEAVE UNCHANGED</option> > > [% FOREACH c IN ccodes %] > [% IF course_item.ccode.defined && ( ( course.enabled == 'yes' && c.authorised_value == item.ccode ) || ( course.enabled == 'no' && c.authorised_value == course_item.ccode ) ) %] >@@ -66,7 +66,7 @@ > <li> > <label class="required" for="location">Shelving location:</label> > <select id="location" name="location"> >- <option value="">LEAVE UNCHANGED</option> >+ <option value="<UNCHANGED>">LEAVE UNCHANGED</option> > > [% FOREACH s IN locations %] > [% IF course_item.location.defined && ( ( course.enabled == 'yes' && s.authorised_value == item.location ) || ( course.enabled == 'no' && s.authorised_value == course_item.location ) ) %] >@@ -81,7 +81,7 @@ > <li> > <label class="required" for="holdingbranch">Holding library:</label> > <select id="holdingbranch" name="holdingbranch"> >- <option value="">LEAVE UNCHANGED</option> >+ <option value="<UNCHANGED>">LEAVE UNCHANGED</option> > [% FOREACH b IN Branches.all() %] > [% IF course_item.holdingbranch.defined && ( ( course.enabled == 'yes' && b.value == item.holdingbranch ) || ( course.enabled == 'no' && b.value == course_item.holdingbranch ) ) %] > <option value="[% b.branchcode %]" selected="selected">[% b.branchname %]</option> >diff --git a/t/db_dependent/CourseReserves/CourseItems.t b/t/db_dependent/CourseReserves/CourseItems.t >index c2bb237..00b561d 100644 >--- a/t/db_dependent/CourseReserves/CourseItems.t >+++ b/t/db_dependent/CourseReserves/CourseItems.t >@@ -23,7 +23,7 @@ use C4::CourseReserves qw/ModCourseItem ModCourseReserve DelCourseReserve GetCou > use C4::Context; > use Koha::Items; > >-use Test::More tests => 17; >+use Test::More tests => 21; > > BEGIN { > require_ok('C4::CourseReserves'); >@@ -83,10 +83,10 @@ is($item->ccode, '', 'Item ccode should be empty'); > > my $ci_id2 = ModCourseItem( > itemnumber => $itemnumber, >- itype => 'CD_foo', >+ itype => '<UNCHANGED>', > ccode => 'BOOK', >- holdingbranch => 'B1', >- location => 'HR', >+ holdingbranch => '<UNCHANGED>', >+ location => '<UNCHANGED>', > ); > > my $cr_id2 = ModCourseReserve( >@@ -97,10 +97,14 @@ my $cr_id2 = ModCourseReserve( > ); > > $item = Koha::Items->find($itemnumber); >+is($item->itype, 'CD_foo', 'Item type should be CD_foo'); > is($item->ccode, 'BOOK', 'Item ccode should be BOOK'); > > my $course_item2 = GetCourseItem( ci_id => $ci_id2 ); >+is($course_item2->{itype}, '<UNCHANGED>', 'Course item ccode should be <UNCHANGED>'); > is($course_item2->{ccode}, '', 'Course item ccode should be empty'); >+is($course_item2->{holdingbranch}, '<UNCHANGED>', 'Course item holding branch should be <UNCHANGED>'); >+is($course_item2->{location}, '<UNCHANGED>', 'Course item location should be <UNCHANGED>'); > > DelCourseReserve( cr_id => $cr_id2 ); > $item = Koha::Items->find($itemnumber); >-- >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 10382
:
18674
|
19611
|
60947
|
60948
|
60979
|
61814
|
61815
|
61816
|
63531
|
72022
|
79030
|
79031
|
79032
|
79114
|
79115
|
79116
|
79207
|
79208
|
79209
|
79722
|
79723
|
79724
|
80007
|
80008
|
80009