Bugzilla – Attachment 63512 Details for
Bug 18606
Move rotating collections code to Koha::Object
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18606: Get rid of CreateCollection
Bug-18606-Get-rid-of-CreateCollection.patch (text/plain), 3.85 KB, created by
Josef Moravec
on 2017-05-18 09:21:29 UTC
(
hide
)
Description:
Bug 18606: Get rid of CreateCollection
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2017-05-18 09:21:29 UTC
Size:
3.85 KB
patch
obsolete
>From e9913fb0d3a034aa064955b20e49da306724f648 Mon Sep 17 00:00:00 2001 >From: Josef Moravec <josef.moravec@gmail.com> >Date: Fri, 14 Oct 2016 18:00:19 +0200 >Subject: [PATCH] Bug 18606: Get rid of CreateCollection > >--- > C4/RotatingCollections.pm | 46 --------------------------------- > rotating_collections/editCollections.pl | 30 ++++++++++----------- > 2 files changed, 15 insertions(+), 61 deletions(-) > >diff --git a/C4/RotatingCollections.pm b/C4/RotatingCollections.pm >index c1bd2e9..0f1ef69 100644 >--- a/C4/RotatingCollections.pm >+++ b/C4/RotatingCollections.pm >@@ -48,7 +48,6 @@ BEGIN { > require Exporter; > @ISA = qw( Exporter ); > @EXPORT = qw( >- CreateCollection > UpdateCollection > > GetItemsInCollection >@@ -61,51 +60,6 @@ BEGIN { > ); > } > >-=head2 CreateCollection >- ( $success, $errorcode, $errormessage ) = CreateCollection( $title, $description ); >- Creates a new collection >- >- Input: >- $title: short description of the club or service >- $description: long description of the club or service >- >- Output: >- $success: 1 if all database operations were successful, 0 otherwise >- $errorCode: Code for reason of failure, good for translating errors in templates >- $errorMessage: English description of error >- >-=cut >- >-sub CreateCollection { >- my ( $title, $description ) = @_; >- >- my $schema = Koha::Database->new()->schema(); >- my $duplicate_titles = $schema->resultset('Collection')->count({ colTitle => $title }); >- >- ## Check for all necessary parameters >- if ( !$title ) { >- return ( 0, 1, "NO_TITLE" ); >- } elsif ( $duplicate_titles ) { >- return ( 0, 2, "DUPLICATE_TITLE" ); >- } >- >- $description ||= q{}; >- >- my $success = 1; >- >- my $dbh = C4::Context->dbh; >- >- my $sth; >- $sth = $dbh->prepare( >- "INSERT INTO collections ( colId, colTitle, colDesc ) >- VALUES ( NULL, ?, ? )" >- ); >- $sth->execute( $title, $description ) or return ( 0, 3, $sth->errstr() ); >- >- return 1; >- >-} >- > =head2 UpdateCollection > > ( $success, $errorcode, $errormessage ) = UpdateCollection( $colId, $title, $description ); >diff --git a/rotating_collections/editCollections.pl b/rotating_collections/editCollections.pl >index bd4b917..b4dcba6 100755 >--- a/rotating_collections/editCollections.pl >+++ b/rotating_collections/editCollections.pl >@@ -47,21 +47,22 @@ if ( $action eq 'create' ) { > my $title = $query->param('title'); > my $description = $query->param('description'); > >- my ( $createdSuccessfully, $errorCode, $errorMessage ) = >- CreateCollection( $title, $description ); >- >- $template->param( >- previousActionCreate => 1, >- createdTitle => $title, >+ my $collection = Koha::RotatingCollection->new( >+ { colTitle => $title, >+ colDesc => $description, >+ } > ); > >- if ($createdSuccessfully) { >- $template->param( createSuccess => 1 ); >- } >- else { >- $template->param( createFailure => 1 ); >- $template->param( failureMessage => $errorMessage ); >+ eval { $collection->store; }; >+ >+ if ($@) { >+ push @messages, { type => 'error', code => 'error_on_insert' }; >+ } else { >+ push @messages, { type => 'message', code => 'success_on_insert' }; > } >+ >+ $action = "list"; >+ > } elsif ( $action eq 'delete' ) { # Delete collection > my $colId = $query->param('colId'); > my $collection = Koha::RotatingCollections->find($colId); >@@ -72,11 +73,10 @@ if ( $action eq 'create' ) { > } else { > push @messages, { type => 'message', code => 'success_on_delete' }; > } >+ > $action = "list"; >-} > >-## Edit a club or service: grab data, put in form. >-elsif ( $action eq 'edit' ) { >+} elsif ( $action eq 'edit' ) { # Edit page of collection > my $collection = Koha::RotatingCollections->find($query->param('colId')); > > $template->param( >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18606
:
63508
|
63509
|
63510
|
63511
|
63512
|
63513
|
63514
|
63515
|
63516
|
63517
|
63518
|
63519
|
63520
|
63521
|
63522
|
63523
|
63524
|
63525
|
63526
|
63527
|
63528
|
66227
|
66228
|
66229
|
66230
|
66231
|
66232
|
66233
|
66234
|
66235
|
66236
|
66237
|
66238
|
66239
|
66240
|
66241
|
66286
|
66287
|
66288
|
66289
|
66290
|
66291
|
66292
|
66293
|
66294
|
66295
|
66296
|
66297
|
66298
|
66299
|
66300
|
67734
|
67735
|
67736
|
67737
|
67738
|
67739
|
67740
|
67741
|
67742
|
67743
|
67744
|
67745
|
67746
|
67747
|
67748
|
67749
|
68428
|
68429
|
68430
|
68431
|
68432
|
68433
|
68434
|
68435
|
68436
|
68437
|
68438
|
68439
|
68440
|
68441
|
68442
|
68443
|
69709
|
69710
|
69711
|
69712
|
69713
|
69714
|
69715
|
69716
|
69717
|
69718
|
69719
|
69720
|
69721
|
69722
|
69723
|
69759
|
72416
|
72417
|
72418
|
72419
|
72420
|
72421
|
72422
|
72423
|
72424
|
72425
|
72426
|
72427
|
72428
|
72429
|
72430
|
72431
|
72572
|
72573
|
72574
|
72575
|
72576
|
72577
|
72578
|
72579
|
72580
|
72581
|
72582
|
72583
|
72584
|
72585
|
72586
|
72587
|
72816
|
79141
|
79142
|
79143
|
79144
|
79145
|
79146
|
79147
|
79148
|
79149
|
79150
|
79151
|
79152
|
79153
|
79154
|
79155
|
79156
|
79157
|
79158
|
79161