From f0994d08989bdd40cffdc246d9a5c720e0b24644 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 23 Sep 2014 10:02:08 +0200 Subject: [PATCH] Bug 11023: Rename the duration parameter with 'age' --- C4/Items.pm | 6 ++-- .../prog/en/modules/tools/toggle_new_status.tt | 24 ++++++++-------- t/db_dependent/Items/ToggleNewStatus.t | 32 +++++++++++----------- tools/toggle_new_status.pl | 2 +- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index 90c8763..37d9f87 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -2934,7 +2934,7 @@ sub ToggleNewStatus { my @biblioitem_columns = map { "biblioitems.$_" } C4::Items::biblioitems_columns; my $report; for my $rule ( @rules ) { - my $duration = $rule->{duration}; + my $age = $rule->{age}; my $conditions = $rule->{conditions}; my $substitutions = $rule->{substitutions}; my @params; @@ -2962,9 +2962,9 @@ sub ToggleNewStatus { } } } - if ( defined $duration ) { + if ( defined $age ) { $query .= q| AND TO_DAYS(NOW()) - TO_DAYS(dateaccessioned) >= ? |; - push @params, $duration; + push @params, $age; } my $sth = $dbh->prepare($query); $sth->execute( @params ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/toggle_new_status.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/toggle_new_status.tt index 7791d6f..f9aa6ce 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/toggle_new_status.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/toggle_new_status.tt @@ -65,7 +65,7 @@ $(new_rule).find("select[name='substitution_field']").attr('name', 'substitution_field_' + unique_id); $(new_rule).find("input[name='condition_value']").attr('name', 'condition_value_' + unique_id); $(new_rule).find("input[name='substitution_value']").attr('name', 'substitution_value_' + unique_id); - $(new_rule).find("input[name='duration']").attr('name', 'duration_' + unique_id); + $(new_rule).find("input[name='age']").attr('name', 'age_' + unique_id); $(new_rule).find("input[name='unique_id']").val(unique_id); $("#rules").append(new_rule); @@ -145,9 +145,9 @@ [% SET id = loop.count %]
-
-
Duration
- days +
+
Age
+ days
Conditions
@@ -208,9 +208,9 @@

Add a new rule

-
-
Duration
- days +
+
Age
+ days
Conditions
@@ -250,12 +250,12 @@

List of rules

[% FOR rule IN rules %]
-
-
Duration
- [% IF rule.duration.defined and rule.duration.length > 0 %] - [% rule.duration %] days +
+
Age
+ [% IF rule.age.defined and rule.age.length > 0 %] + [% rule.age %] days [% ELSE %] - There is no duration for this rule. + There is no age for this rule. [% END %]
diff --git a/t/db_dependent/Items/ToggleNewStatus.t b/t/db_dependent/Items/ToggleNewStatus.t index 40d8e4a..3f2943c 100644 --- a/t/db_dependent/Items/ToggleNewStatus.t +++ b/t/db_dependent/Items/ToggleNewStatus.t @@ -67,7 +67,7 @@ my @rules = ( value => 'updated_value', }, ], - duration => '0', + age => '0', }, ); @@ -93,7 +93,7 @@ is( $marc_item->subfield($tagfield, $new_tagfield), 'updated_value', q|ToggleNew value => 'new_updated_value', }, ], - duration => '0', + age => '0', }, ); @@ -104,7 +104,7 @@ is( $modified_item->{new}, 'updated_value', q|ToggleNewStatus: The new value is $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 duration +# 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 ) ); @@ -126,30 +126,30 @@ $item = C4::Items::GetItem( $itemnumber ); value => 'new_updated_value', }, ], - duration => '10', + age => '10', }, ); C4::Items::ToggleNewStatus( { rules => \@rules } ); $modified_item = C4::Items::GetItem( $itemnumber ); -is( $modified_item->{new}, 'updated_value', q|ToggleNewStatus: Duration = 10 : The new value is not updated|); +is( $modified_item->{new}, 'updated_value', q|ToggleNewStatus: Age = 10 : The new value is not updated|); -$rules[0]->{duration} = 5; +$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: Duration = 5 : The new value is updated|); +is( $modified_item->{new}, 'new_updated_value5', q|ToggleNewStatus: Age = 5 : The new value is updated|); -$rules[0]->{duration} = ''; +$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: Duration = '' : The new value is updated|); +is( $modified_item->{new}, 'new_updated_value_empty_string', q|ToggleNewStatus: Age = '' : The new value is updated|); -$rules[0]->{duration} = undef; +$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: Duration = undef : The new value is updated|); +is( $modified_item->{new}, 'new_updated_value_undef', q|ToggleNewStatus: Age = undef : The new value is updated|); # Field deletion @rules = ( @@ -166,7 +166,7 @@ is( $modified_item->{new}, 'new_updated_value_undef', q|ToggleNewStatus: Duratio value => '', }, ], - duration => '0', + age => '0', }, ); @@ -196,7 +196,7 @@ is( $marc_item->subfield($tagfield, $new_tagfield), undef, q|ToggleNewStatus: Th value => 'new_value', }, ], - duration => '0', + age => '0', }, ); @@ -223,7 +223,7 @@ is( $modified_item->{new}, 'new_value', q|ToggleNewStatus: conditions multiple: value => 'new_updated_value', }, ], - duration => '0', + age => '0', }, ); @@ -250,7 +250,7 @@ is( $modified_item->{new}, 'new_value', q|ToggleNewStatus: conditions multiple: value => 'new_updated_value', }, ], - duration => '0', + age => '0', }, ); @@ -273,7 +273,7 @@ is( $modified_item->{new}, 'new_updated_value', q|ToggleNewStatus: conditions mu value => 'another_new_updated_value', }, ], - duration => '0', + age => '0', }, ); diff --git a/tools/toggle_new_status.pl b/tools/toggle_new_status.pl index a37ea1a..9d4c590 100755 --- a/tools/toggle_new_status.pl +++ b/tools/toggle_new_status.pl @@ -82,7 +82,7 @@ if ( $op eq 'update' ) { } push @{ $rule->{conditions} }, {} unless @{ $rule->{conditions} }; - $rule->{duration} = $cgi->param("duration_$unique_id"); + $rule->{age} = $cgi->param("age_$unique_id"); push @rules, $rule; } my $syspref_content = to_json( \@rules ); -- 2.1.0