fixes to the Gallery
This commit is contained in:
parent
99274cd4ee
commit
53a1cbc7c2
8 changed files with 72 additions and 27 deletions
|
|
@ -159,6 +159,19 @@ sub applyConstraints {
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 canAdd ( )
|
||||||
|
|
||||||
|
Override canAdd to ignore its permissions check. Permissions are handled
|
||||||
|
by the parent Gallery and other permissions methods.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub canAdd {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 canComment ( [userId] )
|
=head2 canComment ( [userId] )
|
||||||
|
|
||||||
Returns true if the user can comment on this asset. C<userId> is a WebGUI
|
Returns true if the user can comment on this asset. C<userId> is a WebGUI
|
||||||
|
|
@ -556,12 +569,21 @@ sub prepareView {
|
||||||
|
|
||||||
sub processPropertiesFromFormPost {
|
sub processPropertiesFromFormPost {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
my $form = $self->session->form;
|
||||||
my $errors = $self->SUPER::processPropertiesFromFormPost || [];
|
my $errors = $self->SUPER::processPropertiesFromFormPost || [];
|
||||||
|
|
||||||
# Return if errors
|
# Return if errors
|
||||||
return $errors if @$errors;
|
return $errors if @$errors;
|
||||||
|
|
||||||
# Passes all checks
|
### Passes all checks
|
||||||
|
# Fix if adding a new photo
|
||||||
|
if ( $form->get("assetId") eq "new" ) {
|
||||||
|
$self->update({
|
||||||
|
ownerUserId => $self->session->user->userId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$self->requestAutoCommit;
|
$self->requestAutoCommit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -447,12 +447,24 @@ check. If no userId is passed, will check the current user.
|
||||||
|
|
||||||
Users can edit this gallery if they are part of the C<groupIdEdit> group.
|
Users can edit this gallery if they are part of the C<groupIdEdit> group.
|
||||||
|
|
||||||
|
Also checks if a user is adding a GalleryAlbum and allows them to if they are
|
||||||
|
part of the C<groupIdAddFile> group.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub canEdit {
|
sub canEdit {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $userId = shift;
|
my $userId = shift;
|
||||||
|
|
||||||
|
my $form = $self->session->form;
|
||||||
|
|
||||||
|
if ( $form->get('func') eq "add" ) {
|
||||||
|
return $self->canAddFile( $userId );
|
||||||
|
}
|
||||||
|
elsif ( $form->get('func') eq "editSave" && $form->get('assetId') eq "new" ) {
|
||||||
|
return $self->canAddFile( $userId );
|
||||||
|
}
|
||||||
|
else {
|
||||||
my $user = $userId
|
my $user = $userId
|
||||||
? WebGUI::User->new( $self->session, $userId )
|
? WebGUI::User->new( $self->session, $userId )
|
||||||
: $self->session->user
|
: $self->session->user
|
||||||
|
|
@ -460,6 +472,7 @@ sub canEdit {
|
||||||
|
|
||||||
return $user->isInGroup( $self->get("groupIdEdit") );
|
return $user->isInGroup( $self->get("groupIdEdit") );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -165,6 +165,19 @@ sub appendTemplateVarsFileLoop {
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 canAdd ( )
|
||||||
|
|
||||||
|
Override canAdd to ignore its permissions check. Permissions are handled
|
||||||
|
by the parent Gallery and other permissions methods.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub canAdd {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 canAddFile ( [userId] )
|
=head2 canAddFile ( [userId] )
|
||||||
|
|
||||||
Returns true if the user can add a file to this album. C<userId> is a WebGUI
|
Returns true if the user can add a file to this album. C<userId> is a WebGUI
|
||||||
|
|
@ -467,12 +480,20 @@ approval workflow.
|
||||||
|
|
||||||
sub processPropertiesFromFormPost {
|
sub processPropertiesFromFormPost {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
my $form = $self->session->form;
|
||||||
my $errors = $self->SUPER::processPropertiesFromFormPost || [];
|
my $errors = $self->SUPER::processPropertiesFromFormPost || [];
|
||||||
|
|
||||||
# Return if error
|
# Return if error
|
||||||
return $errors if @$errors;
|
return $errors if @$errors;
|
||||||
|
|
||||||
# Passes all checks
|
### Passes all checks
|
||||||
|
# Fix if adding a new GalleryAlbum
|
||||||
|
if ( $form->get('assetId') eq "new" ) {
|
||||||
|
$self->update({
|
||||||
|
ownerUserId => $self->session->user->userId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$self->requestAutoCommit;
|
$self->requestAutoCommit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,7 @@ our $HELP = {
|
||||||
namespace => 'Asset_GalleryAlbum',
|
namespace => 'Asset_GalleryAlbum',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
variables => [ ],
|
||||||
},
|
},
|
||||||
|
|
||||||
'help slideshow' => {
|
'help slideshow' => {
|
||||||
|
|
@ -134,6 +135,7 @@ our $HELP = {
|
||||||
namespace => 'Asset_GalleryAlbum',
|
namespace => 'Asset_GalleryAlbum',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
variables => [ ],
|
||||||
},
|
},
|
||||||
|
|
||||||
'help thumbnails' => {
|
'help thumbnails' => {
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,11 @@ use WebGUI::Session;
|
||||||
use WebGUI::Image;
|
use WebGUI::Image;
|
||||||
use WebGUI::Storage::Image;
|
use WebGUI::Storage::Image;
|
||||||
use WebGUI::Asset::File::Image;
|
use WebGUI::Asset::File::Image;
|
||||||
|
use WebGUI::Form::File;
|
||||||
|
|
||||||
use Test::More; # increment this value for each test you create
|
use Test::More; # increment this value for each test you create
|
||||||
use Test::Deep;
|
use Test::Deep;
|
||||||
plan tests => 8;
|
plan tests => 7;
|
||||||
|
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
|
|
||||||
|
|
@ -75,15 +76,8 @@ is($storage->getId, $asset->getStorageLocation->getId, 'Cached Asset storage loc
|
||||||
|
|
||||||
$versionTag->commit;
|
$versionTag->commit;
|
||||||
|
|
||||||
my $imageStorage = WebGUI::Storage::Image->create($session);
|
|
||||||
$mocker->set_always('getValueFromPost', $imageStorage->getId);
|
|
||||||
my $imageFormStorage = $asset->getStorageFromPost();
|
|
||||||
isa_ok($imageFormStorage, 'WebGUI::Storage::Image', 'Asset::Image::getStorageFromPost');
|
|
||||||
|
|
||||||
END {
|
END {
|
||||||
if (defined $versionTag and ref $versionTag eq 'WebGUI::VersionTag') {
|
if (defined $versionTag and ref $versionTag eq 'WebGUI::VersionTag') {
|
||||||
$versionTag->rollback;
|
$versionTag->rollback;
|
||||||
}
|
}
|
||||||
##Storage is cleaned up by rolling back the version tag
|
|
||||||
$imageStorage->delete;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,11 +50,10 @@ END {
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Tests
|
# Tests
|
||||||
plan tests => 10;
|
plan tests => 9;
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Test shortcut's link to original asset
|
# Test shortcut's link to original asset
|
||||||
# plan => 3
|
|
||||||
my $original = $shortcut->getShortcut;
|
my $original = $shortcut->getShortcut;
|
||||||
|
|
||||||
ok(
|
ok(
|
||||||
|
|
@ -74,7 +73,6 @@ is(
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Test trashing snippet trashes shortcut also
|
# Test trashing snippet trashes shortcut also
|
||||||
# plan tests => 3
|
|
||||||
$snippet->trash;
|
$snippet->trash;
|
||||||
$shortcut = WebGUI::Asset->newByDynamicClass($session, $shortcut->getId);
|
$shortcut = WebGUI::Asset->newByDynamicClass($session, $shortcut->getId);
|
||||||
|
|
||||||
|
|
@ -95,7 +93,6 @@ ok(
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Test restoring snippet restores shortcut also
|
# Test restoring snippet restores shortcut also
|
||||||
# plan tests => 3
|
|
||||||
$snippet->publish;
|
$snippet->publish;
|
||||||
$shortcut = WebGUI::Asset->newByDynamicClass($session, $shortcut->getId);
|
$shortcut = WebGUI::Asset->newByDynamicClass($session, $shortcut->getId);
|
||||||
|
|
||||||
|
|
@ -111,7 +108,6 @@ ok(
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Test purging snippet purges shortcut also
|
# Test purging snippet purges shortcut also
|
||||||
# plan tests => 2
|
|
||||||
$snippet->purge;
|
$snippet->purge;
|
||||||
$shortcut = WebGUI::Asset->newByDynamicClass($session, $shortcut->getId);
|
$shortcut = WebGUI::Asset->newByDynamicClass($session, $shortcut->getId);
|
||||||
|
|
||||||
|
|
@ -120,7 +116,3 @@ ok(
|
||||||
"Purge Linked Asset: Shortcut is not defined",
|
"Purge Linked Asset: Shortcut is not defined",
|
||||||
);
|
);
|
||||||
|
|
||||||
ok(
|
|
||||||
!grep({ $_->getId eq $shortcut->getId } @{ $snippet->getAssetsInTrash }),
|
|
||||||
"Purge Linked Asset: Shortcut is not in trash",
|
|
||||||
);
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ my $session = WebGUI::Test->session;
|
||||||
|
|
||||||
my ($extensionTests, $fileIconTests) = setupDataDrivenTests($session);
|
my ($extensionTests, $fileIconTests) = setupDataDrivenTests($session);
|
||||||
|
|
||||||
my $numTests = 77; # increment this value for each test you create
|
my $numTests = 80; # increment this value for each test you create
|
||||||
plan tests => $numTests + scalar @{ $extensionTests } + scalar @{ $fileIconTests };
|
plan tests => $numTests + scalar @{ $extensionTests } + scalar @{ $fileIconTests };
|
||||||
|
|
||||||
my $uploadDir = $session->config->get('uploadsPath');
|
my $uploadDir = $session->config->get('uploadsPath');
|
||||||
|
|
@ -262,8 +262,9 @@ cmp_bag($s3copy->getFiles(), [ @filesToCopy ], 'copy: passing explicit variable
|
||||||
#
|
#
|
||||||
####################################################
|
####################################################
|
||||||
|
|
||||||
is(scalar @{ $storage1->getFiles}, 3, 'storage1 has 2 files');
|
is(scalar @{ $storage1->getFiles }, 4, 'storage1 has 4 files');
|
||||||
is($storage1->deleteFile("testfile-hash-renamed.file"), 1, 'deleteFile: deleted 1 file');
|
is($storage1->deleteFile("testfile-hash-renamed.file"), 1, 'deleteFile: deleted 1 file');
|
||||||
|
is($storage1->deleteFile("testfile-hash-copied.file"), 1, 'deleteFile: deleted 1 file');
|
||||||
is($storage1->deleteFile("WebGUI.pm"), 1, 'deleteFile: deleted another file');
|
is($storage1->deleteFile("WebGUI.pm"), 1, 'deleteFile: deleted another file');
|
||||||
cmp_bag($storage1->getFiles, [$filename], 'deleteFile: storage1 has only 1 file');
|
cmp_bag($storage1->getFiles, [$filename], 'deleteFile: storage1 has only 1 file');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ is($thumbStore->getThumbnailUrl(), '', 'getThumbnailUrl returns undef if no file
|
||||||
is($WebGUI::Test::logger_error, q/Can't make a thumbnail url without a filename./, 'getThumbnailUrl logs an error message for not sending a filename');
|
is($WebGUI::Test::logger_error, q/Can't make a thumbnail url without a filename./, 'getThumbnailUrl logs an error message for not sending a filename');
|
||||||
|
|
||||||
is($thumbStore->getThumbnailUrl('round.png'), '', 'getThumbnailUrl returns undef if the requested file is not in the storage location');
|
is($thumbStore->getThumbnailUrl('round.png'), '', 'getThumbnailUrl returns undef if the requested file is not in the storage location');
|
||||||
is($WebGUI::Test::logger_error, q/Can't make a thumbnail for a file that is not in my storage location./, 'getThumbnailUrl logs an error message for not sending a filename');
|
is($WebGUI::Test::logger_error, q/Can't make a thumbnail for a file named 'round.png' that is not in my storage location./, 'getThumbnailUrl logs an error message for not sending a filename');
|
||||||
|
|
||||||
is($thumbStore->getThumbnailUrl('square.png'), $thumbStore->getUrl('thumb-square.png'), 'getThumbnailUrl returns the correct url');
|
is($thumbStore->getThumbnailUrl('square.png'), $thumbStore->getUrl('thumb-square.png'), 'getThumbnailUrl returns the correct url');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue