diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm
index 01e166370..0531980be 100644
--- a/lib/WebGUI/Asset.pm
+++ b/lib/WebGUI/Asset.pm
@@ -2282,8 +2282,6 @@ sub processEditForm {
}
}
- $self->session->log->info( Dumper \%data );
-
$self->session->db->beginTransaction;
$self->update( \%data );
$self->session->db->commit;
@@ -2939,7 +2937,7 @@ sub www_editSave {
});
if ($commitStatus eq 'redirect') {
##Redirect set by tag. Return nothing to send the user over to the redirect.
- return undef;
+ return 'redirect';
}
elsif ($commitStatus eq 'commit') {
##Commit was successful. Update the local object cache so that it will no longer
diff --git a/lib/WebGUI/Asset/File.pm b/lib/WebGUI/Asset/File.pm
index e5cafd6e8..2ad870503 100644
--- a/lib/WebGUI/Asset/File.pm
+++ b/lib/WebGUI/Asset/File.pm
@@ -628,25 +628,6 @@ sub view {
return $out;
}
-
-#-------------------------------------------------------------------
-
-=head2 www_edit
-
-Display the edit form to the user. Manually handles the template for displaying
-the inline view of the asset.
-
-=cut
-
-sub www_edit {
- my $self = shift;
- return $self->session->privilege->insufficient() unless $self->canEdit;
- return $self->session->privilege->locked() unless $self->canEditIfLocked;
- my $i18n = WebGUI::International->new($self->session);
- my $f = $self->getEditForm;
- return $self->getAdminConsole->render($f->print,$self->addEditLabel);
-}
-
#-------------------------------------------------------------------
=head2 www_view
diff --git a/lib/WebGUI/Asset/File/ZipArchive.pm b/lib/WebGUI/Asset/File/ZipArchive.pm
index 6f8a5a9c0..dd7a8fad3 100644
--- a/lib/WebGUI/Asset/File/ZipArchive.pm
+++ b/lib/WebGUI/Asset/File/ZipArchive.pm
@@ -237,24 +237,6 @@ sub view {
return $out;
}
-
-#-------------------------------------------------------------------
-
-=head2 www_edit ( )
-
-Web facing method which is the default edit page
-
-=cut
-
-sub www_edit {
- my $self = shift;
- return $self->session->privilege->insufficient() unless $self->canEdit;
- return $self->session->privilege->locked() unless $self->canEditIfLocked;
- my $i18n = WebGUI::International->new($self->session, 'Asset_Wobject');
- my $addEdit = ($self->session->form->process("func") eq 'add') ? $i18n->get('add') : $i18n->get('edit');
- return $self->getAdminConsole->render($self->getEditForm->toHtml, $self->addEditLabel);
-}
-
#-------------------------------------------------------------------
=head2 www_view ( )
diff --git a/lib/WebGUI/Asset/MatrixListing.pm b/lib/WebGUI/Asset/MatrixListing.pm
index 93cad8440..4c3f78a64 100644
--- a/lib/WebGUI/Asset/MatrixListing.pm
+++ b/lib/WebGUI/Asset/MatrixListing.pm
@@ -833,7 +833,7 @@ sub www_edit {
my $var = $self->get;
my $matrix = $self->getParent;
# TODO: Change to FormBuilder
- $var->{form} = $self->getEditForm->print;
+ $var->{form} = $self->getEditForm->toHtml;
return $matrix->processStyle($self->processTemplate($var,$matrix->get("editListingTemplateId")));
}
diff --git a/lib/WebGUI/Asset/Post.pm b/lib/WebGUI/Asset/Post.pm
index d5598cdce..c214c8f25 100644
--- a/lib/WebGUI/Asset/Post.pm
+++ b/lib/WebGUI/Asset/Post.pm
@@ -1128,6 +1128,7 @@ override processEditForm => sub {
}
delete $self->{_storageLocation};
$self->postProcess;
+ return;
};
@@ -1593,7 +1594,7 @@ sub www_edit {
});
$var{'form.header'} .= WebGUI::Form::hidden($session, {
name=>"revision",
- value=>$form->param("revision")
+ value=>$form->param("revision") || $self->revisionDate
});
$var{'form.header'} .= WebGUI::Form::hidden($session, {
name=>"ownerUserId",
diff --git a/lib/WebGUI/Asset/Redirect.pm b/lib/WebGUI/Asset/Redirect.pm
index e4667d561..2ea2b5f69 100644
--- a/lib/WebGUI/Asset/Redirect.pm
+++ b/lib/WebGUI/Asset/Redirect.pm
@@ -122,12 +122,14 @@ sub www_view {
my $url = $self->redirectUrl;
WebGUI::Macro::process($self->session, \$url);
if ($self->session->isAdminOn() && $self->canEdit) {
- return $self->getAdminConsole->render($i18n->get("what do you want to do with this redirect").'
+ return '
' . $i18n->get('assetName') . '
'
+ . $i18n->get("what do you want to do with this redirect").'
',$i18n->get("assetName"));
+ '
+ ;
}
unless ($url eq $self->url) {
$self->session->response->setRedirect($url,$self->redirectType);
diff --git a/lib/WebGUI/Asset/Wobject/Carousel.pm b/lib/WebGUI/Asset/Wobject/Carousel.pm
index dd7469a60..61078cf61 100644
--- a/lib/WebGUI/Asset/Wobject/Carousel.pm
+++ b/lib/WebGUI/Asset/Wobject/Carousel.pm
@@ -94,14 +94,11 @@ override getEditForm => sub {
$self->session->style->setScript($self->session->url->extras('wobject/Carousel/carousel.js'), {type =>
'text/javascript'});
- my $tableRowStart =
- ''
- .' '.$i18n->get("items description").' | '
- .' '
- .' '
- .' '
- ." \n";
+ my $tableRowStart = ' '.$i18n->get("items description").' '
+ . ' '
+ . ' '
+ . " \n";
$tabform->getTab("properties")->addField('ReadOnly', value => $tableRowStart);
@@ -161,7 +158,7 @@ onClick='javascript:deleteItem(this.id)'>\n"
$items = JSON->new->encode( $items );
my $i18nJson = JSON->new->encode( { "delete" => $i18n->get("delete") } );
- $tabform->getTab('properties')->raw(<<"ENDHTML");
+ $tabform->getTab('properties')->addField( "ReadOnly", name => 'editor', value => <<"ENDHTML");
ENDHTML
- my $tableRowEnd = qq|
- |
-
- |;
- $tabform->getTab("properties")->addField('ReadOnly', value => $tableRowEnd);
-
return $tabform;
};
diff --git a/lib/WebGUI/International.pm b/lib/WebGUI/International.pm
index a9b55bddb..23cdac7d9 100644
--- a/lib/WebGUI/International.pm
+++ b/lib/WebGUI/International.pm
@@ -204,7 +204,6 @@ sub getLanguages {
my ($self) = @_;
my $hashRef;
for my $lang ( findsubmod 'WebGUI::i18n' ) {
- $self->session->log->info( "Found language $lang" );
$lang =~ s/^WebGUI::i18n:://;
$hashRef->{$lang} = $self->getLanguage($lang, "label");
}
diff --git a/lib/WebGUI/Role/Asset/Dashlet.pm b/lib/WebGUI/Role/Asset/Dashlet.pm
index 4c3f0a3d5..cf50278c3 100644
--- a/lib/WebGUI/Role/Asset/Dashlet.pm
+++ b/lib/WebGUI/Role/Asset/Dashlet.pm
@@ -1,6 +1,7 @@
package WebGUI::Role::Asset::Dashlet;
use Moose::Role;
+use JSON;
=head1 NAME
@@ -38,7 +39,7 @@ sub fetchUserOverrides {
my $userId = shift || $self->session->user->userId;
my $properties_json = $self->session->db->quickScalar('select properties from Dashboard_userPrefs where dashboardAssetId=? and userId=? and dashletAssetId=?',[$dashboardAssetId, $userId, $self->getId,]);
$properties_json ||= '{}';
- my $properties = from_json($properties_json);
+ my $properties = JSON->new->decode($properties_json);
return $properties;
}
@@ -115,7 +116,7 @@ sub storeUserOverrides {
my $dashboardAssetId = shift;
my $properties = shift;
my $userId = shift || $session->user->userId;
- my $properties_json = to_json($properties);
+ my $properties_json = JSON->new->encode($properties);
$session->db->write('DELETE FROM Dashboard_userPrefs where dashboardAssetId=? and userId=? and dashletAssetId=?',[$dashboardAssetId, $userId, $self->getId]);
$session->db->write('INSERT INTO Dashboard_userPrefs (dashboardAssetId, userId, dashletAssetId, properties) VALUES (?,?,?,?)', [$dashboardAssetId, $userId, $self->getId, $properties_json]);
}
diff --git a/t/tests/Test/WebGUI/Asset.pm b/t/tests/Test/WebGUI/Asset.pm
index f311d4fce..1a50ff5d8 100644
--- a/t/tests/Test/WebGUI/Asset.pm
+++ b/t/tests/Test/WebGUI/Asset.pm
@@ -20,6 +20,10 @@ use Test::Exception;
use WebGUI::Test;
use Data::Dumper;
use List::MoreUtils;
+use WebGUI::Test::Mechanize;
+
+use UNIVERSAL::isa;
+no warnings 'UNIVERSAL::isa';
# XXXX fix the Test(n) numbers to match reality
@@ -109,16 +113,25 @@ sub getAnchoredAsset {
status => "pending",
tagId => $tag->getId,
$test->constructorExtras($session),
- }, undef, undef, {skipNotification => 1});
+ }, undef, (time-10), {skipNotification => 1});
# warn "XXX getAnchoredAsset: created new asset of Id: " . $asset->getId . ' of type: ' . ref $asset;
$tag->commit;
foreach my $a ($asset, @parents) {
$a = $a->cloneFromDb;
}
WebGUI::Test->addToCleanup($tag);
+ $test->{_currentTag} = $tag;
return ($tag, $asset, @parents);
}
+sub deleteAssets : Test(teardown) {
+ my ( $test ) = shift;
+ if ( $test->{_currentTag} ) {
+ $test->{_currentTag}->rollback;
+ delete $test->{_currentTag};
+ }
+}
+
sub getMyParents {
my $test = shift;
my $session = $test->session;
@@ -127,17 +140,17 @@ sub getMyParents {
my $default = WebGUI::Asset->getDefault($session);
push @parents, $default;
my $parent = $default;
- my $tag = WebGUI::VersionTag->getWorking($session);
+ my $tag = WebGUI::VersionTag->getWorking( $session );
foreach my $parent_class (@{ $parent_classes }) {
my $new_parent = $parent->addChild(
{
className => $parent_class,
- status => "pending",
- tagId => $tag->getId,
$test->constructorExtras($session),
+ status => 'pending',
+ tagId => $tag->getId,
},
undef,
- undef,
+ (time-10),
{skipNotification => 1,},
);
push @parents, $new_parent;
@@ -564,8 +577,6 @@ sub t_20_www_editSave : Tests {
$asset->groupIdEdit( 7 ); # Everybody! Everybody!
$asset->commit;
- $tag->setWorking;
- sleep 2; # XXXX Todo -- investigate whether this is actually fixing duplicate commit problems
my %mergedProperties = (
formProperties($asset),
@@ -577,15 +588,28 @@ sub t_20_www_editSave : Tests {
# local $SIG{__DIE__} = sub { use Carp; Carp::confess "@_"; };
# local $SIG{__DIE__} = sub { use wth; wth::wth "@_"; }; # see note above about wth
- $session->request->setup_body( \%mergedProperties );
+ my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->file );
+ $mech->get('/');
+ $mech->session->user({ userId => 3 });
+ $tag = WebGUI::VersionTag->getWorking( $mech->session );
+ $tag->setWorking;
+ $mech->get_ok( $asset->getUrl('func=edit') );
- my $content;
- ok(eval { $asset->www_editSave; }, 'www_editSave returns true');
- debug($@);
- undef $@;
+ my $form_content = $mech->content;
+ if ( $test->isa( 'Test::WebGUI::Asset::File::GalleryFile::Photo' )
+ || $test->isa( 'Test::WebGUI::Asset::Wobject::GalleryAlbum' )
+ || $test->isa( 'Test::WebGUI::Asset::Event' )
+ ) {
+ $session->log->info( $form_content );
+ }
+ $mech->submit_form_ok( {
+ fields => \%mergedProperties,
+ },
+ "submit www_editSave form"
+ );
# Get the newly-created revision of the asset
- ok( my $newRevision = eval { WebGUI::Asset->newPending( $session, $asset->getId ); }, 'newPending returns true' );
+ ok( my $newRevision = eval { WebGUI::Asset->newPending( $mech->session, $asset->getId ); }, 'newPending returns true' );
debug($@);
undef $@;
diff --git a/t/tests/Test/WebGUI/Asset/Event.pm b/t/tests/Test/WebGUI/Asset/Event.pm
index deba5498a..1eda2a821 100644
--- a/t/tests/Test/WebGUI/Asset/Event.pm
+++ b/t/tests/Test/WebGUI/Asset/Event.pm
@@ -24,4 +24,10 @@ sub parent_list {
return ['WebGUI::Asset::Wobject::Calendar'];
}
+sub postProcessMergedProperties {
+ my ( $test, $props ) = @_;
+ $props->{startDate} = "2010-01-01";
+ $props->{endDate} = "2010-01-02";
+}
+
1;
diff --git a/t/tests/Test/WebGUI/Asset/Post.pm b/t/tests/Test/WebGUI/Asset/Post.pm
index 11934761b..58c6be534 100644
--- a/t/tests/Test/WebGUI/Asset/Post.pm
+++ b/t/tests/Test/WebGUI/Asset/Post.pm
@@ -25,4 +25,9 @@ sub parent_list {
return [ map { "WebGUI::Asset::$_"} qw/Wobject::Collaboration Post::Thread/ ];
}
+sub postProcessMergedProperties {
+ my ( $test, $props ) = @_;
+ $props->{func} = "editSave"; # func defaults to preview mode
+}
+
1;
diff --git a/t/tests/Test/WebGUI/Asset/Snippet.pm b/t/tests/Test/WebGUI/Asset/Snippet.pm
index 9c5ec70e8..5846445f3 100644
--- a/t/tests/Test/WebGUI/Asset/Snippet.pm
+++ b/t/tests/Test/WebGUI/Asset/Snippet.pm
@@ -25,4 +25,9 @@ sub list_of_tables {
return [qw/assetData snippet/];
}
+sub postProcessMergedProperties {
+ my ( $test, $props ) = @_;
+ $props->{snippet} = "some text";
+}
+
1;
diff --git a/t/tests/Test/WebGUI/Asset/Wobject/Carousel.pm b/t/tests/Test/WebGUI/Asset/Wobject/Carousel.pm
index bbfa30a66..3af26a21c 100644
--- a/t/tests/Test/WebGUI/Asset/Wobject/Carousel.pm
+++ b/t/tests/Test/WebGUI/Asset/Wobject/Carousel.pm
@@ -21,4 +21,17 @@ sub list_of_tables {
return [qw/assetData wobject Carousel/];
}
+sub postProcessMergedProperties {
+ my ( $test, $props ) = @_;
+ $props->{something} = JSON->new->encode({
+ items => [
+ {
+ sequenceNumber => 1,
+ text => "Item 1",
+ },
+ ],
+ });
+ return $props;
+}
+
1;
diff --git a/t/tests/Test/WebGUI/Asset/Wobject/GalleryAlbum.pm b/t/tests/Test/WebGUI/Asset/Wobject/GalleryAlbum.pm
index 0255eaf90..6cf342473 100644
--- a/t/tests/Test/WebGUI/Asset/Wobject/GalleryAlbum.pm
+++ b/t/tests/Test/WebGUI/Asset/Wobject/GalleryAlbum.pm
@@ -25,4 +25,9 @@ sub parent_list {
return [qw/WebGUI::Asset::Wobject::Gallery/];
}
+sub postProcessMergedProperties {
+ my ( $test, $props ) = @_;
+ $props->{save} = "save"; # GalleryAlbum www_edit checks for this to go to editSave
+}
+
1;
diff --git a/t/tests/Test/WebGUI/Asset/Wobject/SQLReport.pm b/t/tests/Test/WebGUI/Asset/Wobject/SQLReport.pm
index df6ba5893..ca4939d66 100644
--- a/t/tests/Test/WebGUI/Asset/Wobject/SQLReport.pm
+++ b/t/tests/Test/WebGUI/Asset/Wobject/SQLReport.pm
@@ -25,4 +25,9 @@ sub list_of_tables {
return [qw/assetData wobject SQLReport/];
}
+sub postProcessMergedProperties {
+ my ( $test, $props ) = @_;
+ $props->{dbQuery1} = "SELECT * FROM users";
+}
+
1;