fixed a bunch of GalleryAlbum/Photo tests
This commit is contained in:
parent
6dfe05b119
commit
af271b9f26
13 changed files with 225 additions and 248 deletions
|
|
@ -17,7 +17,7 @@ package WebGUI::Asset::File::Image::Photo;
|
|||
use strict;
|
||||
use base 'WebGUI::Asset::File::Image';
|
||||
|
||||
use Carp qw( croak );
|
||||
use Carp qw( carp croak );
|
||||
use Image::ExifTool qw( :Public );
|
||||
use JSON;
|
||||
use Tie::IxHash;
|
||||
|
|
@ -38,6 +38,18 @@ WebGUI::Asset::File::Image::Photo
|
|||
|
||||
use WebGUI::Asset::File::Image::Photo
|
||||
|
||||
=head1 DIAGNOSTICS
|
||||
|
||||
=head2 Geometry '...' is invalid. Skipping.
|
||||
|
||||
makeResolutions will not pass invalid geometries to WebGUI::Storage::Image::resize().
|
||||
Valid geometries are one of the following forms:
|
||||
|
||||
^\d+$
|
||||
^\d*x\d*$
|
||||
|
||||
These geometries are exactly as understood by ImageMagick.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
|
@ -232,9 +244,10 @@ sub canView {
|
|||
my $album = $self->getParent;
|
||||
return 0 unless $album->canView($userId);
|
||||
|
||||
if ($self->isFriendsOnly) {
|
||||
if ($self->isFriendsOnly && $userId != $self->get("ownerUserId") ) {
|
||||
my $owner = WebGUI::User->new( $self->session, $self->get("ownerUserId") );
|
||||
return 0
|
||||
unless WebGUI::Friends->new($self->session, $self->get("ownerUserId"))->isFriend($userId);
|
||||
unless WebGUI::Friends->new($self->session, $owner)->isFriend($userId);
|
||||
}
|
||||
|
||||
# Passed all checks
|
||||
|
|
@ -499,6 +512,10 @@ sub makeResolutions {
|
|||
|
||||
for my $res ( @$resolutions ) {
|
||||
# carp if resolution is bad
|
||||
if ( $res !~ /^\d+$/ && $res !~ /^\d*x\d*/ ) {
|
||||
carp "Geometry '$res' is invalid. Skipping.";
|
||||
next;
|
||||
}
|
||||
my $newFilename = $res . ".jpg";
|
||||
$storage->copyFile( $self->get("filename"), $newFilename );
|
||||
$storage->resize( $newFilename, $res );
|
||||
|
|
@ -712,6 +729,7 @@ sub www_addCommentSave {
|
|||
|
||||
return $session->privilege->insufficient unless $self->canComment;
|
||||
|
||||
my $i18n = __PACKAGE__->i18n( $session );
|
||||
my $form = $self->session->form;
|
||||
|
||||
my $properties = {
|
||||
|
|
@ -724,7 +742,9 @@ sub www_addCommentSave {
|
|||
|
||||
$self->setComment( "new", $properties );
|
||||
|
||||
return $self->www_view;
|
||||
return $self->processStyle(
|
||||
sprintf $i18n->get('comment message'), $self->getUrl,
|
||||
);
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -717,10 +717,13 @@ sub www_deleteConfirm {
|
|||
return $self->session->privilege->insufficient unless $self->canEdit;
|
||||
|
||||
my $gallery = $self->getParent;
|
||||
my $i18n = __PACKAGE__->i18n( $self->session );
|
||||
|
||||
$self->purge;
|
||||
|
||||
return $gallery->www_view;
|
||||
return $self->processStyle(
|
||||
sprintf $i18n->get('delete message'), $self->getParent->getUrl,
|
||||
);
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -185,10 +185,10 @@ attached to the session.
|
|||
=cut
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $user = shift || $session->user;
|
||||
my $self = register($class);
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $user = shift || $session->user;
|
||||
my $self = register($class);
|
||||
$session{id $self} = $session;
|
||||
$user{id $self} = $user;
|
||||
return $self;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@ our $I18N = {
|
|||
message => 'Album settings saved. <a href="%s">Return to Album</a>',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
'delete message' => {
|
||||
message => 'Album has been deleted. <a href="%s">Return to Gallery</a>',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help common title' => {
|
||||
message => '',
|
||||
|
|
|
|||
|
|
@ -16,6 +16,11 @@ our $I18N = {
|
|||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'comment message' => {
|
||||
message => q{Your comment has been added. <a href="%s">Back to Photo</a>.},
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help commentForm title' => {
|
||||
message => 'Photo -- Comment Form',
|
||||
lastUpdated => 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue