Koha/svc/letters
Jonathan Druart 5c4fdcf78a Bug 11742: A letter code should be unique.
This patch is a dirty way to fix a design issue on notices.
Currently the code assumes that a letter code is unique. Which is wrong,
the primary key is module, code, branchcode.

Maybe we should add a primary key (id) for the letter table in order to
pass the id to the template and correctly manage the letter code
duplication.

Test plan:
Try to duplicate a letter code using edit, add and copy actions.
If you manage to do it, please describe how you did.

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
2014-06-23 15:19:55 -03:00

63 lines
1.4 KiB
Perl
Executable file

#!/usr/bin/perl
# This file is part of Koha.
#
# Copyright 2014 BibLibre
#
# 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 <http://www.gnu.org/licenses>.
use Modern::Perl;
use C4::Service;
use C4::Letters qw( GetLetters );
=head1 NAME
svc/letters - Web service for getting letters
=head1 SYNOPSIS
GET /svc/letters
=head1 DESCRIPTION
For the moment, this service is only used to get a letter from a letter code.
=head1 METHODS
=cut
=head2 set_preference
=over 4
GET /svc/letters/$code
=back
Used to get letters with a given letter code.
=cut
our ( $query, $response ) = C4::Service->init( tools => 'edit_notices' );
sub get_letters {
my $letters = GetLetters({ code => $query->param('code') });
$response->param( letters => $letters );
C4::Service->return_success( $response );
}
C4::Service->dispatch(
[ 'GET /', [ 'code' ], \&get_letters ],
);