Commit 5ea29f4b authored by Leigh Stoller's avatar Leigh Stoller

Fix who sees the announcement after approving reservation.

parent 1dfe10c8
......@@ -97,7 +97,7 @@ sub DoApprove();
sub DoSystemInfo();
sub DoPrediction();
sub readfile($);
sub AddAnnouncement($$$$$$);
sub AddAnnouncement($$$$$$$);
sub DeleteAnnouncement($);
#
......@@ -349,7 +349,7 @@ sub DoReserve()
#
# Schedule an announcement for the user.
#
AddAnnouncement($portal, $brand, $uuid, $count, $type, $start);
AddAnnouncement($portal, $brand, $uuid, $this_user, $count, $type, $start);
}
if (defined($webtask)) {
$webtask->approved($approved);
......@@ -614,9 +614,13 @@ sub DoApprove()
# Schedule an announcement for the user.
#
my $blob = $response->value();
AddAnnouncement($portal, $brand, $uuid,
$blob->{'nodes'}, $blob->{'type'}, $blob->{'start'});
if (exists($blob->{'user'})) {
my $geniuser = GeniUser->Lookup($blob->{'user'}, 1);
if (defined($geniuser) && $geniuser->IsLocal()) {
AddAnnouncement($portal, $brand, $uuid, $geniuser->emulab_user(),
$blob->{'nodes'}, $blob->{'type'}, $blob->{'start'});
}
}
if (defined($webtask)) {
$webtask->Exited(0);
}
......@@ -953,10 +957,10 @@ sub readfile($) {
#
# Add or Edit a reservation announcement.
#
sub AddAnnouncement($$$$$$)
sub AddAnnouncement($$$$$$$)
{
my ($portal, $brand, $uuid, $nodes, $type, $start) = @_;
my $this_uid = $this_user->uid();
my ($portal, $brand, $uuid, $user, $nodes, $type, $start) = @_;
my $this_uid = $user->uid();
my $nickname = $aggregate->nickname();
my $name = $aggregate->name();
my $url = $brand->wwwBase() .
......
......@@ -1102,6 +1102,21 @@ sub ApproveReservation($)
print STDERR "$output\n";
return GeniResponse->Create(GENIRESPONSE_REFUSED, undef, $output);
}
my $pid = $reservation->pid();
my $project = Project->Lookup($pid);
if (!defined($project)) {
print STDERR "ApproveReservation: No such project $pid\n";
return GeniResponse->Create(GENIRESPONSE_ERROR, undef,
"Could not lookup project");
}
my $uid = $reservation->uid();
my $user = User->Lookup($uid);
if (!defined($user)) {
print STDERR "ApproveReservation: No such user $uid\n";
return GeniResponse->Create(GENIRESPONSE_ERROR, undef,
"Could not lookup project");
}
#
# Return current details of the reservation.
#
......@@ -1110,6 +1125,8 @@ sub ApproveReservation($)
$blob->{"uuid"} = $reservation->uuid();
$blob->{"nodes"} = $reservation->nodes();
$blob->{"type"} = $reservation->type();
$blob->{"project"} = $project->nonlocalurn();
$blob->{"user"} = $user->nonlocalurn();
$blob->{"created"} = TBDateStringGMT($reservation->created());
$blob->{"start"} = TBDateStringGMT($reservation->start());
$blob->{"end"} = TBDateStringGMT($reservation->end());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment