From 0c26c7ba8a6d383057db6714a2ce9bb456098e7b Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 1 Jan 2015 18:13:04 -0500 Subject: [PATCH] Bug 11023 [QA Followup] - Complete the renaming of "toggle new status" to "automatic item modification by age" Signed-off-by: Kyle M Hall --- installer/data/mysql/kohastructure.sql | 4 +- .../intranet-tmpl/prog/en/css/staff-global.css | 2 +- .../en/modules/help/tools/toggle_new_status.tt | 2 +- ...us.tt => automatic_item_modification_by_age.tt} | 10 +- .../prog/en/modules/tools/tools-home.tt | 2 +- .../cronjobs/automatic_item_modification_by_age.pl | 6 +- t/db_dependent/Items/ToggleNewStatus.t | 283 -------------------- ...us.pl => automatic_item_modification_by_age.pl} | 6 +- 8 files changed, 16 insertions(+), 299 deletions(-) rename koha-tmpl/intranet-tmpl/prog/en/modules/tools/{toggle_new_status.tt => automatic_item_modification_by_age.tt} (95%) delete mode 100644 t/db_dependent/Items/ToggleNewStatus.t rename tools/{toggle_new_status.pl => automatic_item_modification_by_age.pl} (94%) diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 9f68322..691dc64 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -946,7 +946,7 @@ CREATE TABLE `deleteditems` ( `enumchron` text default NULL, -- serial enumeration/chronology for the item (MARC21 952$h) `copynumber` varchar(32) default NULL, -- copy number (MARC21 952$t) `stocknumber` varchar(32) default NULL, -- inventory number (MARC21 952$i) - `new` VARCHAR(32) DEFAULT NULL, -- 'new' value, you can put whatever free-text information. This field is intented to be managed by the toggle_new_status cronjob. + `new` VARCHAR(32) DEFAULT NULL, -- 'new' value, you can put whatever free-text information. This field is intented to be managed by the automatic_item_modification_by_age cronjob. PRIMARY KEY (`itemnumber`), KEY `delitembarcodeidx` (`barcode`), KEY `delitemstocknumberidx` (`stocknumber`), @@ -1246,7 +1246,7 @@ CREATE TABLE `items` ( -- holdings/item information `enumchron` text default NULL, -- serial enumeration/chronology for the item (MARC21 952$h) `copynumber` varchar(32) default NULL, -- copy number (MARC21 952$t) `stocknumber` varchar(32) default NULL, -- inventory number (MARC21 952$i) - `new` VARCHAR(32) DEFAULT NULL, -- 'new' value, you can put whatever free-text information. This field is intended to be managed by the toggle_new_status cronjob. + `new` VARCHAR(32) DEFAULT NULL, -- 'new' value, you can put whatever free-text information. This field is intended to be managed by the automatic_item_modification_by_age cronjob. PRIMARY KEY (`itemnumber`), UNIQUE KEY `itembarcodeidx` (`barcode`), KEY `itemstocknumberidx` (`stocknumber`), diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css index 9e50d0e..bf558ba 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css +++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css @@ -2759,7 +2759,7 @@ span.onsite_checkout { border : 1px solid #FFF2CE; } -/* Tools > toggle_new_status */ +/* Tools > automatic_item_modification_by_age */ div.rules { display: block; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/help/tools/toggle_new_status.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/help/tools/toggle_new_status.tt index 0bb591f..292703a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/help/tools/toggle_new_status.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/help/tools/toggle_new_status.tt @@ -38,7 +38,7 @@

How to execute the cronjob script?

-

The cronjob script is misc/cronjobs/toggle_new_status.pl.

+

The cronjob script is misc/cronjobs/automatic_item_modification_by_age.pl.

Try the -h parameter in order to see the help.

Without any parameter, the script will be launched in a dry-run mode. If the -c (or --confirm) flag is given, the script will apply the changes.

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/toggle_new_status.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/automatic_item_modification_by_age.tt similarity index 95% rename from koha-tmpl/intranet-tmpl/prog/en/modules/tools/toggle_new_status.tt rename to koha-tmpl/intranet-tmpl/prog/en/modules/tools/automatic_item_modification_by_age.tt index 86f47b4..a08e96d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/toggle_new_status.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/automatic_item_modification_by_age.tt @@ -113,10 +113,10 @@ //]]> - + [% INCLUDE 'header.inc' %] [% INCLUDE 'cat-search.inc' %] - +
@@ -124,7 +124,7 @@

Automatic item modifications by age

[% FOR message IN messages %] [% IF message.type == "error" %] @@ -137,7 +137,7 @@ [% END %] [% IF op == 'edit_form' %] -
+

List of rules

@@ -200,7 +200,7 @@
- Cancel + Cancel
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt index bac4510..146eb11 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt @@ -128,7 +128,7 @@ [% END %] [% IF ( CAN_user_tools_items_batchmod ) %] -
Automatic item modifications by age
+
Automatic item modifications by age
Define rules to modify items by age
[% END %] diff --git a/misc/cronjobs/automatic_item_modification_by_age.pl b/misc/cronjobs/automatic_item_modification_by_age.pl index 3ed3e46..51effd3 100755 --- a/misc/cronjobs/automatic_item_modification_by_age.pl +++ b/misc/cronjobs/automatic_item_modification_by_age.pl @@ -21,7 +21,7 @@ pod2usage(1) if $help; $verbose = 1 unless $confirm; # Load configuration from the syspref -my $syspref_content = C4::Context->preference('toggle_new_status_configuration'); +my $syspref_content = C4::Context->preference('automatic_item_modification_by_age_configuration'); my $rules = eval { JSON::from_json( $syspref_content ) }; pod2usage({ -message => "Unable to load the configuration : $@", -exitval => 1 }) if $@; @@ -51,11 +51,11 @@ __END__ =head1 NAME -toggle_new_status.pl +automatic_item_modification_by_age.pl =head1 SYNOPSIS -./toggle_new_status.pl -h +./automatic_item_modification_by_age.pl -h Toggle recent acquisitions status. Use this script to delete "new" status for items. diff --git a/t/db_dependent/Items/ToggleNewStatus.t b/t/db_dependent/Items/ToggleNewStatus.t deleted file mode 100644 index 3f2943c..0000000 --- a/t/db_dependent/Items/ToggleNewStatus.t +++ /dev/null @@ -1,283 +0,0 @@ -#!/usr/bin/perl - -use Modern::Perl; -use Test::More tests => 16; -use MARC::Record; -use MARC::Field; -use DateTime; -use DateTime::Duration; - -use C4::Biblio; -use C4::Context; -use C4::Items; -use Koha::DateUtils; - -my $dbh = C4::Context->dbh; -$dbh->{AutoCommit} = 0; -$dbh->{RaiseError} = 1; - -$dbh->do(q| - DELETE FROM marc_subfield_structure - WHERE kohafield = 'items.new' OR kohafield = 'items.stocknumber' -|); - -my $new_tagfield = 'i'; -$dbh->do(qq| - INSERT INTO marc_subfield_structure(tagfield, tagsubfield, kohafield, frameworkcode) - VALUES ( 952, '$new_tagfield', 'items.new', '' ) -|); - -my $record = MARC::Record->new(); -$record->append_fields( - MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), - MARC::Field->new('245', ' ', ' ', a => 'Silence in the library'), - MARC::Field->new('942', ' ', ' ', c => 'ITEMTYPE_T'), -); -my ($biblionumber, undef) = C4::Biblio::AddBiblio($record, ''); - -my ($item_bibnum, $item_bibitemnum, $itemnumber) = C4::Items::AddItem( - { - homebranch => 'CPL', - holdingbranch => 'CPL', - new => 'new_value', - ccode => 'FIC', - }, - $biblionumber -); - -my $item = C4::Items::GetItem( $itemnumber ); -is ( $item->{new}, 'new_value', q|AddItem insert the 'new' field| ); - -my ( $tagfield, undef ) = GetMarcFromKohaField('items.itemnumber', ''); -my $marc_item = C4::Items::GetMarcItem( $biblionumber, $itemnumber ); -is( $marc_item->subfield($tagfield, $new_tagfield), 'new_value', q|Koha mapping is correct|); - -# Update the items.new field if items.ccode eq 'FIC' => should be updated -my @rules = ( - { - conditions => [ - { - field => 'items.ccode', - value => 'FIC', - }, - ], - substitutions => [ - { - field => 'items.new', - value => 'updated_value', - }, - ], - age => '0', - }, -); - -C4::Items::ToggleNewStatus( { rules => \@rules } ); - -my $modified_item = C4::Items::GetItem( $itemnumber ); -is( $modified_item->{new}, 'updated_value', q|ToggleNewStatus: The new value is updated|); -$marc_item = C4::Items::GetMarcItem( $biblionumber, $itemnumber ); -is( $marc_item->subfield($tagfield, $new_tagfield), 'updated_value', q|ToggleNewStatus: The new value is updated| ); - -# Update the items.new field if items.ccode eq 'DONT_EXIST' => should not be updated -@rules = ( - { - conditions => [ - { - field => 'items.ccode', - value => 'DONT_EXIST', - }, - ], - substitutions => [ - { - field => 'items.new', - value => 'new_updated_value', - }, - ], - age => '0', - }, -); - -C4::Items::ToggleNewStatus( { rules => \@rules } ); - -$modified_item = C4::Items::GetItem( $itemnumber ); -is( $modified_item->{new}, 'updated_value', q|ToggleNewStatus: The new value is not updated|); -$marc_item = C4::Items::GetMarcItem( $biblionumber, $itemnumber ); -is( $marc_item->subfield($tagfield, $new_tagfield), 'updated_value', q|ToggleNewStatus: The new value is not updated| ); - -# Play with age -$item = C4::Items::GetItem( $itemnumber ); -my $dt_today = dt_from_string; -my $days5ago = $dt_today->add_duration( DateTime::Duration->new( days => -5 ) ); - -C4::Items::ModItem( { dateaccessioned => $days5ago }, $biblionumber, $itemnumber ); -$item = C4::Items::GetItem( $itemnumber ); - -@rules = ( - { - conditions => [ - { - field => 'items.ccode', - value => 'FIC', - }, - ], - substitutions => [ - { - field => 'items.new', - value => 'new_updated_value', - }, - ], - age => '10', - }, -); -C4::Items::ToggleNewStatus( { rules => \@rules } ); -$modified_item = C4::Items::GetItem( $itemnumber ); -is( $modified_item->{new}, 'updated_value', q|ToggleNewStatus: Age = 10 : The new value is not updated|); - -$rules[0]->{age} = 5; -$rules[0]->{substitutions}[0]{value} = 'new_updated_value5'; -C4::Items::ToggleNewStatus( { rules => \@rules } ); -$modified_item = C4::Items::GetItem( $itemnumber ); -is( $modified_item->{new}, 'new_updated_value5', q|ToggleNewStatus: Age = 5 : The new value is updated|); - -$rules[0]->{age} = ''; -$rules[0]->{substitutions}[0]{value} = 'new_updated_value_empty_string'; -C4::Items::ToggleNewStatus( { rules => \@rules } ); -$modified_item = C4::Items::GetItem( $itemnumber ); -is( $modified_item->{new}, 'new_updated_value_empty_string', q|ToggleNewStatus: Age = '' : The new value is updated|); - -$rules[0]->{age} = undef; -$rules[0]->{substitutions}[0]{value} = 'new_updated_value_undef'; -C4::Items::ToggleNewStatus( { rules => \@rules } ); -$modified_item = C4::Items::GetItem( $itemnumber ); -is( $modified_item->{new}, 'new_updated_value_undef', q|ToggleNewStatus: Age = undef : The new value is updated|); - -# Field deletion -@rules = ( - { - conditions => [ - { - field => 'items.ccode', - value => 'FIC', - }, - ], - substitutions => [ - { - field => 'items.new', - value => '', - }, - ], - age => '0', - }, -); - -C4::Items::ToggleNewStatus( { rules => \@rules } ); - -$modified_item = C4::Items::GetItem( $itemnumber ); -is( $modified_item->{new}, '', q|ToggleNewStatus: The new value is empty|); -$marc_item = C4::Items::GetMarcItem( $biblionumber, $itemnumber ); -is( $marc_item->subfield($tagfield, $new_tagfield), undef, q|ToggleNewStatus: The new field is removed from the item marc| ); - -# conditions multiple -@rules = ( - { - conditions => [ - { - field => 'items.ccode', - value => 'FIC', - }, - { - field => 'items.homebranch', - value => 'CPL', - }, - ], - substitutions => [ - { - field => 'items.new', - value => 'new_value', - }, - ], - age => '0', - }, -); - -C4::Items::ToggleNewStatus( { rules => \@rules } ); - -$modified_item = C4::Items::GetItem( $itemnumber ); -is( $modified_item->{new}, 'new_value', q|ToggleNewStatus: conditions multiple: all match, the new value is updated|); - -@rules = ( - { - conditions => [ - { - field => 'items.ccode', - value => 'FIC', - }, - { - field => 'items.homebranch', - value => 'DONT_EXIST', - }, - ], - substitutions => [ - { - field => 'items.new', - value => 'new_updated_value', - }, - ], - age => '0', - }, -); - -C4::Items::ToggleNewStatus( { rules => \@rules } ); - -$modified_item = C4::Items::GetItem( $itemnumber ); -is( $modified_item->{new}, 'new_value', q|ToggleNewStatus: conditions multiple: at least 1 condition does not match, the new value is not updated|); - -@rules = ( - { - conditions => [ - { - field => 'items.ccode', - value => 'FIC|NFIC', - }, - { - field => 'items.homebranch', - value => 'MPL|CPL', - }, - ], - substitutions => [ - { - field => 'items.new', - value => 'new_updated_value', - }, - ], - age => '0', - }, -); - -C4::Items::ToggleNewStatus( { rules => \@rules } ); - -$modified_item = C4::Items::GetItem( $itemnumber ); -is( $modified_item->{new}, 'new_updated_value', q|ToggleNewStatus: conditions multiple: the 2 conditions match, the new value is updated|); - -@rules = ( - { - conditions => [ - { - field => 'biblioitems.itemtype', - value => 'ITEMTYPE_T', - }, - ], - substitutions => [ - { - field => 'items.new', - value => 'another_new_updated_value', - }, - ], - age => '0', - }, -); - -C4::Items::ToggleNewStatus( { rules => \@rules } ); - -$modified_item = C4::Items::GetItem( $itemnumber ); -is( $modified_item->{new}, 'another_new_updated_value', q|ToggleNewStatus: conditions on biblioitems|); diff --git a/tools/toggle_new_status.pl b/tools/automatic_item_modification_by_age.pl similarity index 94% rename from tools/toggle_new_status.pl rename to tools/automatic_item_modification_by_age.pl index 9d4c590..eca339c 100755 --- a/tools/toggle_new_status.pl +++ b/tools/automatic_item_modification_by_age.pl @@ -19,7 +19,7 @@ =head1 NAME -toggle_new_status.pl: Update new status for items. +automatic_item_modification_by_age.pl: Update new status for items. =cut @@ -45,7 +45,7 @@ my $cgi = new CGI; # open template my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { - template_name => "tools/toggle_new_status.tt", + template_name => "tools/automatic_item_modification_by_age.tt", query => $cgi, type => "intranet", authnotrequired => 0, @@ -55,7 +55,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( my $op = $cgi->param('op') // 'show'; -my $syspref_name = q|toggle_new_status_configuration|; +my $syspref_name = q|automatic_item_modification_by_age_configuration|; if ( $op eq 'update' ) { my @rules; my @unique_ids = $cgi->param('unique_id'); -- 1.7.2.5