Bugzilla – Attachment 64791 Details for
Bug 8137
Checkout limit for all libraries
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8137 - Add default issuing rule for all branches.
Bug-8137---Add-default-issuing-rule-for-all-branch.patch (text/plain), 11.98 KB, created by
Alex Arnaud
on 2017-07-04 08:58:09 UTC
(
hide
)
Description:
Bug 8137 - Add default issuing rule for all branches.
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2017-07-04 08:58:09 UTC
Size:
11.98 KB
patch
obsolete
>From 9c887ba84b9676df00171927b6a436a83e6dd594 Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Tue, 4 Jul 2017 08:37:48 +0000 >Subject: [PATCH] Bug 8137 - Add default issuing rule for all branches. > >This patch does the same that for 'Default checkout limit by patron >category'. > >test plan: > > - Create an issuing rule a patron category and itemtype. make it has priority, > - create more permissive issuing rules for all other branches, > - check that the priority rule is taken into account for this category > and itemtype. >--- > Koha/IssuingRules.pm | 16 +++++++++++ > Koha/Schema/Result/Issuingrule.pm | 16 +++++++++-- > admin/smart-rules.pl | 2 ++ > ...137-add-column-has_priority-in-issuingrules.sql | 3 ++ > .../prog/en/modules/admin/smart-rules.tt | 32 +++++++++++++++++++--- > t/db_dependent/Koha/IssuingRules.t | 29 +++++++++++++++++++- > 6 files changed, 90 insertions(+), 8 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority-in-issuingrules.sql > >diff --git a/Koha/IssuingRules.pm b/Koha/IssuingRules.pm >index e3664df..3a42970 100644 >--- a/Koha/IssuingRules.pm >+++ b/Koha/IssuingRules.pm >@@ -58,6 +58,22 @@ sub get_effective_issuing_rule { > $search_branchcode = { 'in' => [ $branchcode, $default ] }; > } > >+ # First check for priority rules >+ if (my $rule = $self->search({ >+ categorycode => $search_categorycode, >+ itemtype => $search_itemtype, >+ branchcode => '*', >+ has_priority => 1, >+ }, { >+ order_by => { >+ -desc => ['branchcode', 'categorycode', 'itemtype'] >+ }, >+ rows => 1, >+ })->single) { >+ return $rule; >+ } >+ >+ > my $rule = $self->search({ > categorycode => $search_categorycode, > itemtype => $search_itemtype, >diff --git a/Koha/Schema/Result/Issuingrule.pm b/Koha/Schema/Result/Issuingrule.pm >index 0ea74ca..f0432bc 100644 >--- a/Koha/Schema/Result/Issuingrule.pm >+++ b/Koha/Schema/Result/Issuingrule.pm >@@ -37,6 +37,12 @@ __PACKAGE__->table("issuingrules"); > is_nullable: 0 > size: 10 > >+=head2 has_priority >+ >+ data_type: 'integer' >+ default_value: 0 >+ is_nullable: 0 >+ > =head2 restrictedtype > > data_type: 'tinyint' >@@ -222,6 +228,8 @@ __PACKAGE__->add_columns( > { data_type => "varchar", default_value => "", is_nullable => 0, size => 10 }, > "itemtype", > { data_type => "varchar", default_value => "", is_nullable => 0, size => 10 }, >+ "has_priority", >+ { data_type => "integer", default_value => 0, is_nullable => 0 }, > "restrictedtype", > { data_type => "tinyint", is_nullable => 1 }, > "rentaldiscount", >@@ -306,15 +314,17 @@ __PACKAGE__->add_columns( > > =item * L</itemtype> > >+=item * L</has_priority> >+ > =back > > =cut > >-__PACKAGE__->set_primary_key("branchcode", "categorycode", "itemtype"); >+__PACKAGE__->set_primary_key("branchcode", "categorycode", "itemtype", "has_priority"); > > >-# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-04-27 19:15:48 >-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:D1443VWPcoIXN3+lIkckIQ >+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2017-06-30 12:12:06 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:NWH4eE+xaax7gnvWDAdxTg > > > # You can replace this text with custom code or comments, and it will be preserved on regeneration >diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl >index d779e5c..54e2a8a 100755 >--- a/admin/smart-rules.pl >+++ b/admin/smart-rules.pl >@@ -122,6 +122,7 @@ elsif ($op eq 'add') { > my $br = $branch; # branch > my $bor = $input->param('categorycode'); # borrower category > my $itemtype = $input->param('itemtype'); # item type >+ my $has_priority = $input->param('has_priority') ? 1 : 0; > my $fine = $input->param('fine'); > my $finedays = $input->param('finedays'); > my $maxsuspensiondays = $input->param('maxsuspensiondays'); >@@ -166,6 +167,7 @@ elsif ($op eq 'add') { > branchcode => $br, > categorycode => $bor, > itemtype => $itemtype, >+ has_priority => $has_priority, > fine => $fine, > finedays => $finedays, > maxsuspensiondays => $maxsuspensiondays, >diff --git a/installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority-in-issuingrules.sql b/installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority-in-issuingrules.sql >new file mode 100644 >index 0000000..c632b05 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority-in-issuingrules.sql >@@ -0,0 +1,3 @@ >+ALTER TABLE issuingrules ADD has_priority INT(1) DEFAULT 0 AFTER itemtype; >+ALTER TABLE issuingrules DROP primary key; >+ALTER TABLE issuingrules ADD primary key(branchcode , categorycode, itemtype, has_priority); >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >index d2ec909..9f52786 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >@@ -51,7 +51,7 @@ $(document).ready(function() { > itm = $(this).text(); > itm = itm.replace(/^\s*|\s*$/g,''); > var current_column = $("#edit_row td:eq("+i+")"); >- if ( i == 6 ) { >+ if ( i == 7 ) { > // specific processing for the Hard due date column > var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val(); > var input_value = ''; >@@ -62,11 +62,15 @@ $(document).ready(function() { > } > $(current_column).find("input[type='text']").val(input_value); > $(current_column).find("select").val(select_value); >- } else if ( i == 12 ) { >+ } else if ( i == 13 ) { > // specific processing for cap_fine_to_replacement_price > var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']"); > $('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') ); > $('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') ); >+ } else if ( i == 2 ) { >+ var has_priority = $(this).find("input[type='checkbox']"); >+ $('#has_priority').prop('checked', has_priority.is(':checked') ); >+ //$('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') ); > } else { > $(current_column).find("input[type='text']").val(itm); > // select the corresponding option >@@ -87,7 +91,7 @@ $(document).ready(function() { > // Remove potential previous input added > $(current_column).find("input").remove(); > $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />"); >- } else if ( i == 2 || i == 3 ) { >+ } else if ( i == 3 || i == 4 ) { > // If the value is not an integer for "Current checkouts allowed" or "Current on-site checkouts allowed" > // The value is "Unlimited" (or an equivalent translated string) > // an it should be set to an empty string >@@ -168,6 +172,7 @@ $(document).ready(function() { > <tr> > <th>Patron category</th> > <th>Item type</th> >+ [% UNLESS humanbranch %]<th>Has priority</th>[% END %] > <th>Current checkouts allowed</th> > <th>Current on-site checkouts allowed</th> > <th>Loan period</th> >@@ -211,6 +216,15 @@ $(document).ready(function() { > [% rule.translated_description %] > [% END %] > </td> >+ [% UNLESS humanbranch %] >+ <td> >+ [% IF rule.has_priority %] >+ <input type="checkbox" checked="checked" disabled="disabled"/> >+ [% ELSE %] >+ <input type="checkbox" disabled="disabled"/> >+ [% END %] >+ </td> >+ [% END %] > <td>[% IF ( rule.unlimited_maxissueqty ) %] > Unlimited > [% ELSE %] >@@ -315,6 +329,11 @@ $(document).ready(function() { > [% END %] > </select> > </td> >+ [% UNLESS humanbranch %] >+ <td> >+ <input type="checkbox" name="has_priority" id="has_priority"/> >+ </td> >+ [% END %] > <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td> > <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td> > <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td> >@@ -395,6 +414,7 @@ $(document).ready(function() { > <tr> > <th>Patron category</th> > <th>Item type</th> >+ [% UNLESS humanbranch %]<th>Has priority</th>[% END %] > <th>Current checkouts allowed</th> > <th>Current on-site checkouts allowed</th> > <th>Loan period</th> >@@ -588,7 +608,11 @@ $(document).ready(function() { > </td> > [% UNLESS humanbranch %] > <td> >- <input type="checkbox" [% IF branch_cat_rule_loo.has_priority %]checked[% END %] disabled/> >+ [% IF branch_cat_rule_loo.has_priority %] >+ <input type="checkbox" checked="checked" disabled/> >+ [% ELSE %] >+ <input type="checkbox" disabled/> >+ [% END %] > </td> > [% END %] > >diff --git a/t/db_dependent/Koha/IssuingRules.t b/t/db_dependent/Koha/IssuingRules.t >index 2285be1..557a5b8 100644 >--- a/t/db_dependent/Koha/IssuingRules.t >+++ b/t/db_dependent/Koha/IssuingRules.t >@@ -33,7 +33,7 @@ $schema->storage->txn_begin; > my $builder = t::lib::TestBuilder->new; > > subtest 'get_effective_issuing_rule' => sub { >- plan tests => 3; >+ plan tests => 4; > > my $patron = $builder->build({ source => 'Borrower' }); > my $item = $builder->build({ source => 'Item' }); >@@ -42,6 +42,33 @@ subtest 'get_effective_issuing_rule' => sub { > my $itemtype = $item->{'itype'}; > my $branchcode = $item->{'homebranch'}; > >+ subtest 'Priority rule' => sub { >+ plan tests => 3; >+ >+ Koha::IssuingRules->delete; >+ >+ ok(Koha::IssuingRule->new({ >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ })->store, "Given I added an issuing rule branchcode => $branchcode,' >+ .' categorycode => $categorycode, itemtype => $itemtype,"); >+ >+ ok(Koha::IssuingRule->new({ >+ branchcode => '*', >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ has_priority => 1, >+ })->store, "Add a priority rule."); >+ >+ my $rule = Koha::IssuingRules->get_effective_issuing_rule({ >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ }); >+ is($rule->has_priority, 1, 'Priority rule should be returned'); >+ }; >+ > subtest 'Call with undefined values' => sub { > plan tests => 4; > >-- >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 8137
:
9705
|
9706
|
11079
|
64703
|
64704
|
64791
|
64891
|
72831
|
72832
|
107207
|
107208
|
107209
|
107459
|
111368
|
111369
|
111370
|
112640
|
113797
|
113882
|
114531
|
114532
|
114533
|
114534
|
116676
|
116677
|
116678
|
116679
|
116680
|
145476
|
145477
|
145478
|
145479
|
145480
|
152040
|
152041
|
152042
|
152043
|
152044
|
152045
|
156316
|
156317
|
156318
|
156319
|
156320
|
156321
|
156322
|
159712
|
162367
|
167208
|
167923
|
168119
|
169084
|
169696
|
169700
|
169727
|
169927
|
169928
|
170411
|
173605
|
173608
|
175837
|
175838
|
177464