From 2880589eeb768e328454affbd0c28e86c96873f1 Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Fri, 23 Dec 2016 01:11:12 +0000 Subject: [PATCH] Bug 17855 - Tidied up the blank spaces and unnecessary comments in the onboarding.pl script Test plan: 1. Go through the web installer and onboarding tool as outlined here: https://koha-community.org/manual/installation/html/ 2. After finishing the onboarding tool login using the patron credentials of the patron you just created using the onboarding tool 3. Check you can create a library, patron category, item type, patron category, and circulation rule using the patron account you are currently logged in with Bug 17855 - Same as the previous patch Test plan: 1. Go through the web installer and onboarding tool as outlined here: https://koha-community.org/manual/installation/html/ 2. Test the password and card number check and error display in the create patron screen of the onboarding tool by entering in different passwords in the two password fields and/or entering an existing password (which will only work if you installed sample patrons in the web installer). When you do this and submit the form errors should appear and you should be able to select the 'try again' button to get back to the first create patron screen. 3. After finishing the onboarding tool check the following tables of the database, they should all have records in them: branches, categories, borrowers, itemtypes and issuingrules Bug 17855 - Similar to previous patch All fields of the onboarding tool have been tested and they are all inserting correctly into the database Test plan: 1. Go through the web installer and onboarding tool as outlined here: https://koha-community.org/manual/installation/html/ 2. After finishing the onboarding tool write in the username and password of the patron you created using the onboarding tool, into the login page 3. Check your user has superlibrarian privilages by going to: 'Patron'-> click on the first letter of your logged in patron surname->'More'->'Set Permissions' You should see the patron has superlibrarian privilages. 4. Search in the database to make sure: *The library you created is in the borrowers table. *The patron category is in the categories table *The item type is in the itemtypes table *The circulation rule is in the issuingrules table Error messages working correctly and all objects being inserted correctly Start of onboarding.pl code tidied up --- installer/onboarding.pl | 77 ++++++++-------------- .../prog/en/modules/onboarding/onboardingstep1.tt | 2 +- .../prog/en/modules/onboarding/onboardingstep2.tt | 4 +- 3 files changed, 30 insertions(+), 53 deletions(-) diff --git a/installer/onboarding.pl b/installer/onboarding.pl index eab874b..ca085c0 100755 --- a/installer/onboarding.pl +++ b/installer/onboarding.pl @@ -10,8 +10,6 @@ use CGI qw ( -utf8 ); use List::MoreUtils qw/uniq/; use Digest::MD5 qw(md5_base64); use Encode qw( encode ); - -#Internal modules use C4::Koha; use C4::Auth; use C4::Context; @@ -46,7 +44,7 @@ my $input = new CGI; my $query = new CGI; my $step = $query->param('step'); -#Getting the appropriate template to display to the user--> +#Getting the appropriate template to display to the user my ( $template, $loggedinuser, $cookie) = C4::InstallAuth::get_template_and_user( { template_name => "/onboarding/onboardingstep" . ( $step ? $step : 0 ) . ".tt", @@ -87,8 +85,9 @@ if ( $op && $op eq 'finish' ) { #If the value of $op equals 'finish' then redire #Store the value of the template input name='start' in the variable $start so we can check if the user has pressed this button and started the onboarding tool process my $start = $query->param('start'); -$template->param('start'=>$start); #Hand the start variable back to the template -if ( $start && $start eq 'Start setting up my Koha' ){ +$template->param('start'=>$start); + +if ( $start && $start eq 'Start setting up my Koha' ){ my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); $template->param(libraries => $libraries, group_types => [ @@ -101,20 +100,6 @@ if ( $start && $start eq 'Start setting up my Koha' ){ ] ); -}elsif ( $start && $start eq 'Add a patron category' ){ - -#Select all the patron category records in the categories database table and store them in the newly declared variable $categories - my $categories = Koha::Patron::Categories->search(); - $template->param( - categories => $categories, - ); #Hand the variable categories back to the template - -}elsif ( $start && $start eq 'Add an item type' ){ - my $itemtypes = Koha::ItemTypes->search(); - $template->param( - itemtypes => $itemtypes, - );#Hand the variable itemtypes back to the template - #Check if the $step variable equals 1 i.e. the user has clicked to create a library in the create library screen 1 }elsif ( $step && $step == 1 ) { my $createlibrary = $query->param('createlibrary'); #Store the inputted library branch code and name in $createlibrary variable @@ -157,6 +142,12 @@ if ( $start && $start eq 'Start setting up my Koha' ){ my $createcat = $query->param('createcat'); #Store the inputted category code and name in $createcat $template->param('createcat'=>$createcat); +#Select all the patron category records in the categories database table and give them to the template + my $categories = Koha::Patron::Categories->search(); + $template->param( + categories => $categories, + ); + #Initialising values my $searchfield = $input->param('description') // q||; my $categorycode = $input->param('categorycode'); @@ -195,7 +186,7 @@ if ( $start && $start eq 'Start setting up my Koha' ){ dateonly => 1, } ); - } + } #Adds a new patron category to the database $category = Koha::Patron::Category->new({ @@ -275,20 +266,18 @@ if ( $start && $start eq 'Start setting up my Koha' ){ :() } -# unless(Check_Userid($userid, $borrowernumber)){ -# push @errors, "ERROR_login_exist"; -# } push @errors, "ERROR_password_mismatch" if $firstpassword ne $secondpassword; push @errors, "ERROR_short_password" if ($firstpassword && $minpw && $firstpassword ne '****' && (length($firstpassword) < $minpw)); -# + + #Passing errors to template - $nok = $nok || scalar(@errors); + $nok = $nok || scalar(@errors); - if($nok){ + if($nok){ - foreach my $error (@errors){ - if ($error eq 'ERROR_password_mismatch'){ - $template->param(errorpasswordmismatch => 1); + foreach my $error (@errors){ + if ($error eq 'ERROR_password_mismatch'){ + $template->param(errorpasswordmismatch => 1); } if ($error eq 'ERROR_login_exist'){ $template->param(errorloginexists =>1); @@ -368,16 +357,16 @@ if ( $start && $start eq 'Start setting up my Koha' ){ $sth = $dbh->prepare("UPDATE borrowers SET flags=? WHERE borrowernumber=?"); $sth->execute($module_flags, $borrowernumber); - #Error handling checking if the patron was created successfully - if(!$borrowernumber){ - push @messages, {type=> 'error', code => 'error_on_insert'}; - }else{ - push @messages, {type=> 'message', code => 'success_on_insert'}; - } - } + #Error handling checking if the patron was created successfully + if(!$borrowernumber){ + push @messages, {type=> 'error', code => 'error_on_insert'}; + }else{ + push @messages, {type=> 'message', code => 'success_on_insert'}; + } + } } } -}elsif ( $step && $step == 4){ + }elsif ( $step && $step == 4){ my $createitemtype = $input->param('createitemtype'); $template->param('createitemtype'=> $createitemtype ); @@ -554,8 +543,7 @@ if ( $start && $start eq 'Start setting up my Koha' ){ } else { $sth_insert->execute($branch, $onshelfholds); } - } -#End new code + } my $issuingrule = Koha::IssuingRules->find({categorycode => $bor, itemtype => $itemtype, branchcode => $br }); if($issuingrule){ @@ -566,17 +554,6 @@ if ( $start && $start eq 'Start setting up my Koha' ){ Koha::IssuingRule->new()->set($params)->store(); } } - - my @messages; - - my $issuingrule = Koha::IssuingRules->find({categorycode => $bor, itemtype => $itemtype, branchcode => $br }); - if($issuingrule){ - $issuingrule->set($params)->store(); - push @messages, {type=> 'error', code => 'error_on_insert'};#Stops crash of the onboarding tool if someone makes a circulation rule with the same item type, library and patron categroy as an exisiting circulation rule. - }else{ - Koha::IssuingRule->new()->set($params)->store(); - } - } } output_html_with_http_headers $input, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt index e9616e3..3e51368 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt @@ -36,7 +36,7 @@
-

Welcome to Koha

+

Welcome to Koha test if in correct repo

Koha

[% IF libraries.count > 0 %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep2.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep2.tt index 7221a97..7dc5d93 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep2.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep2.tt @@ -284,7 +284,7 @@ $(document).ready(function(){ [% ELSE %] -

Create a new Patron Category

+

Create a new Patron Category testing rwq

@@ -292,7 +292,7 @@ $(document).ready(function(){
  1. - + Required
  2. -- 2.1.4