Added the notifications for the code review.

This commit is contained in:
Loic d'Anterroches 2009-01-28 14:03:34 +01:00
parent 2ec653ad43
commit ee5044fb1c
3 changed files with 49 additions and 6 deletions

View File

@ -179,6 +179,26 @@ class IDF_Form_ReviewCreate extends Pluf_Form
$patch->commit = self::findCommit($this->cleaned_data['commit']); $patch->commit = self::findCommit($this->cleaned_data['commit']);
$patch->patch = $this->cleaned_data['patch']; $patch->patch = $this->cleaned_data['patch'];
$patch->create(); $patch->create();
// Send create notification
if ('' != $this->project->getConf()->getVal('review_notification_email', '')) {
$context = new Pluf_Template_Context(
array(
'review' => $review,
'patch' => $patch,
'comments' => array(),
'project' => $this->project,
'url_base' => Pluf::f('url_base'),
)
);
$tmpl = new Pluf_Template('idf/review/review-created-email.txt');
$text_email = $tmpl->render($context);
$email = new Pluf_Mail(Pluf::f('from_email'),
$this->project->getConf()->getVal('review_notification_email'),
sprintf(__('New Code Review %s - %s (%s)'),
$review->id, $review->summary, $this->project->shortname));
$email->addTextMessage($text_email);
$email->sendMail();
}
return $review; return $review;
} }

View File

@ -177,16 +177,23 @@ class IDF_Views_Review
$tmpl = new Pluf_Template('idf/review/review-updated-email.txt'); $tmpl = new Pluf_Template('idf/review/review-updated-email.txt');
$text_email = $tmpl->render($context); $text_email = $tmpl->render($context);
$email = new Pluf_Mail_Batch(Pluf::f('from_email')); $email = new Pluf_Mail_Batch(Pluf::f('from_email'));
$to_emails = array();
foreach ($reviewers as $user) { foreach ($reviewers as $user) {
if ($user->id != $request->user->id) { if ($user->id != $request->user->id) {
$to_emails[] = $user->email;
}
}
if ('' != $request->conf->getVal('review_notification_email', '')) {
$to_emails[] = $request->conf->getVal('review_notification_email');
}
foreach ($to_emails as $oemail) {
$email->setSubject(sprintf(__('Updated Code Review %s - %s (%s)'), $email->setSubject(sprintf(__('Updated Code Review %s - %s (%s)'),
$review->id, $review->summary, $prj->shortname)); $review->id, $review->summary, $prj->shortname));
$email->setTo($user->email); $email->setTo($oemail);
$email->setReturnPath(Pluf::f('from_email')); $email->setReturnPath(Pluf::f('from_email'));
$email->addTextMessage($text_email); $email->addTextMessage($text_email);
$email->sendMail(); $email->sendMail();
} }
}
$email->close(); $email->close();
return new Pluf_HTTP_Response_Redirect($url); return new Pluf_HTTP_Response_Redirect($url);
} }

View File

@ -0,0 +1,16 @@
{trans 'Hello,'}
{blocktrans}The following review has been created:{/blocktrans}
{$review.id} - {$review.summary|safe}
{trans 'Project:'} {$project.name|safe}
{trans 'Status:'} {$review.get_status.name}
{trans 'Reported by:'} {$review.get_submitter|safe}
{trans 'URL:'} {$url_base}{url 'IDF_Views_Review::view', array($project.shortname, $review.id)}
{assign $tags = $review.get_tags_list()}{if $tags.count()}{trans 'Labels:'}
{foreach $tags as $tag} {$tag.class|safe}:{$tag.name|safe}
{/foreach}
{/if}
--
{trans 'Review:'} {$url_base}{url 'IDF_Views_Review::view', array($project.shortname, $review.id)}