From dbf8f4f71ad56d6e400326176584aca86a56cfcb Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 5 May 2023 14:43:01 +0100 Subject: [PATCH] Bug 32721: (QA follow-up) Drop fields from API response Signed-off-by: Martin Renvoize Bug 32721: (QA follow-up) Rename fields to opac* This patch updates the field names to reflect that they're OPAC related. Signed-off-by: Martin Renvoize Bug 32721: (QA follow-up) Fix rebase errors We let some superflous template params creep back in during a rebase somewhere. Signed-off-by: Martin Renvoize --- C4/Auth.pm | 8 ----- Koha/Library.pm | 2 ++ Koha/Template/Plugin/Branches.pm | 16 +++++----- admin/branches.pl | 4 +-- api/v1/swagger/definitions/library.yaml | 10 ------ .../bug_32721-add_branch_level_js.pl | 14 ++++---- installer/data/mysql/kohastructure.sql | 4 +-- .../prog/en/modules/admin/branches.tt | 12 +++---- t/db_dependent/Template/Plugin/Branches.t | 32 +++++++++---------- 9 files changed, 43 insertions(+), 59 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 7361f829e9..2f6321a950 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -1371,14 +1371,6 @@ sub checkauth { OpacFavicon => C4::Context->preference("OpacFavicon"), opacreadinghistory => C4::Context->preference("opacreadinghistory"), opaclanguagesdisplay => C4::Context->preference("opaclanguagesdisplay"), - opacbookbag => "" . C4::Context->preference("opacbookbag"), - OpacCloud => C4::Context->preference("OpacCloud"), - OpacTopissue => C4::Context->preference("OpacTopissue"), - OpacAuthorities => C4::Context->preference("OpacAuthorities"), - OpacBrowser => C4::Context->preference("OpacBrowser"), - TagsEnabled => C4::Context->preference("TagsEnabled"), - OPACUserJS => C4::Context->preference("OPACUserJS"), - OPACUserCSS => C4::Context->preference("OPACUserCSS"), intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), intranetstylesheet => C4::Context->preference("intranetstylesheet"), IntranetNav => C4::Context->preference("IntranetNav"), diff --git a/Koha/Library.pm b/Koha/Library.pm index 2e9259b450..9987bbc53e 100644 --- a/Koha/Library.pm +++ b/Koha/Library.pm @@ -353,6 +353,8 @@ sub to_api_mapping { branchip => 'ip', branchnotes => 'notes', marcorgcode => 'marc_org_code', + opacusercss => undef, + opacuserjs => undef }; } diff --git a/Koha/Template/Plugin/Branches.pm b/Koha/Template/Plugin/Branches.pm index 693c088fe2..7090530f38 100644 --- a/Koha/Template/Plugin/Branches.pm +++ b/Koha/Template/Plugin/Branches.pm @@ -154,25 +154,25 @@ sub pickup_locations { } sub GetBranchSpecificJS { - my ($self, $branchcode) = @_; + my ( $self, $branchcode ) = @_; return q{} unless defined $branchcode; - my $library = Koha::Libraries->find($branchcode); - my $userjs = $library ? $library->userjs : q{}; + my $library = Koha::Libraries->find($branchcode); + my $opacuserjs = $library ? $library->opacuserjs : q{}; - return $userjs + return $opacuserjs; } sub GetBranchSpecificCSS { - my ($self, $branchcode) = @_; + my ( $self, $branchcode ) = @_; return q{} unless defined $branchcode; - my $library = Koha::Libraries->find($branchcode); - my $usercss = $library ? $library->usercss : q{}; + my $library = Koha::Libraries->find($branchcode); + my $opacusercss = $library ? $library->opacusercss : q{}; - return $usercss + return $opacusercss; } 1; diff --git a/admin/branches.pl b/admin/branches.pl index 2ee0a71760..50e909dfa0 100755 --- a/admin/branches.pl +++ b/admin/branches.pl @@ -81,8 +81,8 @@ if ( $op eq 'add_form' ) { marcorgcode pickup_location public - userjs - usercss + opacuserjs + opacusercss ); my $is_a_modif = $input->param('is_a_modif'); diff --git a/api/v1/swagger/definitions/library.yaml b/api/v1/swagger/definitions/library.yaml index 24d88b588f..de010c50d3 100644 --- a/api/v1/swagger/definitions/library.yaml +++ b/api/v1/swagger/definitions/library.yaml @@ -107,16 +107,6 @@ properties: public: type: boolean description: If the library is visible to the public - userjs: - type: - - string - - "null" - description: Any branch-specific UserJS for the OPAC - usercss: - type: - - string - - "null" - description: Any branch-specific UserCSS for the OPAC smtp_server: type: - object diff --git a/installer/data/mysql/atomicupdate/bug_32721-add_branch_level_js.pl b/installer/data/mysql/atomicupdate/bug_32721-add_branch_level_js.pl index 4471d96eef..d2dddd44c2 100755 --- a/installer/data/mysql/atomicupdate/bug_32721-add_branch_level_js.pl +++ b/installer/data/mysql/atomicupdate/bug_32721-add_branch_level_js.pl @@ -7,19 +7,19 @@ return { my ($args) = @_; my ($dbh, $out) = @$args{qw(dbh out)}; - if( !column_exists( 'branches', 'userjs' ) ) { + if( !column_exists( 'branches', 'opacuserjs' ) ) { $dbh->do(q{ - ALTER TABLE branches ADD COLUMN `userjs` longtext DEFAULT NULL AFTER `public` + ALTER TABLE branches ADD COLUMN `opacuserjs` longtext DEFAULT NULL AFTER `public` }); - say $out "Added column 'branches.userjs'"; + say $out "Added column 'branches.opacuserjs'"; } - if( !column_exists( 'branches', 'usercss' ) ) { + if( !column_exists( 'branches', 'opacusercss' ) ) { $dbh->do(q{ - ALTER TABLE branches ADD COLUMN `usercss` longtext DEFAULT NULL AFTER `userjs` + ALTER TABLE branches ADD COLUMN `opacusercss` longtext DEFAULT NULL AFTER `opacuserjs` }); - say $out "Added column 'branches.usercss'"; + say $out "Added column 'branches.opacusercss'"; } }, -}; \ No newline at end of file +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 5829383e65..3ec25c9ac9 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1609,8 +1609,8 @@ CREATE TABLE `branches` ( `marcorgcode` varchar(16) DEFAULT NULL COMMENT 'MARC Organization Code, see http://www.loc.gov/marc/organizations/orgshome.html, when empty defaults to syspref MARCOrgCode', `pickup_location` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'the ability to act as a pickup location', `public` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'whether this library should show in the opac', - `userjs` longtext DEFAULT NULL COMMENT 'branch specific javascript for the OPAC', - `usercss` longtext DEFAULT NULL COMMENT 'branch specific css for the OPAC', + `opacuserjs` longtext DEFAULT NULL COMMENT 'branch specific javascript for the OPAC', + `opacusercss` longtext DEFAULT NULL COMMENT 'branch specific css for the OPAC', PRIMARY KEY (`branchcode`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt index dab2e97ea7..1a38417ff4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt @@ -291,17 +291,17 @@
  • - Click to edit - - + Click to edit + +
  • - Click to edit - - + Click to edit + +
  • diff --git a/t/db_dependent/Template/Plugin/Branches.t b/t/db_dependent/Template/Plugin/Branches.t index 0c37ae0416..163696d190 100755 --- a/t/db_dependent/Template/Plugin/Branches.t +++ b/t/db_dependent/Template/Plugin/Branches.t @@ -227,35 +227,35 @@ subtest 'branch specific js and css' => sub { my $newbranch_with = $builder->build({ source => 'Branch', value => { - userjs => 'console.log(\'Hello World\');', - usercss => 'body { background-color: blue; }' + opacuserjs => 'console.log(\'Hello World\');', + opacusercss => 'body { background-color: blue; }' } }); my $newbranch_none = $builder->build({ source => 'Branch', value => { - userjs => '', - usercss => '' + opacuserjs => '', + opacusercss => '' } }); my $plugin = Koha::Template::Plugin::Branches->new(); - my $userjs = $plugin->GetBranchSpecificJS($newbranch_with->{branchcode}); - is($userjs, $newbranch_with->{userjs},'received correct JS string from function'); + my $opacuserjs = $plugin->GetBranchSpecificJS($newbranch_with->{branchcode}); + is($opacuserjs, $newbranch_with->{opacuserjs},'received correct JS string from function'); - my $usercss = $plugin->GetBranchSpecificCSS($newbranch_with->{branchcode}); - is($usercss, $newbranch_with->{usercss},'received correct CSS string from function'); + my $opacusercss = $plugin->GetBranchSpecificCSS($newbranch_with->{branchcode}); + is($opacusercss, $newbranch_with->{opacusercss},'received correct CSS string from function'); - $userjs = $plugin->GetBranchSpecificJS($newbranch_none->{branchcode}); - $usercss = $plugin->GetBranchSpecificCSS($newbranch_none->{branchcode}); - is($userjs, q{},'received correct blank string from function when branch has none'); - is($usercss, q{},'received correct blank string from function when branch has none'); + $opacuserjs = $plugin->GetBranchSpecificJS($newbranch_none->{branchcode}); + $opacusercss = $plugin->GetBranchSpecificCSS($newbranch_none->{branchcode}); + is($opacuserjs, q{},'received correct blank string from function when branch has none'); + is($opacusercss, q{},'received correct blank string from function when branch has none'); - $userjs = $plugin->GetBranchSpecificJS(); - $usercss = $plugin->GetBranchSpecificCSS(); - is($userjs, q{},'received correct blank string from function when no branch set'); - is($usercss, q{},'received correct blank string from function when no branch set'); + $opacuserjs = $plugin->GetBranchSpecificJS(); + $opacusercss = $plugin->GetBranchSpecificCSS(); + is($opacuserjs, q{},'received correct blank string from function when no branch set'); + is($opacusercss, q{},'received correct blank string from function when no branch set'); $schema->storage->txn_rollback; }; -- 2.37.1 (Apple Git-137.1)