Bug 28130: (QA follow-up) Tidy
Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
73739dd0b6
commit
fe21bbad2a
5 changed files with 52 additions and 57 deletions
|
@ -2708,12 +2708,12 @@ Return a Koha::Subscriptions object containing subscriptions for which the patro
|
|||
=cut
|
||||
|
||||
sub alert_subscriptions {
|
||||
my ( $self ) = @_;
|
||||
my ($self) = @_;
|
||||
|
||||
my @alerts = $self->_result->alerts;
|
||||
my @alerts = $self->_result->alerts;
|
||||
my @subscription_ids = map { $_->externalid } @alerts;
|
||||
|
||||
return Koha::Subscriptions->search({ subscriptionid => \@subscription_ids });
|
||||
return Koha::Subscriptions->search( { subscriptionid => \@subscription_ids } );
|
||||
}
|
||||
|
||||
=head2 Internal methods
|
||||
|
|
|
@ -28,29 +28,33 @@ use Koha::Patrons;
|
|||
my $input = CGI->new;
|
||||
|
||||
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
|
||||
{ template_name => "members/alert-subscriptions.tt",
|
||||
query => $input,
|
||||
type => "intranet",
|
||||
flagsrequired => { serials => '*' },
|
||||
{
|
||||
template_name => "members/alert-subscriptions.tt",
|
||||
query => $input,
|
||||
type => "intranet",
|
||||
flagsrequired => { serials => '*' },
|
||||
}
|
||||
);
|
||||
|
||||
my $borrowernumber = $input->param('borrowernumber');
|
||||
|
||||
my $logged_in_user = Koha::Patrons->find( $loggedinuser );
|
||||
my $patron = Koha::Patrons->find( $borrowernumber );
|
||||
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
|
||||
my $logged_in_user = Koha::Patrons->find($loggedinuser);
|
||||
my $patron = Koha::Patrons->find($borrowernumber);
|
||||
output_and_exit_if_error(
|
||||
$input, $cookie, $template,
|
||||
{ module => 'members', logged_in_user => $logged_in_user, current_patron => $patron }
|
||||
);
|
||||
|
||||
my $subscription_id = $input->param('subscription_id');
|
||||
if ( $subscription_id ) {
|
||||
my $subscription = Koha::Subscriptions->find( $subscription_id );
|
||||
$subscription->remove_subscriber( $patron );
|
||||
print $input->redirect("/cgi-bin/koha/members/alert-subscriptions.pl?borrowernumber=".$borrowernumber);
|
||||
if ($subscription_id) {
|
||||
my $subscription = Koha::Subscriptions->find($subscription_id);
|
||||
$subscription->remove_subscriber($patron);
|
||||
print $input->redirect( "/cgi-bin/koha/members/alert-subscriptions.pl?borrowernumber=" . $borrowernumber );
|
||||
}
|
||||
|
||||
$template->param(
|
||||
patron => $patron,
|
||||
alertsview => 1,
|
||||
patron => $patron,
|
||||
alertsview => 1,
|
||||
);
|
||||
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
# 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 CGI qw ( -utf8 );
|
||||
use C4::Auth qw( get_template_and_user );
|
||||
|
@ -25,68 +24,58 @@ use C4::Output qw( output_html_with_http_headers );
|
|||
use C4::Context;
|
||||
use C4::Serials qw( GetSubscription );
|
||||
|
||||
|
||||
my $query = CGI->new;
|
||||
my $op = $query->param('op') || '';
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
my ( $template, $loggedinuser, $cookie );
|
||||
my $subscriptionid = $query->param('subscriptionid');
|
||||
my $referer = $query->param('referer') || 'detail';
|
||||
my $biblionumber = $query->param('biblionumber');
|
||||
my $referer = $query->param('referer') || 'detail';
|
||||
my $biblionumber = $query->param('biblionumber');
|
||||
|
||||
( $template, $loggedinuser, $cookie ) = get_template_and_user(
|
||||
{
|
||||
template_name => "opac-alert-subscribe.tt",
|
||||
query => $query,
|
||||
type => "opac",
|
||||
authnotrequired => 0, # user must logged in to request
|
||||
# subscription notifications
|
||||
authnotrequired => 0, # user must be logged in to request
|
||||
# subscription notifications
|
||||
}
|
||||
);
|
||||
|
||||
my $subscription = Koha::Subscriptions->find( $subscriptionid );
|
||||
my $logged_in_patron = Koha::Patrons->find( $loggedinuser );
|
||||
my $subscription = Koha::Subscriptions->find($subscriptionid);
|
||||
my $logged_in_patron = Koha::Patrons->find($loggedinuser);
|
||||
|
||||
if ( $op eq 'alert_confirmed' ) {
|
||||
$subscription->add_subscriber( $logged_in_patron );
|
||||
$subscription->add_subscriber($logged_in_patron);
|
||||
if ( $referer eq 'serial' ) {
|
||||
print $query->redirect(
|
||||
"opac-serial-issues.pl?biblionumber=$biblionumber");
|
||||
print $query->redirect("opac-serial-issues.pl?biblionumber=$biblionumber");
|
||||
exit;
|
||||
} else {
|
||||
print $query->redirect(
|
||||
"opac-detail.pl?biblionumber=$biblionumber");
|
||||
print $query->redirect("opac-detail.pl?biblionumber=$biblionumber");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
elsif ( $op eq 'cancel_confirmed' ) {
|
||||
$subscription->remove_subscriber( $logged_in_patron );
|
||||
} elsif ( $op eq 'cancel_confirmed' ) {
|
||||
$subscription->remove_subscriber($logged_in_patron);
|
||||
warn "CANCEL confirmed : $loggedinuser, $subscriptionid";
|
||||
if ( $referer eq 'serial' ) {
|
||||
print $query->redirect(
|
||||
"opac-serial-issues.pl?biblionumber=$biblionumber");
|
||||
print $query->redirect("opac-serial-issues.pl?biblionumber=$biblionumber");
|
||||
exit;
|
||||
} elsif ( $referer eq 'patron' ) {
|
||||
print $query->redirect(
|
||||
"/cgi-bin/koha/opac-alert-subscriptions.pl"
|
||||
);
|
||||
print $query->redirect("/cgi-bin/koha/opac-alert-subscriptions.pl");
|
||||
} else {
|
||||
print $query->redirect(
|
||||
"opac-detail.pl?biblionumber=$biblionumber");
|
||||
print $query->redirect("opac-detail.pl?biblionumber=$biblionumber");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
my $subscription = &GetSubscription($subscriptionid);
|
||||
$template->param(
|
||||
referer => $referer,
|
||||
"typeissue$op" => 1,
|
||||
bibliotitle => $subscription->{bibliotitle},
|
||||
notes => $subscription->{notes},
|
||||
subscriptionid => $subscriptionid,
|
||||
subscriptionid => $subscriptionid,
|
||||
biblionumber => $biblionumber,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -29,25 +29,27 @@ my $query = CGI->new();
|
|||
|
||||
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
|
||||
{
|
||||
template_name => 'opac-alert-subscriptions.tt',
|
||||
query => $query,
|
||||
type => 'opac',
|
||||
template_name => 'opac-alert-subscriptions.tt',
|
||||
query => $query,
|
||||
type => 'opac',
|
||||
}
|
||||
);
|
||||
|
||||
my $patron = Koha::Patrons->find( $borrowernumber );
|
||||
my $patron = Koha::Patrons->find($borrowernumber);
|
||||
|
||||
$template->param(
|
||||
alertsview => 1,
|
||||
patron => $patron,
|
||||
referer => 'patron',
|
||||
patron => $patron,
|
||||
referer => 'patron',
|
||||
);
|
||||
|
||||
my $new_session_id = $query->cookie('CGISESSID');
|
||||
$template->param(
|
||||
csrf_token => Koha::Token->new->generate_csrf({
|
||||
session_id => $new_session_id,
|
||||
}),
|
||||
csrf_token => Koha::Token->new->generate_csrf(
|
||||
{
|
||||
session_id => $new_session_id,
|
||||
}
|
||||
),
|
||||
);
|
||||
|
||||
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
|
||||
|
|
|
@ -1934,13 +1934,13 @@ subtest 'alert_subscriptions tests' => sub {
|
|||
|
||||
plan tests => 3;
|
||||
|
||||
my $patron = $builder->build_object({ class => 'Koha::Patrons' });
|
||||
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
|
||||
|
||||
my $subscription1 = $builder->build_object({ class => 'Koha::Subscriptions' });
|
||||
$subscription1->add_subscriber( $patron );
|
||||
my $subscription1 = $builder->build_object( { class => 'Koha::Subscriptions' } );
|
||||
$subscription1->add_subscriber($patron);
|
||||
|
||||
my $subscription2 = $builder->build_object({ class => 'Koha::Subscriptions' });
|
||||
$subscription2->add_subscriber( $patron );
|
||||
my $subscription2 = $builder->build_object( { class => 'Koha::Subscriptions' } );
|
||||
$subscription2->add_subscriber($patron);
|
||||
|
||||
my @subscriptions = $patron->alert_subscriptions->as_list;
|
||||
|
||||
|
|
Loading…
Reference in a new issue