From be33a59e90fcdda9f769731020313d304184a1e6 Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Mon, 25 Apr 2011 16:30:34 -0500 Subject: [PATCH] add messageboard to test_content and fix revealed problems --- lib/WebGUI/Asset/Wobject/MessageBoard.pm | 11 ++- lib/WebGUI/Command/test_content.pm | 121 +++++++++++++++++++++-- 2 files changed, 121 insertions(+), 11 deletions(-) diff --git a/lib/WebGUI/Asset/Wobject/MessageBoard.pm b/lib/WebGUI/Asset/Wobject/MessageBoard.pm index 18abd73ff..6a1e42385 100644 --- a/lib/WebGUI/Asset/Wobject/MessageBoard.pm +++ b/lib/WebGUI/Asset/Wobject/MessageBoard.pm @@ -50,8 +50,8 @@ See WebGUI::Asset::prepareView() for details. sub prepareView { my $self = shift; $self->SUPER::prepareView(); - my $template = WebGUI::Asset::Template->newById($self->session, $self->templateId); - if (!$template) { + my $template = eval{ WebGUI::Asset::Template->newById($self->session, $self->templateId) }; + if ($@ or !$template) { WebGUI::Error::ObjectNotFound::Template->throw( error => qq{Template not found}, templateId => $self->templateId, @@ -111,8 +111,11 @@ sub view { $first = $child; } my %lastPostVars; - my $lastPost = WebGUI::Asset::Wobject::MessageBoard->newById($self->session, $child->lastPostId); - if (defined $lastPost) { + if ( $child->lastPostId ) { + my $lastPost = eval { WebGUI::Asset->newById($self->session, $child->lastPostId) }; + if ( $@ ) { + $self->session->log->error( "Could not instance " . $child->lastPostId . ": " . $@ ); + } %lastPostVars = ( 'forum.lastPost.url' => $lastPost->getUrl, 'forum.lastPost.date' => $self->session->datetime->epochToHuman($lastPost->creationDate,"%z"), diff --git a/lib/WebGUI/Command/test_content.pm b/lib/WebGUI/Command/test_content.pm index 882346ce7..bc86b5d7e 100644 --- a/lib/WebGUI/Command/test_content.pm +++ b/lib/WebGUI/Command/test_content.pm @@ -132,6 +132,7 @@ sub buildAsset { my $files = $rawprops->{_files} || []; my $children = $rawprops->{_children} || []; my $props = { map { $_ => $rawprops->{$_} } grep { !/^_/ } keys %$rawprops }; + $props->{ styleTemplateId } ||= $page->can( 'styleTemplateId' ) ? $page->styleTemplateId : ''; my $asset = $page->addChild({ className => $class, @@ -461,12 +462,12 @@ my $DT_NOW = DateTime->now; ], }, ], - }, - ], - _files => [ - { - property => 'storageId', - file => catfile( WebGUI::Paths->extras, 'wg.png' ), + _files => [ + { + property => 'storageId', + file => catfile( WebGUI::Paths->extras, 'wg.png' ), + }, + ], }, ], }, @@ -626,7 +627,113 @@ my $DT_NOW = DateTime->now; } ], 'WebGUI::Asset::Wobject::MessageBoard' => [ - + { + title => 'Message Board', + isHidden => 1, + _children => [ + { + className => 'WebGUI::Asset::Wobject::Collaboration', + title => 'Logos', + isHidden => 1, + postFormTemplateId => 'PBtmpl0000000000000029', + threadTemplateId => 'PBtmpl0000000000000032', + collaborationTemplateId => 'PBtmpl0000000000000026', + _children => [ + { + className => 'WebGUI::Asset::Post::Thread', + title => 'Thread', + content => lorem(0,1,2), + synopsis => lorem(0), + _children => [ + { + className => 'WebGUI::Asset::Post', + title => "Post", + content => lorem(3,4,5), + _files => [ + { + property => 'storageId', + file => catfile( WebGUI::Paths->extras, 'plainblack.gif' ), + }, + ], + }, + ], + _files => [ + { + property => 'storageId', + file => catfile( WebGUI::Paths->extras, 'wg.png' ), + }, + ], + }, + ], + }, + { + title => 'Icons', + _children => [ + { + className => 'WebGUI::Asset::Post::Thread', + title => 'Clock', + content => lorem(0,1,2), + synopsis => lorem(0), + _children => [ + { + className => 'WebGUI::Asset::Post', + title => "Camera", + content => lorem(3,4,5), + _files => [ + { + property => 'storageId', + file => catfile( WebGUI::Paths->extras, 'icon', 'camera.png' ), + }, + ], + }, + ], + _files => [ + { + property => 'storageId', + file => catfile( WebGUI::Paths->extras, 'icon', 'clock.png' ), + }, + ], + }, + { + className => 'WebGUI::Asset::Post::Thread', + title => 'Brick', + content => lorem(0,1,2), + synopsis => lorem(0), + _files => [ + { + property => 'storageId', + file => catfile( WebGUI::Paths->extras, 'icon', 'brick.png' ), + }, + ], + }, + { + className => 'WebGUI::Asset::Post::Thread', + title => 'Cog', + content => lorem(0,1,2), + synopsis => lorem(0), + _files => [ + { + property => 'storageId', + file => catfile( WebGUI::Paths->extras, 'icon', 'cog.png' ), + }, + ], + }, + { + className => 'WebGUI::Asset::Post::Thread', + title => 'Bug', + content => lorem(0,1,2), + synopsis => lorem(0), + _files => [ + { + property => 'storageId', + file => catfile( WebGUI::Paths->extras, 'icon', 'bug.png' ), + }, + ], + }, + ], + }, + ], + }, ], 'WebGUI::Asset::Wobject::Collaboration::Newsletter' => [