Bugzilla – Attachment 63530 Details for
Bug 10383
printable version of bib record doesn't include subtitle in staff client
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10382 - Course reserves: handle empty values
Bug-10382---Course-reserves-handle-empty-values.patch (text/plain), 8.69 KB, created by
Alex Arnaud
on 2017-05-18 13:35:44 UTC
(
hide
)
Description:
Bug 10382 - Course reserves: handle empty values
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2017-05-18 13:35:44 UTC
Size:
8.69 KB
patch
obsolete
>From 4a98ec030d48abfccee2c442fdb623a4e1829091 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] Bug 10382 - Course reserves: handle empty values > >DB changes: > - remove course_items_ibfk_2, > - set course_items.itype to VARCHAR(20), > - set course_items.ccode to VARCHAR(20), > - set course_items.holdingbranch to VARCHAR(20), > >https://bugs.koha-community.org/show_bug.cgi?id=10383 >--- > C4/CourseReserves.pm | 4 ++-- > .../atomicupdate/bug_10382-changes-on-courseitems-table.sql | 4 ++++ > installer/data/mysql/kohastructure.sql | 7 +++---- > .../prog/en/modules/course_reserves/add_items-step2.tt | 8 ++++---- > t/db_dependent/CourseReserves/CourseItems.t | 12 ++++++++---- > 5 files changed, 21 insertions(+), 14 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/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index c293b79..a3b9d49 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -3780,9 +3780,9 @@ DROP TABLE IF EXISTS course_items; > CREATE TABLE `course_items` ( > `ci_id` int(11) NOT NULL AUTO_INCREMENT, -- course item id > `itemnumber` int(11) NOT NULL, -- items.itemnumber for the item on reserve >- `itype` varchar(10) DEFAULT NULL, -- new itemtype for the item to have while on reserve (optional) >- `ccode` varchar(10) DEFAULT NULL, -- new category code for the item to have while on reserve (optional) >- `holdingbranch` varchar(10) DEFAULT NULL, -- new holding branch for the item to have while on reserve (optional) >+ `itype` varchar(20) DEFAULT NULL, -- new itemtype for the item to have while on reserve (optional) >+ `ccode` varchar(20) DEFAULT NULL, -- new category code for the item to have while on reserve (optional) >+ `holdingbranch` varchar(20) DEFAULT NULL, -- new holding branch for the item to have while on reserve (optional) > `location` varchar(80) DEFAULT NULL, -- new shelving location for the item to have while on reseve (optional) > `enabled` enum('yes','no') NOT NULL DEFAULT 'no', -- if at least one enabled course has this item on reseve, this field will be 'yes', otherwise it will be 'no' > `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, >@@ -3795,7 +3795,6 @@ CREATE TABLE `course_items` ( > -- Constraints for table `course_items` > -- > ALTER TABLE `course_items` >- ADD CONSTRAINT `course_items_ibfk_2` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE, > ADD CONSTRAINT `course_items_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE; > > -- >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.7.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 10383
:
18526
|
63530