diff --git a/docs/upgrades/upgrade_7.6.14-7.7.0.pl b/docs/upgrades/upgrade_7.6.14-7.7.0.pl index cca5a47f3..ebdf27625 100644 --- a/docs/upgrades/upgrade_7.6.14-7.7.0.pl +++ b/docs/upgrades/upgrade_7.6.14-7.7.0.pl @@ -32,9 +32,6 @@ my $quiet; # this line required my $session = start(); # this line required # upgrade functions go here -installStoryManagerTables($session); -upgradeConfigFiles($session); - addGroupToAddToMatrix( $session ); addScreenshotTemplatesToMatrix( $session ); surveyDoAfterTimeLimit($session); @@ -42,6 +39,10 @@ surveyRemoveResponseTemplate($session); surveyEndWorkflow($session); installAssetHistory($session); +# Story Manager +installStoryManagerTables($session); +upgradeConfigFiles($session); + # Passive Analytics pa_installLoggingTables($session); pa_installPassiveAnalyticsRule($session); @@ -364,6 +365,7 @@ CREATE TABLE StoryTopic ( revisionDate BIGINT NOT NULL, storiesPer INTEGER, storiesShort INTEGER, + templateId CHAR(22) BINARY, storyTemplateId CHAR(22) BINARY, PRIMARY KEY ( assetId, revisionDate ) ) diff --git a/lib/WebGUI/Asset/Wobject/StoryTopic.pm b/lib/WebGUI/Asset/Wobject/StoryTopic.pm index 914ba7d22..de46ab5c0 100644 --- a/lib/WebGUI/Asset/Wobject/StoryTopic.pm +++ b/lib/WebGUI/Asset/Wobject/StoryTopic.pm @@ -53,6 +53,15 @@ sub definition { hoverHelp => $i18n->get('stories short help'), defaultValue => 5, }, + templateId => { + tab => 'display', + fieldType => 'template', + label => $i18n->get('template'), + hoverHelp => $i18n->get('template help'), + filter => 'fixId', + namespace => 'Story', + defaultValue => 'liNZSK4xWGyALU6nu_criw', + }, storyTemplateId => { tab => 'display', fieldType => 'template', @@ -146,14 +155,24 @@ sub viewTemplateVariables { STORY: foreach my $storyId (@{ $storyIds }) { my $story = WebGUI::Asset->new($session, $storyId->{assetId}, $storyId->{className}, $storyId->{revisionDate}); next STORY unless $story; - my $creationDate = $story->get('creationDate'); push @{$var->{story_loop}}, { url => $session->url->append($self->getUrl, 'func=viewStory;assetId='.$storyId->{assetId}), title => $story->getTitle, - creationDate => $creationDate, + creationDate => $story->get('creationDate'), } } + if ($self->{_standAlone}) { + my $topStoryData = $storyIds->[0]; + shift @{ $var->{story_loop} }; + ##Note, this could have saved from the loop above, but this looks more clean and encapsulated to me. + my $topStory = WebGUI::Asset->new($session, $topStoryData->{assetId}, $topStoryData->{className}, $topStoryData->{revisionDate}); + $var->{topStoryTitle} = $topStory->getTitle; + $var->{topStoryUrl} = $session->url->append($self->getUrl, 'func=viewStory;assetId='.$topStoryData->{assetId}), + $var->{topStoryCreationDate} = $topStory->get('creationDate'); + ##TODO: Photo variables + } + return $var; } diff --git a/lib/WebGUI/Help/Asset_StoryTopic.pm b/lib/WebGUI/Help/Asset_StoryTopic.pm index 65f4243b6..31fbc2aa5 100644 --- a/lib/WebGUI/Help/Asset_StoryTopic.pm +++ b/lib/WebGUI/Help/Asset_StoryTopic.pm @@ -19,13 +19,16 @@ our $HELP = { ], fields => [], variables => [ - { 'name' => 'story_loop', - 'variables' => [ - { 'name' => 'url' }, - { 'name' => 'title' }, - { 'name' => 'creationDate' }, + { name => 'story_loop', + variables => [ + { name => 'url' }, + { name => 'title' }, + { name => 'creationDate' }, ], }, + { name => 'topStoryTitle' }, + { name => 'topStoryUrl' }, + { name => 'topStoryCreationDate' }, ], related => [] }, diff --git a/lib/WebGUI/i18n/English/Asset_StoryTopic.pm b/lib/WebGUI/i18n/English/Asset_StoryTopic.pm index 449fa0a53..426d64fd2 100644 --- a/lib/WebGUI/i18n/English/Asset_StoryTopic.pm +++ b/lib/WebGUI/i18n/English/Asset_StoryTopic.pm @@ -81,6 +81,24 @@ our $I18N = { lastUpdated => 0, }, + 'topStoryUrl' => { + message => q|The URL to view the top story.|, + context => q|Template variable.|, + lastUpdated => 0, + }, + + 'topStoryTitle' => { + message => q|The title of the top story.|, + context => q|Template variable.|, + lastUpdated => 0, + }, + + 'topStoryCreationDate' => { + message => q|The epoch date when the top story was created, or submitted, to its Story Archive.|, + context => q|Template variable.|, + lastUpdated => 0, + }, + 'view template' => { message => q|View Story Topic Template|, context => q|Template variable.|, diff --git a/t/Asset/Wobject/StoryTopic.t b/t/Asset/Wobject/StoryTopic.t index e0b8eac22..abea7f516 100644 --- a/t/Asset/Wobject/StoryTopic.t +++ b/t/Asset/Wobject/StoryTopic.t @@ -31,7 +31,7 @@ my $session = WebGUI::Test->session; #---------------------------------------------------------------------------- # Tests -my $tests = 4; +my $tests = 8; plan tests => 1 + $tests; #---------------------------------------------------------------------------- @@ -113,16 +113,18 @@ cmp_deeply( 'viewTemplateVars has right number and contents in the story_loop' ); +ok( + ! exists $templateVars->{topStoryTitle} + && ! exists $templateVars->{topStoryUrl} + && ! exists $templateVars->{topStoryCreationDate}, + 'topStory variables not present unless in standalone mode' +); + $topic->{_standAlone} = 1; $templateVars = $topic->viewTemplateVariables(); cmp_deeply( $templateVars->{story_loop}, [ - { - title => 'bogs', - url => $session->url->append($topic->getUrl, 'func=viewStory;assetId='.$storyHandler->{'bogs'}->getId), - creationDate => $now, - }, { title => 'red', url => $session->url->append($topic->getUrl, 'func=viewStory;assetId='.$storyHandler->{'red'}->getId), @@ -152,11 +154,20 @@ cmp_deeply( 'viewTemplateVars has right number and contents in the story_loop in standalone mode' ); +is($templateVars->{topStoryTitle}, 'bogs', 'viewTemplateVars in standalone mode, title'); +is( + $templateVars->{topStoryUrl}, + $session->url->append($topic->getUrl, 'func=viewStory;assetId='.$storyHandler->{'bogs'}->getId), + 'viewTemplateVars in standalone mode, url' +); +is($templateVars->{topStoryCreationDate}, $now, 'viewTemplateVars in standalone mode, title'); + $topic->update({ - storiesPer => 16, - storiesShort => 3, + storiesShort => 20, }); +$topic->{_standAlone} = 0; + $templateVars = $topic->viewTemplateVariables; my @topicInmates = map { $_->{title} } @{ $templateVars->{story_loop} }; cmp_deeply(