Bug 23019: (follow-up) Fix other things

This patch:
* Fixes table name change
* Adds schema file
* Changes api parameter name
* Fixes string escaping
* Fixes error handling

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Agustin Moyano 2020-11-06 14:50:29 -03:00 committed by Jonathan Druart
parent 2d53ae88b6
commit 9f5596afd6
9 changed files with 39 additions and 22 deletions

View file

@ -48,7 +48,7 @@ sub to_api_mapping {
=cut
sub _type {
return 'ImportBatchesProfile';
return 'ImportBatchProfile';
}
1;

View file

@ -37,7 +37,7 @@ Koha::ImportBatchProfiles - Koha ImportBatchProfiles Object class
=cut
sub _type {
return 'ImportBatchesProfile';
return 'ImportBatchProfile';
}
=head3 object_class

View file

@ -91,7 +91,7 @@ sub edit {
my $c = shift->openapi->valid_input or return;
return try {
my $profile_id = $c->validation->param('profile_id');
my $profile_id = $c->validation->param('import_batch_profile_id');
my $profile = Koha::ImportBatchProfiles->find( $profile_id );
unless ($profile) {
return $c->render( status => 404,
@ -121,7 +121,7 @@ Method that handles deleting a Koha::ImportBatchProfile object
sub delete {
my $c = shift->openapi->valid_input or return;
my $profile_id = $c->validation->param('profile_id');
my $profile_id = $c->validation->param('import_batch_profile_id');
my $profile = Koha::ImportBatchProfiles->find( $profile_id );
unless ($profile) {

View file

@ -246,13 +246,13 @@ __PACKAGE__->has_many(
Type: belongs_to
Related object: L<Koha::Schema::Result::ImportBatchesProfile>
Related object: L<Koha::Schema::Result::ImportBatchProfile>
=cut
__PACKAGE__->belongs_to(
"profile",
"Koha::Schema::Result::ImportBatchesProfile",
"Koha::Schema::Result::ImportBatchProfile",
{ id => "profile_id" },
{
is_deferrable => 1,
@ -263,8 +263,8 @@ __PACKAGE__->belongs_to(
);
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-06-03 15:47:08
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:jGfBdM8ht823HaxSr2c9Wg
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-11-06 13:52:29
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:nnGJ0Nvgiz123+ic7v0GqQ
=head2 koha_object_class

View file

@ -1,12 +1,12 @@
use utf8;
package Koha::Schema::Result::ImportBatchesProfile;
package Koha::Schema::Result::ImportBatchProfile;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Koha::Schema::Result::ImportBatchesProfile
Koha::Schema::Result::ImportBatchProfile
=cut
@ -15,11 +15,11 @@ use warnings;
use base 'DBIx::Class::Core';
=head1 TABLE: C<import_batches_profile>
=head1 TABLE: C<import_batch_profiles>
=cut
__PACKAGE__->table("import_batches_profile");
__PACKAGE__->table("import_batch_profiles");
=head1 ACCESSORS
@ -132,6 +132,20 @@ __PACKAGE__->add_columns(
__PACKAGE__->set_primary_key("id");
=head1 UNIQUE CONSTRAINTS
=head2 C<u_import_batch_profiles__name>
=over 4
=item * L</name>
=back
=cut
__PACKAGE__->add_unique_constraint("u_import_batch_profiles__name", ["name"]);
=head1 RELATIONS
=head2 import_batches
@ -150,8 +164,11 @@ __PACKAGE__->has_many(
);
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-06-03 15:47:08
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:BWFz5yLEEP6ANuAWKAMCeg
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-11-06 13:52:29
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:kThbQZTT2c0fuWAGgvoDLQ
# You can replace this text with custom code or comments, and it will be preserved on regeneration
__PACKAGE__->add_columns(
'+parse_items' => { is_boolean => 1 },

View file

@ -11,8 +11,8 @@
"patron_id_qp": {
"$ref": "parameters/patron.json#/patron_id_qp"
},
"profile_id_pp": {
"$ref": "parameters/import_batch_profile.json#/profile_id_pp"
"import_batch_profile_id_pp": {
"$ref": "parameters/import_batch_profile.json#/import_batch_profile_id_pp"
},
"city_id_pp": {
"$ref": "parameters/city.json#/city_id_pp"

View file

@ -1,6 +1,6 @@
{
"profile_id_pp": {
"name": "profile_id",
"import_batch_profile_id_pp": {
"name": "import_batch_profile_id",
"in": "path",
"description": "Internal profile identifier",
"required": true,

View file

@ -352,7 +352,7 @@
},
"x-koha-authorization": {
"permissions": {
"catalogue": "1"
"tools": "stage_marc_import"
}
}
}

View file

@ -362,7 +362,7 @@
return getProfiles(profile.profile_id);
})
.catch(function(error) {
alert(_("An error occurred")+"\n\n"+error);
alert(_("An error occurred")+"\n\n"+((error.responseJSON && error.responseJSON.error) || error.responseText || error.statusText));
})
});
@ -386,7 +386,7 @@
return getProfiles();
})
.catch(function(error) {
alert(_("An error occurred")+"\n\n"+error);
alert(_("An error occurred")+"\n\n"+((error.responseJSON && error.responseJSON.error) || error.responseText || error.statusText));
})
});
});
@ -460,7 +460,7 @@
opt.prop('selected', true);
}
opt.attr("value", profile.profile_id);
opt.html(profile.name);
opt.text(profile.name);
opt.data("profile", profile);
});
})