From 35116ff825550eff7a9f72bfce45d69fcf19b78e Mon Sep 17 00:00:00 2001 From: "@alexbuckley" Date: Wed, 28 Dec 2016 00:08:51 +0000 Subject: [PATCH] Bug 17855 - Finished updated web installer and onboarding tool. Test plan: 1. Go through the web installer as outlined in the below link. But go through the web installer 4 times to test the basic and advanced setup modes of the web installer: https://koha-community.org/manual/installation/html/ Note: Each time you have finished the web installer restart memcached service with: sudo service memcached restart and drop and recreate the database. 2. Attempt 1 : Choose basic and MARC21. Notice the bulletpoints for default sample data on web installer step 3, and unticked checkboxes for optional data values. Attempt 2: Choose basic and UNIMARC, make the same observation as above. Attempt 3: Choose advanced and MACR21 notice all data values have unticked checkboxes (including the default data values) Attempt 4: Choose advanced and UNIMARC and make same observation as above. 3. After your fourth attempt do not restart memcached or drop and recreate the database. You will be redirected to the onboarding tool automatically after finishing the web installer. 4. Go through the onboarding tool as outlined here: https://koha-community.org/manual/installation/html/ 5. Whilst going through the onboarding tool write in special characters to all text input fields of the onboarding tool and try to submit the form. You should not be able to, due to html regexes being implemented. 6. In the create patron category form try to input a value into both the 'Months:' and 'Until date:' input fields. A message should appear beside the input boxes telling the you to only write in one date value 7. Select a date from the datepicker of the create patron category form 8. Continue through the rest of the onboarding tool as outlined in that above link 9. Once you have finished the onboarding tool and have logged in with the patron account you created in the onboarding tool, try to create a library, patron category, patron, item type and circulation rule. If you can create these then you know that the onboarding tool has successfully set up Koha for you. Therefore the onboarding tool is working as intended. Bug 17855 - In the onboarding tool the following has been implemented: * Pre-filled card number input field to prevent the user having to write in a number which could already exist thereby causing a duplicate cardnumber entry error. * Working html regexes on all inputs in the create patron category form as well as all other input fields in the onboarding tool. * Working datepicker in the create patron category form. It is working because when the user clicks on the calendar icon by the 'Until date:' input box a calendar appears and the user may select a date which is displayed in the said input box. * Working detection of invalid dates in the create patron category form * Fixed the bug in categories.pl which allowed users to write in an invalid date to the date input box and submit the form So now if the user writes in an invalid date a message box appears telling them what they entered was invalid Test plan: 1. Go through the web installer and onboarding tool (further instructions for onboaridng tool below) as outlined here: https://koha-community.org/manual/installation/html/ 2. Test every text input fields html regex in the onboarding tool by writing in special characters and then trying to submit the form. None of the forms should submit with special characters in any of the text input fields 3. Use the datepicker in the first create patron category screen, to choose a date from the calendar. 4. Try writing in an invalid date (e.g. 40/20/2018) to the 'Until Date:' field of the create patron category form. A messagebox should appear immediately and tell you the date you entered is invalid 5. Try writing a date in the 'Until date:' input and a number of months in the 'Months:' input. Because only one of these two fields should contain a value a message should appear alongside these fields to tell you to only input one date value. 6. Continue the onboarding tool as specified in the above link 7. Login using the newly created patron account 8. Go to More->Administration->Patron categories->New category try writing an invalid date into the 'Until date:' input. As with the onboarding tool a messagebox should appear asutomatically to tell you that the date you entered was invalid Bug 17855 - Implemented in the onboarding tool working html validation on all fields except the text inputs fields in the create patron category screen Test plan: 1. Go through the web installer as outlined here: https://koha-community.org/manual/installation/html/ 2. Try writing in special characters to all text input fields in the onboarding tool (except the create patron form text input fields which do not yet have working html regexes) You should not be able to submit the form with special characters in the text input fields Working html data validation of all onboarding tool steps Testing of the onboarding version Testing of version (second test) Working data validation of the patron categories Testing of version (second test) Testing the patron category Working insertion of all fields, and all except patron categories have successful data validation Tidied code with additional comments added and test text removed Valid cardnumber pre-written into patron form Prevents duplicate cardnumber entry Working regex on patron catgeory form Working patron category datepicker Does not allow user to use datepicker Working datepicker and month input check Form now only allows only one dateperiod input Working detection of invalid dates Fixed categories.pl invalid date check All neccisary functionality in onboarding tool User can still choose any patron category in patron form --- installer/install.pl | 17 + installer/onboarding.pl | 189 +++++---- .../prog/en/modules/admin/categories.tt | 2 +- .../prog/en/modules/onboarding/onboardingstep0.tt | 33 +- .../prog/en/modules/onboarding/onboardingstep1.tt | 44 +- .../prog/en/modules/onboarding/onboardingstep2.tt | 454 +++++++++++---------- .../prog/en/modules/onboarding/onboardingstep3.tt | 20 +- .../prog/en/modules/onboarding/onboardingstep4.tt | 4 +- .../prog/en/modules/onboarding/onboardingstep5.tt | 16 +- 9 files changed, 399 insertions(+), 380 deletions(-) diff --git a/installer/install.pl b/installer/install.pl index 17d01e9..a71a5c0 100755 --- a/installer/install.pl +++ b/installer/install.pl @@ -1,5 +1,22 @@ #!/usr/bin/perl +# This file is part of Koha. +# # +# # Copyright (C) YEAR YOURNAME-OR-YOUREMPLOYER +# # +# # Koha is free software; you can redistribute it and/or modify it +# # under the terms of the GNU General Public License as published by +# # the Free Software Foundation; either version 3 of the License, or +# # (at your option) any later version. +# # +# # Koha is distributed in the hope that it will be useful, but +# # WITHOUT ANY WARRANTY; without even the implied warranty of +# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# # GNU General Public License for more details. +# # +# # You should have received a copy of the GNU General Public License +# # along with Koha; if not, see . + use strict; use warnings; use diagnostics; diff --git a/installer/onboarding.pl b/installer/onboarding.pl index ca085c0..5430e03 100755 --- a/installer/onboarding.pl +++ b/installer/onboarding.pl @@ -1,5 +1,23 @@ #!/usr/bin/perl #Recommended pragmas + +# This file is part of Koha. +# # +# # Copyright (C) YEAR YOURNAME-OR-YOUREMPLOYER +# # +# # Koha is free software; you can redistribute it and/or modify it +# # under the terms of the GNU General Public License as published by +# # the Free Software Foundation; either version 3 of the License, or +# # (at your option) any later version. +# # +# # Koha is distributed in the hope that it will be useful, but +# # WITHOUT ANY WARRANTY; without even the implied warranty of +# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# # GNU General Public License for more details. +# # +# # You should have received a copy of the GNU General Public License +# # along with Koha; if not, see . + use strict; use warnings; use diagnostics; @@ -100,6 +118,15 @@ 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 give them to the template + my $categories = Koha::Patron::Categories->search(); + $template->param( + categories => $categories, + ); + + #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 @@ -107,6 +134,7 @@ if ( $start && $start eq 'Start setting up my Koha' ){ #store inputted parameters in variables my $branchcode = $input->param('branchcode'); + $branchcode = uc($branchcode); my $categorycode = $input->param('categorycode'); my $op = $input->param('op') || 'list'; my $message; @@ -134,97 +162,85 @@ if ( $start && $start eq 'Start setting up my Koha' ){ $message = 'error_on_insert'; } - $template->param('message' => $message); + $template->param('message' => $message); #Check if the $step variable equals 2 i.e. the user has clicked to create a patron category in the create patron category screen 1 }elsif ( $step && $step == 2 ){ - 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'); - my $op = $input->param('op') // 'list'; - my $message; - my $category; - $template->param('categorycode' =>$categorycode); - - my ( $template, $loggedinuser, $cookie ) = C4::InstallAuth::get_template_and_user( - { + my $createcat = $query->param('createcat'); #Store the inputted category code and name in $createcat + $template->param('createcat'=>$createcat); + + #Initialising values + my $searchfield = $input->param('description') // q||; + my $categorycode = $input->param('categorycode'); + my $op = $input->param('op') // 'list'; + my $message; + my $category; + $template->param('categorycode' =>$categorycode); + + my ( $template, $loggedinuser, $cookie ) = C4::InstallAuth::get_template_and_user( + { template_name => "/onboarding/onboardingstep2.tt", query => $input, type => "intranet", authnotrequired => 0, flagsrequired => { parameters => 'parameters_remaining_permissions' }, debug => 1, - } + } ); - #Once the user submits the page, this code validates the input and adds it - #to the database as a new patron category - $categorycode = $input->param('categorycode'); - my $description = $input->param('description'); - my $overduenoticerequired = $input->param('overduenoticerequired'); - my $category_type = $input->param('category_type'); - my $default_privacy = $input->param('default_privacy'); - my $enrolmentperiod = $input->param('enrolmentperiod'); - my $enrolmentperioddate = $input->param('enrolmentperioddate') || undef; - - #Converts the string into a date format - if ( $enrolmentperioddate) { - $enrolmentperioddate = output_pref( +#Once the user submits the page, this code validates the input and adds it +#to the database as a new patron category + + $categorycode = $input->param('categorycode'); + $categorycode = uc($categorycode); + my $description = $input->param('description'); + my $overduenoticerequired = $input->param('overduenoticerequired'); + my $category_type = $input->param('category_type'); + my $default_privacy = $input->param('default_privacy'); + my $enrolmentperiod = $input->param('enrolmentperiod'); + my $enrolmentperioddate = $input->param('enrolmentperioddate') || undef; + +#Converts the string into a date format + if ( $enrolmentperioddate) { + $enrolmentperioddate = output_pref( { - dt => dt_from_string($enrolmentperioddate), - dateformat => 'iso', - dateonly => 1, + dt => dt_from_string($enrolmentperioddate), + dateformat => 'iso', + dateonly => 1, } ); - } - - #Adds a new patron category to the database - $category = Koha::Patron::Category->new({ - categorycode=> $categorycode, - description => $description, - overduenoticerequired => $overduenoticerequired, - category_type=> $category_type, - default_privacy => $default_privacy, - enrolmentperiod => $enrolmentperiod, - enrolmentperioddate => $enrolmentperioddate, - }); + } - eval { - $category->store; - }; +#Adds a new patron category to the database + $category = Koha::Patron::Category->new({ + categorycode=> $categorycode, + description => $description, + overduenoticerequired => $overduenoticerequired, + category_type=> $category_type, + default_privacy => $default_privacy, + enrolmentperiod => $enrolmentperiod, + enrolmentperioddate => $enrolmentperioddate, + }); + + eval { + $category->store; + }; - #Error messages - if($category){ - $message = 'success_on_insert'; - }else{ - $message = 'error_on_insert'; - } +#Error messages + if($category){ + $message = 'success_on_insert'; + }else{ + $message = 'error_on_insert'; + } - $template->param('message' => $message); + $template->param('message' => $message); #Create a patron }elsif ( $step && $step == 3 ){ my $firstpassword = $input->param('password'); my $secondpassword = $input->param('password2'); - - if ($firstpassword ne $secondpassword){ - my $DisplayError='Please rewrite the password'; - warn $DisplayError; - $template->param(DisplayError=>$DisplayError, - ); - } - #Find all library records in the database and hand them to the template to display in the library dropdown box my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); $template->param(libraries => $libraries, @@ -244,6 +260,14 @@ if ( $start && $start eq 'Start setting up my Koha' ){ categories => $categories, ); +#Incrementing the highest existing patron cardnumber to prevent duplicate cardnumber entry + my $exisiting_cardnumber = my $sth_search = $dbh->prepare("SELECT MAX(cardnumber) FROM borrowers"); + my $new_cardnumber = $exisiting_cardnumber + 1; + warn $new_cardnumber; + $template->param("newcardnumber" => $new_cardnumber); + + + my $op = $input->param('op') // 'list'; my $minpw = C4::Context->preference("minPasswordLength"); $template->param("minPasswordLength" => $minpw); @@ -251,13 +275,13 @@ if ( $start && $start eq 'Start setting up my Koha' ){ my @messages; my @errors; my $nok = $input->param('nok'); - my $firstpassword = $input->param('password'); my $secondpassword = $input->param('password2'); my $cardnumber= $input->param('cardnumber'); my $borrowernumber= $input->param('borrowernumber'); my $userid=$input->param('userid'); +#If the entered cardnumber causes an error hand this error to the @errors array if(my $error_code = checkcardnumber($cardnumber, $borrowernumber)){ push @errors, $error_code == 1 ? 'ERROR_cardnumber_already_exists' @@ -266,6 +290,7 @@ if ( $start && $start eq 'Start setting up my Koha' ){ :() } +#If the entered password causes an error hand this error to the @errors array push @errors, "ERROR_password_mismatch" if $firstpassword ne $secondpassword; push @errors, "ERROR_short_password" if ($firstpassword && $minpw && $firstpassword ne '****' && (length($firstpassword) < $minpw)); @@ -273,8 +298,8 @@ if ( $start && $start eq 'Start setting up my Koha' ){ #Passing errors to template $nok = $nok || scalar(@errors); +#If errors have been generated from the users inputted cardnumber or password then display the error and do not insert the patron into the borrowers table if($nok){ - foreach my $error (@errors){ if ($error eq 'ERROR_password_mismatch'){ $template->param(errorpasswordmismatch => 1); @@ -293,8 +318,9 @@ if ( $start && $start eq 'Start setting up my Koha' ){ } } $template->param('nok' => 1); - warn $nok; - }else{ + +#Else if no errors have been caused by the users inputted card number or password then insert the patron into the borrowers table + }else{ my ($template, $loggedinuser, $cookie)= C4::InstallAuth::get_template_and_user({ template_name => "/onboarding/onboardingstep3.tt", query => $input, @@ -370,9 +396,6 @@ if ( $start && $start eq 'Start setting up my Koha' ){ my $createitemtype = $input->param('createitemtype'); $template->param('createitemtype'=> $createitemtype ); - my $itemtype_code = $input->param('itemtype'); - my $op = $input->param('op') // 'list'; - my $message; my( $template, $borrowernumber, $cookie) = C4::InstallAuth::get_template_and_user( { template_name => "/onboarding/onboardingstep4.tt", @@ -386,15 +409,20 @@ if ( $start && $start eq 'Start setting up my Koha' ){ if($op eq 'add_validate'){ my $description = $input->param('description'); - - #store the input from the form - only 2 fields + my $itemtype_code = $input->param('itemtype'); + $itemtype_code = uc($itemtype_code); + #Create a new itemtype object using the user inputted itemtype and description my $itemtype= Koha::ItemType->new( { itemtype => $itemtype_code, description => $description, } ); + eval{ $itemtype->store; }; - #Error messages + + my $message; + +#Fill the $message variable with an error if the item type object was not successfully created and inserted into the itemtypes table if($itemtype){ $message = 'success_on_insert'; }else{ @@ -442,8 +470,9 @@ if ( $start && $start eq 'Start setting up my Koha' ){ debug => 1, }); +#If no libraries exist then set the $branch value to * my $branch = $input->param('branch'); - unless ( $branch ) { + unless ( $branch ) { if ( C4::Context->preference('DefaultToLoggedInLibraryCircRules') ) { $branch = Koha::Libraries->search->count() == 1 ? undef : C4::Context::mybranch(); } @@ -456,7 +485,7 @@ if ( $start && $start eq 'Start setting up my Koha' ){ if($op eq 'add_validate'){ my $type = $input->param('type'); - my $br = $branch; + my $br = $input->param('branch'); my $bor = $input->param('categorycode'); my $itemtype = $input->param('itemtype'); my $maxissueqty = $input->param('maxissueqty'); @@ -541,7 +570,7 @@ if ( $start && $start eq 'Start setting up my Koha' ){ if ($res->{total}) { $sth_update->execute($onshelfholds, $branch); } else { - $sth_insert->execute($branch, $onshelfholds); + $sth_insert->execute($branch, $onshelfholds); } } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt index 7f1fb53..4f3f119 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt @@ -93,7 +93,7 @@
  • - +
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep0.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep0.tt index 9d18344..e4fc3ee 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep0.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep0.tt @@ -2,44 +2,15 @@ [% INCLUDE 'doc-head-open.inc' %] [% INCLUDE 'installer-doc-head-close.inc' %] - Welcome › to › Koha - - - - - +

    Welcome to Koha

    Koha

    -

    You haven't installed some sample data, so we're just going to set up a few more things...

    +

    We're just going to set up a few more things...

    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 3e51368..c4a732d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt @@ -4,39 +4,11 @@ Welcome › to › Koha - - - -
    -

    Welcome to Koha test if in correct repo

    +

    Welcome to Koha

    Koha

    [% IF libraries.count > 0 %] @@ -59,7 +31,11 @@

    Success: Library created!

    To add another library and for more settings,
    - go to Tools->Administration->Libraries and Groups + go to:

    + More->Administration->Libraries and groups
    + OR
    + Administration->Libraries and groups +

    Next up: @@ -87,12 +63,12 @@
    1. - + Required
    2. - + Required
    @@ -100,8 +76,8 @@
    -[% END %] - +[% END %] + 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 7dc5d93..4687d62 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep2.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep2.tt @@ -6,29 +6,9 @@ Add a patron category [% INCLUDE 'installer-doc-head-close.inc' %] [% INCLUDE 'calendar.inc' %] - - -$(document).ready(function(){ - $("#category_form").validate({ - rules: { - categorycode: { - required: true, - letters_numbers: true - }, - description: "required", - enrolmentperiod: { - required: function(element){ - return $("#enrolmentperioddate").val() === ""; - }, - digits: true, - enrollment_period: true - }, - enrolmentperioddate: { - required: function(element){ - return $("#enrolmentperiod").val() === ""; - }, - enrollment_period: true - }, - dateofbirthrequired: { - digits: true - }, - upperagelimit: { - digits: true - }, - enrolmentfee: { - number: true - }, - reservefee: { - number: true - }, - category_type: { - required: true - } - }, - messages: { - enrolmentperiod: { - required: MSG_ONE_ENROLLMENTPERIOD - }, - enrolmentperioddate: { - required: MSG_ONE_ENROLLMENTPERIOD - } - } - - }); - -}) + + +
    @@ -265,7 +292,10 @@ $(document).ready(function(){

    Success: Patron category created!

    To add another patron category and for more settings
    - go to More->Administration->Patrons & Circulation->Patron Categories

    + go to:
    + More->Administration->Patron categories
    + OR
    + Administration->Patron categories

    Next up:
    @@ -280,19 +310,19 @@ $(document).ready(function(){
    - [% END %] - + [% END %] + [% ELSE %] -

    Create a new Patron Category testing rwq

    -
    +

    Create a new Patron Category

    +
    1. - + Required
    2. @@ -361,15 +391,11 @@ $(document).ready(function(){
      1. - months + months
      2. - - ... - - - +
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep3.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep3.tt index c72a859..19381d3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep3.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep3.tt @@ -114,7 +114,7 @@ $(document).ready(function(){
    [% ELSE %] -

    Create a new Patron

    +

    Create a new Patron

    Library Management

    Now we will create a patron with superlibrarian permissions. Login with this to access Koha as a staff member will all permissions. @@ -129,12 +129,12 @@ $(document).ready(function(){

  • - + Required
  • - + Required
  • @@ -142,7 +142,7 @@ $(document).ready(function(){
    1. - + Required
    2. @@ -160,9 +160,9 @@ $(document).ready(function(){
    3. Required
    4. @@ -180,17 +180,17 @@ $(document).ready(function(){

      OPAC/Staff Login

    5. - + Required
    6. - + Required
    7. - + Required
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep4.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep4.tt index fe6fb59..87be779 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep4.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep4.tt @@ -66,12 +66,12 @@
    1. - + Required
    2. - + Required
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt index 6bd611a..f582bd1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt @@ -53,7 +53,7 @@ [% FOREACH category IN categories %] - [%END%] + [%END%] Required @@ -70,20 +70,20 @@
  • - + Required
  • - + Required
  • + [% END %] +
  • - + Required
  • - + Required
  • -- 2.1.4