Commit events created by the ExtendCalendarRecurrences workflow activity. Fixes bug #11994.

This commit is contained in:
Colin Kuskie 2011-01-03 17:01:26 -08:00
parent 3e0da41f0a
commit b911f05125
3 changed files with 30 additions and 13 deletions

View file

@ -14,6 +14,7 @@
- fixed #12010: Related URLs are not copied for events created through recurrence
- fixed #12012: WebGUI Account system does not present login to visitors for proper redirect
- fixed #12015: Thingy: Custom 'File' form fields get deleted upon save
- fixed #11994: recurring calendar entries
7.10.6
- fixed #11974: Toolbar icons unclickable in Webkit using HTML5

View file

@ -19,6 +19,7 @@ use strict;
use base 'WebGUI::Workflow::Activity';
use WebGUI::International;
use WebGUI::Asset;
use WebGUI::VersionTag;
use DateTime;
=head1 NAME
@ -171,18 +172,25 @@ sub processRecurrence {
}
my $recur = $event->getRecurrence;
my $versionTag = WebGUI::VersionTag->create($self->session, {name => 'Extend Calendar Recurrence for assetId '.$event->getId, });
$versionTag->setWorking();
my $start = $event->getDateTimeStart->truncate(to => 'day');
my $limit = DateTime->today->add( years => 2 );
my $end = $event->limitedEndDate($limit);
my $set = $event->dateSet( $recur, $start, $end );
my $i = $set->iterator;
while ( my $d = $i->next ) {
return if ( time > $timeLimit );
my $time_limit = 0;
DATE: while ( my $d = $i->next ) {
if ( time > $timeLimit ) {
$time_limit = 1;
last DATE;
}
$event->generateRecurrence($d);
}
return 1;
$versionTag->commit;
return $time_limit ? 1 : 0;
} ## end sub processRecurrence
1;

View file

@ -38,9 +38,13 @@ my $event = $calendar->addChild(
{ className => 'WebGUI::Asset::Event',
startDate => $one_year_ago,
endDate => $one_year_ago,
}
}, undef, undef, {skipAutoCommitWorkflows => 1, }
);
$tag->commit;
$calendar = $calendar->cloneFromDb;
$event = $event->cloneFromDb;
my $recurId = $event->setRecurrence(
{ recurType => 'monthDay',
every => 2,
@ -87,17 +91,21 @@ while (my $status = $instance->run ne 'complete') {
$instance->run;
}
my $sql = q{
select e.startDate, e.endDate
from asset a
inner join Event e on e.assetId = a.assetId
and a.parentId = ?
order by e.startDate
};
#my $sql = q{
# select e.startDate, e.endDate
# from asset a
# inner join Event e on e.assetId = a.assetId
# and a.parentId = ?
# order by e.startDate
#};
my $dates = $session->db->buildArrayRefOfHashRefs($sql, [$calendar->getId]);
#my $dates = $session->db->buildArrayRefOfHashRefs($sql, [$calendar->getId]);
my $dates = $calendar->getLineage(['children'], { returnObjects => 1, });
# 3 years at every other month (6 times) plus the one we started with
is(@$dates, 19, 'created right number of dates') or diag Dumper $dates;
is(@{$dates}, 19, 'created right number of dates') or diag Dumper $dates;
my @uncommitted_events = grep { $_->get('status') ne 'approved' } @{ $dates };
is @uncommitted_events, 0, 'all events are committed (approved)';
done_testing;