Bug 14544: Handle database error when creating a shelf with DB admin account
authorAlex Arnaud <alex.arnaud@biblibre.com>
Wed, 2 Sep 2015 08:04:04 +0000 (10:04 +0200)
committerTomas Cohen Arazi <tomascohen@theke.io>
Thu, 5 Nov 2015 13:00:22 +0000 (10:00 -0300)
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
I don't think this is useful, it will be a mess if we have to check this
case everywhere. But it works!
I let the cut to the QAer or RM.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Koha/Exceptions.pm
Koha/Virtualshelf.pm
koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt

index f6534e0..4409296 100644 (file)
@@ -28,6 +28,10 @@ use Exception::Class (
     'Koha::Exceptions::Virtualshelves::ShareHasExpired' => {
         isa => 'Koha::Exceptions::Exception',
         description=> 'Cannot share this shelf, the share has expired',
+    },
+    'Koha::Exceptions::Virtualshelves::UseDbAdminAccount' => {
+        isa => 'Koha::Exceptions::Exception',
+        description => "Invalid use of database administrator account",
     }
 );
 
index d80f249..7ce2738 100644 (file)
@@ -51,6 +51,10 @@ our $PUBLIC = 2;
 sub store {
     my ( $self ) = @_;
 
+    unless ( $self->owner ) {
+        Koha::Exceptions::Virtualshelves::UseDbAdminAccount->throw;
+    }
+
     unless ( $self->is_shelfname_valid ) {
         Koha::Exceptions::Virtualshelves::DuplicateObject->throw;
     }
index 25159f1..414342b 100644 (file)
@@ -351,6 +351,8 @@ function placeHold () {
             No biblio has been removed.
         [% CASE 'Koha::Exceptions::Virtualshelves::DuplicateObject' %]
             An error occurred when inserting this list. The name already [% shelfname %] exists.
+        [% CASE 'Koha::Exceptions::Virtualshelves::UseDbAdminAccount' %]
+            List could not be created. (Do not use the database administrator account.).
         [% CASE 'DBIx::Class::Exception' %]
             [% m.msg %]
         [% CASE %]