From da9232087a6105ee9a15f8f658dcfcca6e5e7a53 Mon Sep 17 00:00:00 2001 From: Alex Sassmannshausen Date: Mon, 19 Feb 2018 16:03:42 +0100 Subject: [PATCH] Bug 11897: (QA Followup) Implement review feedback. - Update Table declarations - Add permissions checks - Remove unused code - Fix language & naming - Make templates translation friendly --- Koha/REST/V1/Stage.pm | 12 ++++ catalogue/stockrotation.pl | 5 +- .../data/mysql/atomicupdate/stockrot_tables.sql | 6 +- installer/data/mysql/kohastructure.sql | 70 +++++++++++----------- installer/data/mysql/sysprefs.sql | 6 +- .../intranet-tmpl/prog/en/includes/tools-menu.inc | 17 ------ .../en/modules/admin/preferences/circulation.pref | 2 +- .../prog/en/modules/catalogue/stockrotation.tt | 34 +++++++---- .../prog/en/modules/tools/stockrotation.tt | 10 ++-- tools/stockrotation.pl | 4 ++ 10 files changed, 91 insertions(+), 75 deletions(-) diff --git a/Koha/REST/V1/Stage.pm b/Koha/REST/V1/Stage.pm index fa4ca7ad2b..485384a41b 100644 --- a/Koha/REST/V1/Stage.pm +++ b/Koha/REST/V1/Stage.pm @@ -22,6 +22,18 @@ use Mojo::Base 'Mojolicious::Controller'; use Koha::StockRotationRotas; use Koha::StockRotationStages; +=head1 NAME + +Koha::REST::V1::Stage + +=head2 Operations + +=head3 move + +Move a stage up or down the stockrotation rota. + +=cut + sub move { my $c = shift->openapi->valid_input or return; my $input = $c->validation->output; diff --git a/catalogue/stockrotation.pl b/catalogue/stockrotation.pl index ff63b8a270..bf38d91625 100755 --- a/catalogue/stockrotation.pl +++ b/catalogue/stockrotation.pl @@ -57,7 +57,10 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user( query => $input, type => 'intranet', authnotrequired => 0, - flagsrequired => { catalogue => 1 } + flagsrequired => { + catalogue => 1, + stockrotation => 'can_user_stockrotation_can_edit_rotas', + }, } ); diff --git a/installer/data/mysql/atomicupdate/stockrot_tables.sql b/installer/data/mysql/atomicupdate/stockrot_tables.sql index 8469d20ca7..bde87f1b1a 100644 --- a/installer/data/mysql/atomicupdate/stockrot_tables.sql +++ b/installer/data/mysql/atomicupdate/stockrot_tables.sql @@ -7,7 +7,7 @@ CREATE TABLE IF NOT EXISTS stockrotationrotas ( cyclical tinyint(1) NOT NULL default 0, -- Should items on this rota keep cycling? active tinyint(1) NOT NULL default 0, -- Is this rota currently active? PRIMARY KEY (`rota_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- Stock Rotation Stages @@ -26,7 +26,7 @@ CREATE TABLE IF NOT EXISTS stockrotationstages ( FOREIGN KEY (`branchcode_id`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- Stock Rotation Items @@ -44,7 +44,7 @@ CREATE TABLE IF NOT EXISTS stockrotationitems ( FOREIGN KEY (`stage_id`) REFERENCES `stockrotationstages` (`stage_id`) ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- System preferences diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index eaf36f8036..e1e632f450 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -4120,40 +4120,6 @@ CREATE TABLE illrequests ( ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; --- --- Table structure for table `stockrotationrotas` --- - -CREATE TABLE IF NOT EXISTS stockrotationrotas ( - rota_id int(11) auto_increment, -- Stockrotation rota ID - title varchar(100) NOT NULL, -- Title for this rota - description text NOT NULL default '', -- Description for this rota - cyclical tinyint(1) NOT NULL default 0, -- Should items on this rota keep cycling? - active tinyint(1) NOT NULL default 0, -- Is this rota currently active? - PRIMARY KEY (`rota_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - --- --- Table structure for table `stockrotationstages` --- - -CREATE TABLE IF NOT EXISTS stockrotationstages ( - stage_id int(11) auto_increment, -- Unique stage ID - position int(11) NOT NULL, -- The position of this stage within its rota - rota_id int(11) NOT NULL, -- The rota this stage belongs to - branchcode_id varchar(10) NOT NULL, -- Branch this stage relates to - duration int(11) NOT NULL default 4, -- The number of days items shoud occupy this stage - PRIMARY KEY (`stage_id`), - CONSTRAINT `stockrotationstages_rifk` - FOREIGN KEY (`rota_id`) - REFERENCES `stockrotationrotas` (`rota_id`) - ON UPDATE CASCADE ON DELETE CASCADE, - CONSTRAINT `stockrotationstages_bifk` - FOREIGN KEY (`branchcode_id`) - REFERENCES `branches` (`branchcode`) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - -- -- Table structure for table `illrequestattributes` -- @@ -4192,6 +4158,40 @@ CREATE TABLE library_groups ( UNIQUE KEY title ( title ) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +-- +-- Table structure for table `stockrotationrotas` +-- + +CREATE TABLE IF NOT EXISTS stockrotationrotas ( + rota_id int(11) auto_increment, -- Stockrotation rota ID + title varchar(100) NOT NULL, -- Title for this rota + description text NOT NULL default '', -- Description for this rota + cyclical tinyint(1) NOT NULL default 0, -- Should items on this rota keep cycling? + active tinyint(1) NOT NULL default 0, -- Is this rota currently active? + PRIMARY KEY (`rota_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- +-- Table structure for table `stockrotationstages` +-- + +CREATE TABLE IF NOT EXISTS stockrotationstages ( + stage_id int(11) auto_increment, -- Unique stage ID + position int(11) NOT NULL, -- The position of this stage within its rota + rota_id int(11) NOT NULL, -- The rota this stage belongs to + branchcode_id varchar(10) NOT NULL, -- Branch this stage relates to + duration int(11) NOT NULL default 4, -- The number of days items shoud occupy this stage + PRIMARY KEY (`stage_id`), + CONSTRAINT `stockrotationstages_rifk` + FOREIGN KEY (`rota_id`) + REFERENCES `stockrotationrotas` (`rota_id`) + ON UPDATE CASCADE ON DELETE CASCADE, + CONSTRAINT `stockrotationstages_bifk` + FOREIGN KEY (`branchcode_id`) + REFERENCES `branches` (`branchcode`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + -- -- Table structure for table `stockrotationitems` -- @@ -4210,7 +4210,7 @@ CREATE TABLE IF NOT EXISTS stockrotationitems ( FOREIGN KEY (`stage_id`) REFERENCES `stockrotationstages` (`stage_id`) ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 3ed8e916e4..aa661f8f62 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -472,6 +472,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('ReturnToShelvingCart','0','','If set, when any item is \'checked in\', it\'s location code will be changed to CART.','YesNo'), ('reviewson','1','','If ON, enables patron reviews of bibliographic records in the OPAC','YesNo'), ('RisExportAdditionalFields', '', NULL , 'Define additional RIS tags to export from MARC records in YAML format as an associative array with either a marc tag/subfield combination as the value, or a list of tag/subfield combinations.', 'textarea'), +('RotationPreventTransfers','0',NULL,'If ON, prevent any transfers for items on stock rotation rotas, except for stock rotation transfers','YesNo'), ('RoutingListAddReserves','1','','If ON the patrons on routing lists are automatically added to holds on the issue.','YesNo'), ('RoutingListNote','To change this note edit RoutingListNote system preference.','70|10','Define a note to be shown on all routing lists','Textarea'), ('RoutingSerials','1',NULL,'If ON, serials routing is enabled','YesNo'), @@ -519,6 +520,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('StaffSerialIssueDisplayCount','3','','Number of serial issues to display per subscription in the Staff client','Integer'), ('StaticHoldsQueueWeight','0',NULL,'Specify a list of library location codes separated by commas -- the list of codes will be traversed and weighted with first values given higher weight for holds fulfillment -- alternatively, if RandomizeHoldsQueueWeight is set, the list will be randomly selective','Integer'), ('StatisticsFields','location|itype|ccode', NULL, 'Define Fields (from the items table) used for statistics members','Free'), +('StockRotation','0',NULL,'If ON, enables the stock rotation module','YesNo'), ('StoreLastBorrower','0','','If ON, the last borrower to return an item will be stored in items.last_returned_by','YesNo'), ('SubfieldsToAllowForRestrictedBatchmod','','Define a list of subfields for which edition is authorized when items_batchmod_restricted permission is enabled, separated by spaces. Example: 995\$f 995\$h 995\$j',NULL,'Free'), ('SubfieldsToAllowForRestrictedEditing','','Define a list of subfields for which edition is authorized when edit_items_restricted permission is enabled, separated by spaces. Example: 995\$f 995\$h 995\$j',NULL,'Free'), @@ -608,7 +610,5 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('XSLTListsDisplay','default','','Enable XSLT stylesheet control over lists pages display on intranet','Free'), ('XSLTResultsDisplay','default','','Enable XSL stylesheet control over results page display on intranet','Free'), ('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'), -('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo'), -('StockRotation','0',NULL,'If ON, enables the stock rotation module','YesNo'), -('RotationPreventTransfers','0',NULL,'If ON, prevent any transfers for items on stock rotation rotas, except for stock rotation transfers','YesNo') +('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo') ; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc index d4a6ad2b1c..5891dd3512 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc @@ -1,22 +1,5 @@ [% USE Koha %] -