Add template field to StoryTopic. The same template will be shared between both modes.
Add top story variables, and tests.
This commit is contained in:
parent
4b859e5ada
commit
ea31d52ac0
5 changed files with 71 additions and 18 deletions
|
|
@ -32,9 +32,6 @@ my $quiet; # this line required
|
||||||
my $session = start(); # this line required
|
my $session = start(); # this line required
|
||||||
|
|
||||||
# upgrade functions go here
|
# upgrade functions go here
|
||||||
installStoryManagerTables($session);
|
|
||||||
upgradeConfigFiles($session);
|
|
||||||
|
|
||||||
addGroupToAddToMatrix( $session );
|
addGroupToAddToMatrix( $session );
|
||||||
addScreenshotTemplatesToMatrix( $session );
|
addScreenshotTemplatesToMatrix( $session );
|
||||||
surveyDoAfterTimeLimit($session);
|
surveyDoAfterTimeLimit($session);
|
||||||
|
|
@ -42,6 +39,10 @@ surveyRemoveResponseTemplate($session);
|
||||||
surveyEndWorkflow($session);
|
surveyEndWorkflow($session);
|
||||||
installAssetHistory($session);
|
installAssetHistory($session);
|
||||||
|
|
||||||
|
# Story Manager
|
||||||
|
installStoryManagerTables($session);
|
||||||
|
upgradeConfigFiles($session);
|
||||||
|
|
||||||
# Passive Analytics
|
# Passive Analytics
|
||||||
pa_installLoggingTables($session);
|
pa_installLoggingTables($session);
|
||||||
pa_installPassiveAnalyticsRule($session);
|
pa_installPassiveAnalyticsRule($session);
|
||||||
|
|
@ -364,6 +365,7 @@ CREATE TABLE StoryTopic (
|
||||||
revisionDate BIGINT NOT NULL,
|
revisionDate BIGINT NOT NULL,
|
||||||
storiesPer INTEGER,
|
storiesPer INTEGER,
|
||||||
storiesShort INTEGER,
|
storiesShort INTEGER,
|
||||||
|
templateId CHAR(22) BINARY,
|
||||||
storyTemplateId CHAR(22) BINARY,
|
storyTemplateId CHAR(22) BINARY,
|
||||||
PRIMARY KEY ( assetId, revisionDate )
|
PRIMARY KEY ( assetId, revisionDate )
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,15 @@ sub definition {
|
||||||
hoverHelp => $i18n->get('stories short help'),
|
hoverHelp => $i18n->get('stories short help'),
|
||||||
defaultValue => 5,
|
defaultValue => 5,
|
||||||
},
|
},
|
||||||
|
templateId => {
|
||||||
|
tab => 'display',
|
||||||
|
fieldType => 'template',
|
||||||
|
label => $i18n->get('template'),
|
||||||
|
hoverHelp => $i18n->get('template help'),
|
||||||
|
filter => 'fixId',
|
||||||
|
namespace => 'Story',
|
||||||
|
defaultValue => 'liNZSK4xWGyALU6nu_criw',
|
||||||
|
},
|
||||||
storyTemplateId => {
|
storyTemplateId => {
|
||||||
tab => 'display',
|
tab => 'display',
|
||||||
fieldType => 'template',
|
fieldType => 'template',
|
||||||
|
|
@ -146,14 +155,24 @@ sub viewTemplateVariables {
|
||||||
STORY: foreach my $storyId (@{ $storyIds }) {
|
STORY: foreach my $storyId (@{ $storyIds }) {
|
||||||
my $story = WebGUI::Asset->new($session, $storyId->{assetId}, $storyId->{className}, $storyId->{revisionDate});
|
my $story = WebGUI::Asset->new($session, $storyId->{assetId}, $storyId->{className}, $storyId->{revisionDate});
|
||||||
next STORY unless $story;
|
next STORY unless $story;
|
||||||
my $creationDate = $story->get('creationDate');
|
|
||||||
push @{$var->{story_loop}}, {
|
push @{$var->{story_loop}}, {
|
||||||
url => $session->url->append($self->getUrl, 'func=viewStory;assetId='.$storyId->{assetId}),
|
url => $session->url->append($self->getUrl, 'func=viewStory;assetId='.$storyId->{assetId}),
|
||||||
title => $story->getTitle,
|
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;
|
return $var;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,16 @@ our $HELP = {
|
||||||
],
|
],
|
||||||
fields => [],
|
fields => [],
|
||||||
variables => [
|
variables => [
|
||||||
{ 'name' => 'story_loop',
|
{ name => 'story_loop',
|
||||||
'variables' => [
|
variables => [
|
||||||
{ 'name' => 'url' },
|
{ name => 'url' },
|
||||||
{ 'name' => 'title' },
|
{ name => 'title' },
|
||||||
{ 'name' => 'creationDate' },
|
{ name => 'creationDate' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{ name => 'topStoryTitle' },
|
||||||
|
{ name => 'topStoryUrl' },
|
||||||
|
{ name => 'topStoryCreationDate' },
|
||||||
],
|
],
|
||||||
related => []
|
related => []
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,24 @@ our $I18N = {
|
||||||
lastUpdated => 0,
|
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' => {
|
'view template' => {
|
||||||
message => q|View Story Topic Template|,
|
message => q|View Story Topic Template|,
|
||||||
context => q|Template variable.|,
|
context => q|Template variable.|,
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ my $session = WebGUI::Test->session;
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Tests
|
# Tests
|
||||||
|
|
||||||
my $tests = 4;
|
my $tests = 8;
|
||||||
plan tests => 1 + $tests;
|
plan tests => 1 + $tests;
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
@ -113,16 +113,18 @@ cmp_deeply(
|
||||||
'viewTemplateVars has right number and contents in the story_loop'
|
'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;
|
$topic->{_standAlone} = 1;
|
||||||
$templateVars = $topic->viewTemplateVariables();
|
$templateVars = $topic->viewTemplateVariables();
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$templateVars->{story_loop},
|
$templateVars->{story_loop},
|
||||||
[
|
[
|
||||||
{
|
|
||||||
title => 'bogs',
|
|
||||||
url => $session->url->append($topic->getUrl, 'func=viewStory;assetId='.$storyHandler->{'bogs'}->getId),
|
|
||||||
creationDate => $now,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title => 'red',
|
title => 'red',
|
||||||
url => $session->url->append($topic->getUrl, 'func=viewStory;assetId='.$storyHandler->{'red'}->getId),
|
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'
|
'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({
|
$topic->update({
|
||||||
storiesPer => 16,
|
storiesShort => 20,
|
||||||
storiesShort => 3,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$topic->{_standAlone} = 0;
|
||||||
|
|
||||||
$templateVars = $topic->viewTemplateVariables;
|
$templateVars = $topic->viewTemplateVariables;
|
||||||
my @topicInmates = map { $_->{title} } @{ $templateVars->{story_loop} };
|
my @topicInmates = map { $_->{title} } @{ $templateVars->{story_loop} };
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue