Bug 5087: (QA follow-up) Rename the attribute to fit later API usage
authorTomas Cohen Arazi <tomascohen@theke.io>
Mon, 20 Jul 2020 14:09:01 +0000 (11:09 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 23 Jul 2020 08:52:10 +0000 (10:52 +0200)
This patch renames the introduced attribute for later usage on the API,
and changes the logic to use it the other way around.

It also adds a KEY for the flag, as it will be used in WHERE statements.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Koha/Schema/Result/ExportFormat.pm
installer/data/mysql/atomicupdate/bug_5087_-_add_opac_option_field_to_export_formats.perl
installer/data/mysql/kohastructure.sql
koha-tmpl/intranet-tmpl/prog/en/modules/tools/csv-profiles.tt
opac/opac-basket.pl
opac/opac-downloadcart.pl
tools/csv-profiles.pl

index 1816f0d..675c6e2 100644 (file)
@@ -85,7 +85,7 @@ __PACKAGE__->table("export_format");
   is_nullable: 1
   size: 255
 
-=head2 opac_option
+=head2 staff_only
 
   data_type: 'tinyint'
   default_value: 0
@@ -129,7 +129,7 @@ __PACKAGE__->add_columns(
     is_nullable => 1,
     size => 255,
   },
-  "opac_option",
+  "staff_only",
   { data_type => "tinyint", default_value => 0, is_nullable => 0 },
 );
 
@@ -146,8 +146,8 @@ __PACKAGE__->add_columns(
 __PACKAGE__->set_primary_key("export_format_id");
 
 
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-04-20 20:08:25
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:J2VDj9yI8uanFR9EGv2sXw
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-07-20 14:15:46
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:O8kM+dd6GTS2qS39lnDG1g
 
 sub koha_object_class {
     'Koha::CsvProfile';
@@ -157,7 +157,7 @@ sub koha_objects_class {
 }
 
 __PACKAGE__->add_columns(
-    '+opac_option' => { is_boolean => 1 },
+    '+staff_only' => { is_boolean => 1 },
 );
 
 1;
index c2b4021..7eaffd4 100644 (file)
@@ -1,8 +1,12 @@
 $DBversion = 'XXX';
 if( CheckVersion( $DBversion ) ) {
-    unless( column_exists( 'export_format', 'opac_option' ) ) {
-        $dbh->do(q|ALTER TABLE export_format ADD opac_option TINYINT(1) NOT NULL DEFAULT 0 AFTER used_for|);
+    unless( column_exists( 'export_format', 'staff_only' ) ) {
+        $dbh->do(q|
+            ALTER TABLE export_format
+                ADD staff_only TINYINT(1) NOT NULL DEFAULT 0 AFTER used_for,
+                ADD KEY `staff_only_idx` (`staff_only`);
+        |);
     }
 
-    NewVersion( $DBversion, 5087, "Add export_format.opac_option" );
+    NewVersion( $DBversion, 5087, "Add export_format.staff_only" );
 }
index e57cf00..456f7b1 100644 (file)
@@ -691,8 +691,9 @@ CREATE TABLE `export_format` (
   `encoding` varchar(255) NOT NULL DEFAULT 'utf8',
   `type` varchar(255) DEFAULT 'marc',
   `used_for` varchar(255) DEFAULT 'export_records',
-  `opac_option` TINYINT(1) NOT NULL DEFAULT 0,
-  PRIMARY KEY (`export_format_id`)
+  `staff_only` TINYINT(1) NOT NULL DEFAULT 0,
+  PRIMARY KEY (`export_format_id`),
+  KEY `staff_only_idx` (`staff_only`)
 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Used for CSV export';
 
 --
index 55f7f7a..1d2dbfd 100644 (file)
                 </li>
 
                 <li class="marc_specific">
-                    <label for="opac_option">Show option in OPAC: </label>
-                    [% IF csv_profile.opac_option %]
-                        <input type="checkbox" name="opac_option" id="opac_option" value="1" checked="checked">
+                    <label for="staff_only">Only available on the staff interface: </label>
+                    [% IF csv_profile.staff_only %]
+                        <input type="checkbox" name="staff_only" id="staff_only" value="1" checked="checked">
                     [% ELSE %]
-                        <input type="checkbox" name="opac_option" id="opac_option" value="1">
+                        <input type="checkbox" name="staff_only" id="staff_only" value="1">
                     [% END %]
                 </li>
 
index a7e7100..1713de4 100755 (executable)
@@ -166,7 +166,11 @@ my $resultsarray = \@results;
 # my $itemsarray=\@items;
 
 $template->param(
-    csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }) ],
+    csv_profiles => [
+        Koha::CsvProfiles->search(
+            { type => 'marc', used_for => 'export_records', staff_only => 0 }
+        )
+    ],
     bib_list => $bib_list,
     BIBLIO_RESULTS => $resultsarray,
 );
index 671542a..7720cd4 100755 (executable)
@@ -124,7 +124,17 @@ if ($bib_list && $format) {
     print $output;
 
 } else { 
-    $template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records', opac_option => 1 }) ]);
+    $template->param(
+        csv_profiles => [
+            Koha::CsvProfiles->search(
+                {
+                    type       => 'marc',
+                    used_for   => 'export_records',
+                    staff_only => 0
+                }
+            )
+        ]
+    );
     $template->param(bib_list => $bib_list); 
     output_html_with_http_headers $query, $cookie, $template->output;
 }
index b1bbcba..284fdc1 100755 (executable)
@@ -84,7 +84,7 @@ if ( $op eq 'add_form' ) {
     my $field_separator    = $input->param("field_separator");
     my $subfield_separator = $input->param("subfield_separator");
     my $encoding           = $input->param("encoding");
-    my $opac_option        = $input->param("opac_option");
+    my $staff_only         = $input->param("staff_only") ? 1 : 0;
 
     if ($export_format_id) {
         my $csv_profile = Koha::CsvProfiles->find($export_format_id)
@@ -98,7 +98,7 @@ if ( $op eq 'add_form' ) {
         $csv_profile->encoding($encoding);
         $csv_profile->type($type);
         $csv_profile->used_for($used_for);
-        $csv_profile->opac_option($opac_option);
+        $csv_profile->staff_only($staff_only);
         eval { $csv_profile->store; };
 
         if ($@) {
@@ -117,7 +117,7 @@ if ( $op eq 'add_form' ) {
                 encoding           => $encoding,
                 type               => $type,
                 used_for           => $used_for,
-                opac_option        => $opac_option
+                staff_only         => $staff_only
             }
         );
         eval { $csv_profile->store; };