From dfabe9282c9a0067504acd5bbfc6685ec4eeeb2e Mon Sep 17 00:00:00 2001 From: Alex Sassmannshausen Date: Mon, 19 Feb 2018 16:03:42 +0100 Subject: [PATCH] Bug 11897: (QA follow-up) 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 | 72 +++++++++++----------- installer/data/mysql/sysprefs.sql | 7 ++- .../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, 93 insertions(+), 76 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 4760f2e407..21d9e19f8e 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -4143,40 +4143,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` -- @@ -4206,7 +4172,7 @@ CREATE TABLE library_groups ( description MEDIUMTEXT NULL DEFAULT NULL, -- Longer explanation of the group, if necessary ft_hide_patron_info tinyint(1) NOT NULL DEFAULT 0, -- Turn on the feature "Hide patron's info" for this group ft_search_groups_opac tinyint(1) NOT NULL DEFAULT 0, -- Use this group for staff side search groups - ft_search_groups_staff tinyint(1) NOT NULL DEFAULT 0, -- Use this group for opac side search groups + ft_search_groups_staff tinyint(1) NOT NULL DEFAULT 0, -- Use this group for opac side search groups created_on TIMESTAMP NULL, -- Date and time of creation updated_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- Date and time of last PRIMARY KEY id ( id ), @@ -4227,6 +4193,40 @@ CREATE TABLE `oauth_access_tokens` ( PRIMARY KEY (`access_token`) ) 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` -- @@ -4245,7 +4245,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 9de17ae667..cd3811e020 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -479,6 +479,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('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'), ('RoutingListAddReserves','0','','If ON the patrons on routing lists are automatically added to holds on the issue.','YesNo'), +('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'), ('SCOMainUserBlock','','70|10','Add a block of HTML that will display on the self checkout screen','Textarea'), @@ -525,6 +527,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'), @@ -616,7 +619,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 ee0034f6cb..5660878970 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 %] -