Bug 24476: Rename autorenewal to autorenew_checkouts
authorNick Clemens <nick@bywatersolutions.com>
Fri, 28 Feb 2020 17:30:07 +0000 (17:30 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 24 Mar 2020 11:23:54 +0000 (11:23 +0000)
Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

14 files changed:
C4/Circulation.pm
Koha/Patron.pm
api/v1/swagger/definitions/patron.json
api/v1/swagger/paths/patrons.json
installer/data/mysql/atomicupdate/bug_24476_opt_out_of_auto_renewal.perl
installer/data/mysql/kohastructure.sql
koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-brief.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt
misc/cronjobs/automatic_renewals.pl
t/db_dependent/Circulation.t

index 30311b0..c6f3cf9 100644 (file)
@@ -2751,7 +2751,7 @@ sub CanBookBeRenewed {
             return ( 0, 'overdue');
         }
 
-        if ( $issue->auto_renew && $patron->autorenewal ) {
+        if ( $issue->auto_renew && $patron->autorenew_checkouts ) {
 
             if ( $patron->category->effective_BlockExpiredPatronOpacActions and $patron->is_expired ) {
                 return ( 0, 'auto_account_expired' );
@@ -2807,10 +2807,10 @@ sub CanBookBeRenewed {
 
             if ( $soonestrenewal > DateTime->now( time_zone => C4::Context->tz() ) )
             {
-                return ( 0, "auto_too_soon" ) if $issue->auto_renew && $patron->autorenewal;
+                return ( 0, "auto_too_soon" ) if $issue->auto_renew && $patron->autorenew_checkouts;
                 return ( 0, "too_soon" );
             }
-            elsif ( $issue->auto_renew && $patron->autorenewal ) {
+            elsif ( $issue->auto_renew && $patron->autorenew_checkouts ) {
                 $auto_renew = 1;
             }
         }
index 331d7b9..b879286 100644 (file)
@@ -1671,7 +1671,7 @@ sub to_api_mapping {
         smsalertnumber      => 'sms_number',
         sort1               => 'statistics_1',
         sort2               => 'statistics_2',
-        autorenewal         => 'autorenewal',
+        autorenew_checkouts => 'autorenew_checkouts',
         streetnumber        => 'street_number',
         streettype          => 'street_type',
         zipcode             => 'postal_code',
index cf5eedf..a4f998c 100644 (file)
       "type": ["string", "null"],
       "description": "a field that can be used for any information unique to the library"
     },
-    "autorenewal": {
+    "autorenew_checkouts": {
       "type": "boolean",
       "description": "indicate whether auto-renewal is allowed for patron"
     },
index bb4efd3..c8798f2 100644 (file)
         "required": false,
         "type": "string"
       }, {
-        "name": "autorenewal",
+        "name": "autorenew_checkouts",
         "in": "query",
-        "description": "Search on autorenewal",
+        "description": "Search on autorenew_checkouts",
         "required": false,
         "type": "boolean"
       }, {
index 9bc691b..50edba9 100644 (file)
@@ -1,20 +1,20 @@
 $DBversion = 'XXX';
 if( CheckVersion( $DBversion ) ) {
-    unless( column_exists('borrowers','autorenewal') ){
-        $dbh->do( "ALTER TABLE borrowers ADD COLUMN autorenewal TINYINT(1) NOT NULL DEFAULT 1" );
+    unless( column_exists('borrowers','autorenew_checkouts') ){
+        $dbh->do( "ALTER TABLE borrowers ADD COLUMN autorenew_checkouts TINYINT(1) NOT NULL DEFAULT 1" );
     }
-    unless( column_exists('deletedborrowers','autorenewal') ){
-        $dbh->do( "ALTER TABLE deletedborrowers ADD COLUMN autorenewal TINYINT(1) NOT NULL DEFAULT 1" );
+    unless( column_exists('deletedborrowers','autorenew_checkouts') ){
+        $dbh->do( "ALTER TABLE deletedborrowers ADD COLUMN autorenew_checkouts TINYINT(1) NOT NULL DEFAULT 1" );
     }
-    unless( column_exists('borrower_modifications','autorenewal') ){
-        $dbh->do( "ALTER TABLE borrower_modifications ADD COLUMN autorenewal TINYINT(1) NOT NULL DEFAULT 1" );
+    unless( column_exists('borrower_modifications','autorenew_checkouts') ){
+        $dbh->do( "ALTER TABLE borrower_modifications ADD COLUMN autorenew_checkouts TINYINT(1) NOT NULL DEFAULT 1" );
     }
     $dbh->do(q{
         UPDATE systempreferences
-        SET value  = CONCAT(value,'|autorenewal')
+        SET value  = CONCAT(value,'|autorenew_checkouts')
         WHERE variable IN
         ('PatronSelfModificationBorrowerUnwantedField','PatronSelfRegistrationBorrowerUnwantedField')
-        AND value NOT LIKE '%autorenewal%'
+        AND value NOT LIKE '%autorenew_checkouts%'
     });
     SetVersion( $DBversion );
     print "Upgrade to $DBversion done (Bug 24476 - Allow patrons to opt-out of autorenewal)\n";
index 9c361dd..e80c64c 100644 (file)
@@ -589,7 +589,7 @@ CREATE TABLE `deletedborrowers` ( -- stores data related to the patrons/borrower
   `login_attempts` int(4) default 0, -- number of failed login attemps
   `overdrive_auth_token` MEDIUMTEXT default NULL, -- persist OverDrive auth token
   `anonymized` TINYINT(1) NOT NULL DEFAULT 0, -- flag for data anonymization
-  `autorenewal` TINYINT(1) NOT NULL DEFAULT 1, -- flag for allowing auto-renewal
+  `autorenew_checkouts` TINYINT(1) NOT NULL DEFAULT 1, -- flag for allowing auto-renewal
   KEY borrowernumber (borrowernumber),
   KEY `cardnumber` (`cardnumber`),
   KEY `sms_provider_id` (`sms_provider_id`)
@@ -1533,7 +1533,7 @@ CREATE TABLE `borrowers` ( -- this table includes information about your patrons
   `login_attempts` int(4) default 0, -- number of failed login attemps
   `overdrive_auth_token` MEDIUMTEXT default NULL, -- persist OverDrive auth token
   `anonymized` TINYINT(1) NOT NULL DEFAULT 0, -- flag for data anonymization
-  `autorenewal` TINYINT(1) NOT NULL DEFAULT 1, -- flag for allowing auto-renewal
+  `autorenew_checkouts` TINYINT(1) NOT NULL DEFAULT 1, -- flag for allowing auto-renewal
   UNIQUE KEY `cardnumber` (`cardnumber`),
   PRIMARY KEY `borrowernumber` (`borrowernumber`),
   KEY `categorycode` (`categorycode`),
@@ -3441,7 +3441,7 @@ CREATE TABLE IF NOT EXISTS `borrower_modifications` (
   `privacy` int(11) DEFAULT NULL,
   `extended_attributes` MEDIUMTEXT DEFAULT NULL,
   `gdpr_proc_consent` datetime, -- data processing consent
-  `autorenewal` TINYINT(1) NOT NULL DEFAULT 1, -- flag for allowing auto-renewal
+  `autorenew_checkouts` TINYINT(1) NOT NULL DEFAULT 1, -- flag for allowing auto-renewal
   PRIMARY KEY (`verification_token` (191),`borrowernumber`),
   KEY `verification_token` (`verification_token` (191)),
   KEY `borrowernumber` (`borrowernumber`)
index feb3c3a..167a203 100644 (file)
                                                         <div id="set-automatic-renewal" class="circ-setting">
                                                             [% IF NEEDSCONFIRMATION %]
                                                                 [% IF auto_renew %]
-                                                                    [% IF patron.autorenewal %]
+                                                                    [% IF patron.autorenew_checkouts %]
                                                                         <input type="checkbox" name="auto_renew" id="auto_renew" value="auto_renew" disabled="disabled"
                                                                         title="Patron has opted out of auto-renewal"/>
                                                                     [% ELSE %]
                                                                     <input type="checkbox" name="auto_renew" id="auto_renew" value="auto_renew" disabled="disabled" />
                                                                 [% END %]
                                                             [% ELSE %]
-                                                                [% IF ( auto_renew && patron.autorenewal ) %]
+                                                                [% IF ( auto_renew && patron.autorenew_checkouts ) %]
                                                                     <input type="checkbox" name="auto_renew" id="auto_renew" value="auto_renew" class="circ_setting" checked="checked" />
-                                                                [% ELSIF patron.autorenewal %]
+                                                                [% ELSIF patron.autorenew_checkouts %]
                                                                     <input type="checkbox" name="auto_renew" id="auto_renew" value="auto_renew" class="circ_setting" />
                                                                 [% ELSE %]
                                                                     <input type="checkbox" name="auto_renew" id="auto_renew" value="auto_renew" disabled="disabled"
index 20ddc76..967c41f 100644 (file)
@@ -874,28 +874,28 @@ legend:hover {
                                             </li>
                                         [% END # /UNLESS nosort2 %]
 
-                                        [% UNLESS noautorenewal %]
+                                        [% UNLESS noautorenew_checkouts %]
                                             <li class="radio">
-                                                <label for="yes-autorenewal">
+                                                <label for="yes-autorenew_checkouts">
                                                     Allow auto-renewal of items:
                                                 </label>
-                                                    [% IF ( autorenewal ) %]
-                                                        <label for="yes-autorenewal">
+                                                    [% IF ( autorenew_checkouts ) %]
+                                                        <label for="yes-autorenew_checkouts">
                                                             Yes
-                                                            <input type="radio" id="yes-autorenewal" name="autorenewal" value="1" checked="checked" />
+                                                            <input type="radio" id="yes-autorenew_checkouts" name="autorenew_checkouts" value="1" checked="checked" />
                                                         </label>
-                                                        <label for="no-autorenewal">
+                                                        <label for="no-autorenew_checkouts">
                                                             No
-                                                            <input type="radio" id="no-autorenewal" name="autorenewal" value="0" />
+                                                            <input type="radio" id="no-autorenew_checkouts" name="autorenew_checkouts" value="0" />
                                                         </label>
                                                     [% ELSE %]
-                                                        <label for="yes-autorenewal">
+                                                        <label for="yes-autorenew_checkouts">
                                                             Yes
-                                                            <input type="radio" id="yes-autorenewal" name="autorenewal" value="1" />
+                                                            <input type="radio" id="yes-autorenew_checkouts" name="autorenew_checkouts" value="1" />
                                                         </label>
-                                                        <label for="no-autorenewal">
+                                                        <label for="no-autorenew_checkouts">
                                                             No
-                                                            <input type="radio" id="no-autorenewal" name="autorenewal" value="0" checked="checked" />
+                                                            <input type="radio" id="no-autorenew_checkouts" name="autorenew_checkouts" value="0" checked="checked" />
                                                         </label>
                                                     [% END %]
                                             </li>
index c16e432..e250b9e 100644 (file)
@@ -52,7 +52,7 @@
 [% CASE 'contacttitle'        %]<span>Contact: Title</span>
 [% CASE 'relationship'        %]<span>Contact: Relationship</span>
 [% CASE 'sex'                 %]<span>Gender</span>
-[% CASE 'autorenewal'         %]<span>Auto-renewal</span>
+[% CASE 'autorenew_checkouts' %]<span>Auto-renewal</span>
 [% CASE 'altcontactfirstname' %]<span>Alternate contact: First name</span>
 [% CASE 'altcontactsurname'   %]<span>Alternate contact: Surname</span>
 [% CASE 'altcontactaddress1'  %]<span>Alternate contact: Address</span>
index ecac3b7..2eded98 100644 (file)
@@ -84,7 +84,7 @@
             <li><span class="label">Library: </span>[% patron.library.branchname | html %]</li>
             [% IF ( patron.sort1 ) %]<li><span class="label">Sort field 1:</span>[% AuthorisedValues.GetByCode('Bsort1', patron.sort1) | html %]</li>[% END %]
             [% IF ( patron.sort2 ) %]<li><span class="label">Sort field 2:</span>[% AuthorisedValues.GetByCode('Bsort2', patron.sort2) | html %]</li>[% END %]
-            [% UNLESS ( patron.autorenewal ) %]<li>Auto renewal: Patron has opted out</li>[% END %]
+            [% UNLESS ( patron.autorenew_checkouts ) %]<li>Auto renewal: Patron has opted out</li>[% END %]
         </ol>
     </div>
     </div>
index 488515b..15ea33c 100644 (file)
                                                 [% AuthorisedValues.GetByCode('Bsort2', patron.sort2) | html %]
                                             </li>
                                         [% END %]
-                                        [% UNLESS ( patron.autorenewal ) %]
-                                            <li id="patron-autorenewal">
+                                        [% UNLESS ( patron.autorenew_checkouts ) %]
+                                            <li id="patron-autorenew_checkouts">
                                                 <span class="label">Auto renewal:</span>
                                                 Patron has opted out
                                             </li>
index a2bcde4..b5c5e34 100644 (file)
                                         [% END %]
                                     </li>
                                 [% END %]
-                                [% UNLESS hidden.defined('autorenewal') %]
+                                [% UNLESS hidden.defined('autorenew_checkouts') %]
                                     <li class="lradio">
-                                        <label for="yes-autorenewal">
+                                        <label for="yes-autorenew_checkouts">
                                             Allow auto-renewal:
                                         </label>
-                                            [% IF ( borrower.autorenewal ) %]
-                                                <label class="radio inline" for="yes-autorenewal">
+                                            [% IF ( borrower.autorenew_checkouts ) %]
+                                                <label class="radio inline" for="yes-autorenew_checkouts">
                                                     Yes
-                                                    <input type="radio" id="yes-autorenewal" name="borrower_autorenewal" value="1" checked="checked" />
+                                                    <input type="radio" id="yes-autorenew_checkouts" name="borrower_autorenew_checkouts" value="1" checked="checked" />
                                                 </label>
 
-                                                <label class="radio inline" for="no-autorenewal">
+                                                <label class="radio inline" for="no-autorenew_checkouts">
                                                     No
-                                                    <input type="radio" id="no-autorenewal" name="borrower_autorenewal" value="0" />
+                                                    <input type="radio" id="no-autorenew_checkouts" name="borrower_autorenew_checkouts" value="0" />
                                                 </label>
                                             [% ELSE %]
-                                                <label class="radio inline" for="yes-autorenewal">
+                                                <label class="radio inline" for="yes-autorenew_checkouts">
                                                     Yes
-                                                    <input type="radio" id="yes-autorenewal" name="borrower_autorenewal" value="1" />
+                                                    <input type="radio" id="yes-autorenew_checkouts" name="borrower_autorenew_checkouts" value="1" />
                                                 </label>
-                                                <label class="radio inline" for="no-autorenewal">
+                                                <label class="radio inline" for="no-autorenew_checkouts">
                                                     No
-                                                    <input type="radio" id="no-autorenewal" name="borrower_autorenewal" value="0" checked="checked" />
+                                                    <input type="radio" id="no-autorenew_checkouts" name="borrower_autorenew_checkouts" value="0" checked="checked" />
                                                 </label>
                                             [% END %]
                                     </li>
index a3bded3..a76f7df 100755 (executable)
@@ -80,7 +80,7 @@ GetOptions(
 pod2usage(0) if $help;
 cronlogaction();
 
-my $auto_renews = Koha::Checkouts->search({ auto_renew => 1, 'borrower.autorenewal' => 1 },{ join => 'borrower'});
+my $auto_renews = Koha::Checkouts->search({ auto_renew => 1, 'borrower.autorenew_checkouts' => 1 },{ join => 'borrower'});
 
 my %report;
 $verbose = 1 unless $verbose or $confirm;
index 72dd1d2..6d7e4b4 100755 (executable)
@@ -657,10 +657,10 @@ subtest "CanBookBeRenewed tests" => sub {
 
 
 
-    $renewing_borrower_obj->autorenewal(0)->store;
+    $renewing_borrower_obj->autorenew_checkouts(0)->store;
     ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber );
     is( $renewokay, 1, 'No renewal before is undef, but patron opted out of auto_renewal' );
-    $renewing_borrower_obj->autorenewal(1)->store;
+    $renewing_borrower_obj->autorenew_checkouts(1)->store;
 
 
     # Bug 7413
@@ -706,11 +706,11 @@ subtest "CanBookBeRenewed tests" => sub {
         'Bug 14101: Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)'
     );
 
-    $renewing_borrower_obj->autorenewal(0)->store;
+    $renewing_borrower_obj->autorenew_checkouts(0)->store;
     ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber );
     is( $renewokay, 0, 'No renewal before is 7, patron opted out of auto_renewal still cannot renew early' );
     is( $error, 'too_soon', 'Error is too_soon, no auto' );
-    $renewing_borrower_obj->autorenewal(1)->store;
+    $renewing_borrower_obj->autorenew_checkouts(1)->store;
 
     # Change policy so that loans can only be renewed exactly on due date (0 days prior to due date)
     # and test automatic renewal again
@@ -722,11 +722,11 @@ subtest "CanBookBeRenewed tests" => sub {
         'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = 0 (returned code is auto_too_soon)'
     );
 
-    $renewing_borrower_obj->autorenewal(0)->store;
+    $renewing_borrower_obj->autorenew_checkouts(0)->store;
     ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber );
     is( $renewokay, 0, 'No renewal before is 0, patron opted out of auto_renewal still cannot renew early' );
     is( $error, 'too_soon', 'Error is too_soon, no auto' );
-    $renewing_borrower_obj->autorenewal(1)->store;
+    $renewing_borrower_obj->autorenew_checkouts(1)->store;
 
     # Change policy so that loans can be renewed 99 days prior to the due date
     # and test automatic renewal again
@@ -738,10 +738,10 @@ subtest "CanBookBeRenewed tests" => sub {
         'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)'
     );
 
-    $renewing_borrower_obj->autorenewal(0)->store;
+    $renewing_borrower_obj->autorenew_checkouts(0)->store;
     ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber );
     is( $renewokay, 1, 'No renewal before is 99, patron opted out of auto_renewal so can renew' );
-    $renewing_borrower_obj->autorenewal(1)->store;
+    $renewing_borrower_obj->autorenew_checkouts(1)->store;
 
     subtest "too_late_renewal / no_auto_renewal_after" => sub {
         plan tests => 14;