Fixed issue 145, code reviews don't show up in the timeline.
This commit is contained in:
parent
1d24432f8d
commit
646cf6479b
@ -30,12 +30,15 @@ class IDF_Form_ReviewFileComment extends Pluf_Form
|
||||
public $files = null;
|
||||
public $patch = null;
|
||||
public $user = null;
|
||||
public $project = null;
|
||||
|
||||
public function initFields($extra=array())
|
||||
{
|
||||
$this->files = $extra['files'];
|
||||
$this->patch = $extra['patch'];
|
||||
$this->user = $extra['user'];
|
||||
$this->project = $extra['project'];
|
||||
|
||||
foreach ($this->files as $filename => $def) {
|
||||
$this->fields[md5($filename)] = new Pluf_Form_Field_Varchar(
|
||||
array('required' => false,
|
||||
@ -48,6 +51,41 @@ class IDF_Form_ReviewFileComment extends Pluf_Form
|
||||
),
|
||||
));
|
||||
}
|
||||
$this->fields['content'] = new Pluf_Form_Field_Varchar(
|
||||
array('required' => true,
|
||||
'label' => __('General comment'),
|
||||
'initial' => '',
|
||||
'widget' => 'Pluf_Form_Widget_TextareaInput',
|
||||
'widget_attrs' => array(
|
||||
'cols' => 58,
|
||||
'rows' => 9,
|
||||
),
|
||||
));
|
||||
if ($this->user->hasPerm('IDF.project-owner', $this->project)
|
||||
or $this->user->hasPerm('IDF.project-member', $this->project)) {
|
||||
$this->show_full = true;
|
||||
}
|
||||
if ($this->show_full) {
|
||||
$this->fields['summary'] = new Pluf_Form_Field_Varchar(
|
||||
array('required' => true,
|
||||
'label' => __('Summary'),
|
||||
'initial' => $this->patch->get_review()->summary,
|
||||
'widget_attrs' => array(
|
||||
'maxlength' => 200,
|
||||
'size' => 67,
|
||||
),
|
||||
));
|
||||
|
||||
$this->fields['status'] = new Pluf_Form_Field_Varchar(
|
||||
array('required' => true,
|
||||
'label' => __('Status'),
|
||||
'initial' => $this->patch->get_review()->get_status()->name,
|
||||
'widget_attrs' => array(
|
||||
'maxlength' => 20,
|
||||
'size' => 15,
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -64,6 +102,16 @@ class IDF_Form_ReviewFileComment extends Pluf_Form
|
||||
throw new Pluf_Form_Invalid(__('You need to provide comments on at least one file.'));
|
||||
}
|
||||
|
||||
function clean_content()
|
||||
{
|
||||
$content = trim($this->cleaned_data['content']);
|
||||
if (!$this->show_full and strlen($content) == 0) {
|
||||
throw new Pluf_Form_Invalid(__('You need to provide your general comment about the proposal.'));
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save the model in the database.
|
||||
*
|
||||
@ -80,6 +128,24 @@ class IDF_Form_ReviewFileComment extends Pluf_Form
|
||||
$bc = new IDF_Review_Comment();
|
||||
$bc->patch = $this->patch;
|
||||
$bc->submitter = $this->user;
|
||||
$bc->content = $this->cleaned_data['content'];
|
||||
$review = $this->patch->get_review();
|
||||
if ($this->show_full) {
|
||||
// Compare between the old and the new data
|
||||
// Status, summary
|
||||
$changes = array();
|
||||
$status = IDF_Tag::add(trim($this->cleaned_data['status']), $this->project, 'Status');
|
||||
if ($status->id != $this->patch->get_review()->status) {
|
||||
$changes['st'] = $status->name;
|
||||
}
|
||||
if (trim($this->patch->get_review()->summary) != trim($this->cleaned_data['summary'])) {
|
||||
$changes['su'] = trim($this->cleaned_data['summary']);
|
||||
}
|
||||
// Update the review
|
||||
$review->summary = trim($this->cleaned_data['summary']);
|
||||
$review->status = $status;
|
||||
$bc->changes = $changes;
|
||||
}
|
||||
$bc->create();
|
||||
foreach ($this->files as $filename => $def) {
|
||||
if (!empty($this->cleaned_data[md5($filename)])) {
|
||||
@ -91,8 +157,7 @@ class IDF_Form_ReviewFileComment extends Pluf_Form
|
||||
$c->create();
|
||||
}
|
||||
}
|
||||
$this->patch->get_review()->update(); // reindex and put up in
|
||||
// the list.
|
||||
$review->update(); // reindex and put up in the list.
|
||||
return $bc;
|
||||
}
|
||||
}
|
||||
|
@ -171,6 +171,8 @@ class IDF_Review extends Pluf_Model
|
||||
|
||||
function postSave($create=false)
|
||||
{
|
||||
// At creation, we index after saving the associated patch.
|
||||
if (!$create) IDF_Search::index($this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -117,28 +117,53 @@ class IDF_Review_Comment extends Pluf_Model
|
||||
|
||||
function postSave($create=false)
|
||||
{
|
||||
if (0 and $create) {
|
||||
// Check if more than one comment for this patch. We do
|
||||
// not want to insert the first comment in the timeline as
|
||||
// the patch itself is inserted.
|
||||
$sql = new Pluf_SQL('patch=%s', array($this->patch));
|
||||
$co = Pluf::factory(__CLASS__)->getList(array('filter'=>$sql->gen()));
|
||||
if ($co->count() > 1) {
|
||||
IDF_Timeline::insert($this, $this->get_patch()->get_review()->get_project(),
|
||||
$this->get_submitter());
|
||||
}
|
||||
if ($create) {
|
||||
IDF_Timeline::insert($this,
|
||||
$this->get_patch()->get_review()->get_project(),
|
||||
$this->get_submitter());
|
||||
}
|
||||
IDF_Search::index($this->get_patch()->get_review());
|
||||
}
|
||||
|
||||
public function timelineFragment($request)
|
||||
{
|
||||
return '';
|
||||
$review = $this->get_patch()->get_review();
|
||||
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Review::view',
|
||||
array($request->project->shortname,
|
||||
$review->id));
|
||||
$out = '<tr class="log"><td><a href="'.$url.'">'.
|
||||
Pluf_esc(Pluf_Template_dateAgo($this->creation_dtime, 'without')).
|
||||
'</a></td><td>';
|
||||
$stag = new IDF_Template_ShowUser();
|
||||
$user = $stag->start($this->get_submitter(), $request, '', false);
|
||||
$ic = (in_array($review->status, $request->project->getTagIdsByStatus('closed'))) ? 'issue-c' : 'issue-o';
|
||||
$out .= sprintf(__('<a href="%1$s" class="%2$s" title="View review">Review %3$d</a>, %4$s'), $url, $ic, $review->id, Pluf_esc($review->summary)).'</td>';
|
||||
$out .= "\n".'<tr class="extra"><td colspan="2">
|
||||
<div class="helptext right">'.sprintf(__('Update of <a href="%s" class="%s">review %d</a>, by %s'), $url, $ic, $review->id, $user).'</div></td></tr>';
|
||||
return Pluf_Template::markSafe($out);
|
||||
}
|
||||
|
||||
public function feedFragment($request)
|
||||
{
|
||||
return '';
|
||||
$review = $this->get_patch()->get_review();
|
||||
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Review::view',
|
||||
array($request->project->shortname,
|
||||
$review->id));
|
||||
$title = sprintf(__('%s: Updated review %d - %s'),
|
||||
Pluf_esc($request->project->name),
|
||||
$review->id, Pluf_esc($review->summary));
|
||||
$url .= '#ic'.$this->id;
|
||||
$date = Pluf_Date::gmDateToGmString($this->creation_dtime);
|
||||
$context = new Pluf_Template_Context_Request(
|
||||
$request,
|
||||
array('url' => $url,
|
||||
'author' => $this->get_submitter(),
|
||||
'title' => $title,
|
||||
'c' => $this,
|
||||
'review' => $review,
|
||||
'date' => $date)
|
||||
);
|
||||
$tmpl = new Pluf_Template('idf/review/feedfragment.xml');
|
||||
return $tmpl->render($context);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -165,11 +190,13 @@ class IDF_Review_Comment extends Pluf_Model
|
||||
$reviewers[] = $review->get_submitter();
|
||||
}
|
||||
$comments = $patch->getFileComments(array('order' => 'id DESC'));
|
||||
$gcomments = $patch->get_comments_list(array('order' => 'id DESC'));
|
||||
$context = new Pluf_Template_Context(
|
||||
array(
|
||||
'review' => $review,
|
||||
'patch' => $patch,
|
||||
'comments' => $comments,
|
||||
'gcomments' => $gcomments,
|
||||
'project' => $prj,
|
||||
'url_base' => Pluf::f('url_base'),
|
||||
)
|
||||
|
@ -116,6 +116,7 @@ class IDF_Review_Patch extends Pluf_Model
|
||||
|
||||
function preDelete()
|
||||
{
|
||||
IDF_Timeline::remove($this);
|
||||
}
|
||||
|
||||
function preSave($create=false)
|
||||
@ -127,16 +128,53 @@ class IDF_Review_Patch extends Pluf_Model
|
||||
|
||||
function postSave($create=false)
|
||||
{
|
||||
if ($create) {
|
||||
IDF_Timeline::insert($this,
|
||||
$this->get_review()->get_project(),
|
||||
$this->get_review()->get_submitter());
|
||||
IDF_Search::index($this->get_review());
|
||||
}
|
||||
}
|
||||
|
||||
public function timelineFragment($request)
|
||||
{
|
||||
return '';
|
||||
$review = $this->get_review();
|
||||
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Review::view',
|
||||
array($request->project->shortname,
|
||||
$review->id));
|
||||
$out = '<tr class="log"><td><a href="'.$url.'">'.
|
||||
Pluf_esc(Pluf_Template_dateAgo($this->creation_dtime, 'without')).
|
||||
'</a></td><td>';
|
||||
$stag = new IDF_Template_ShowUser();
|
||||
$user = $stag->start($review->get_submitter(), $request, '', false);
|
||||
$ic = (in_array($review->status, $request->project->getTagIdsByStatus('closed'))) ? 'issue-c' : 'issue-o';
|
||||
$out .= sprintf(__('<a href="%1$s" class="%2$s" title="View review">Review %3$d</a>, %4$s'), $url, $ic, $review->id, Pluf_esc($review->summary)).'</td>';
|
||||
$out .= "\n".'<tr class="extra"><td colspan="2">
|
||||
<div class="helptext right">'.sprintf(__('Creation of <a href="%s" class="%s">review %d</a>, by %s'), $url, $ic, $review->id, $user).'</div></td></tr>';
|
||||
return Pluf_Template::markSafe($out);
|
||||
}
|
||||
|
||||
public function feedFragment($request)
|
||||
{
|
||||
return '';
|
||||
$review = $this->get_review();
|
||||
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Review::view',
|
||||
array($request->project->shortname,
|
||||
$review->id));
|
||||
$title = sprintf(__('%s: Creation of Review %d - %s'),
|
||||
Pluf_esc($request->project->name),
|
||||
$review->id, Pluf_esc($review->summary));
|
||||
$date = Pluf_Date::gmDateToGmString($this->creation_dtime);
|
||||
$context = new Pluf_Template_Context_Request(
|
||||
$request,
|
||||
array('url' => $url,
|
||||
'author' => $review->get_submitter(),
|
||||
'title' => $title,
|
||||
'p' => $this,
|
||||
'review' => $review,
|
||||
'date' => $date)
|
||||
);
|
||||
$tmpl = new Pluf_Template('idf/review/feedfragment.xml');
|
||||
return $tmpl->render($context);
|
||||
}
|
||||
|
||||
public function notify($conf, $create=true)
|
||||
|
@ -128,7 +128,7 @@ class IDF_Timeline extends Pluf_Model
|
||||
$t->model_id = $item->id;
|
||||
$t->model_class = $item->_model;
|
||||
$t->create();
|
||||
return true;
|
||||
return $t;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -92,6 +92,10 @@ class IDF_Views_Project
|
||||
$rights[] = '\'IDF_WikiPage\'';
|
||||
$rights[] = '\'IDF_WikiRevision\'';
|
||||
}
|
||||
if (true === IDF_Precondition::accessReview($request)) {
|
||||
$rights[] = '\'IDF_Review_Comment\'';
|
||||
$rights[] = '\'IDF_Review_Patch\'';
|
||||
}
|
||||
if (count($rights) == 0) {
|
||||
$rights[] = '\'IDF_Dummy\'';
|
||||
}
|
||||
@ -169,6 +173,10 @@ class IDF_Views_Project
|
||||
$rights[] = '\'IDF_WikiPage\'';
|
||||
$rights[] = '\'IDF_WikiRevision\'';
|
||||
}
|
||||
if (true === IDF_Precondition::accessReview($request)) {
|
||||
$rights[] = '\'IDF_Review_Comment\'';
|
||||
$rights[] = '\'IDF_Review_Patch\'';
|
||||
}
|
||||
if (count($rights) == 0) {
|
||||
$rights[] = '\'IDF_Dummy\'';
|
||||
}
|
||||
|
@ -150,6 +150,7 @@ class IDF_Views_Review
|
||||
array('files' => $diff->files,
|
||||
'user' => $request->user,
|
||||
'patch' => $patch,
|
||||
'project' => $prj,
|
||||
));
|
||||
if ($form->isValid()) {
|
||||
$review_comment = $form->save();
|
||||
@ -166,6 +167,7 @@ class IDF_Views_Review
|
||||
$form = new IDF_Form_ReviewFileComment(null,
|
||||
array('files' => $diff->files,
|
||||
'user' => $request->user,
|
||||
'project' => $prj,
|
||||
'patch' => $patch,));
|
||||
}
|
||||
$scm = IDF_Scm::get($request->project);
|
||||
@ -192,6 +194,7 @@ class IDF_Views_Review
|
||||
}
|
||||
$reviewers = Pluf_Model_RemoveDuplicates($reviewers);
|
||||
return Pluf_Shortcuts_RenderToResponse('idf/review/view.html',
|
||||
array_merge(
|
||||
array(
|
||||
'page_title' => $title,
|
||||
'review' => $review,
|
||||
@ -202,6 +205,8 @@ class IDF_Views_Review
|
||||
'form' => $form,
|
||||
'reviewers' => $reviewers,
|
||||
),
|
||||
IDF_Views_Issue::autoCompleteArrays($prj)
|
||||
),
|
||||
$request);
|
||||
}
|
||||
}
|
||||
|
18
src/IDF/templates/idf/review/feedfragment.xml
Normal file
18
src/IDF/templates/idf/review/feedfragment.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<entry>
|
||||
<title>{$title} - {$review.get_status}</title>
|
||||
<link href="{$url}"/>
|
||||
<id>{$url}</id>
|
||||
<updated>{$date}</updated>
|
||||
<author>{$author}</author>
|
||||
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
|
||||
{if $c}
|
||||
<pre>{issuetext $c.content, $request}</pre>
|
||||
{if $c.changes}
|
||||
{foreach $c.changes as $w => $v}
|
||||
<strong>{if $w == 'su'}{trans 'Summary:'}{/if}{if $w == 'st'}{trans 'Status:'}{/if}{if $w == 'ow'}{trans 'Owner:'}{/if}{if $w == 'lb'}{trans 'Labels:'}{/if}</strong> {if $w == 'lb'}{assign $l = implode(', ', $v)}{$l}{else}{$v}{/if}<br />
|
||||
{/foreach}
|
||||
{/if}{else}
|
||||
<pre>{issuetext $p.description, $request}</pre>
|
||||
{/if}
|
||||
</div></content>
|
||||
</entry>
|
@ -10,7 +10,13 @@
|
||||
{assign $tags = $review.get_tags_list()}{if $tags.count()}{trans 'Labels:'}
|
||||
{foreach $tags as $tag} {$tag.class|safe}:{$tag.name|safe}
|
||||
{/foreach}
|
||||
{/if}{trans 'Comments (last first):'}
|
||||
{/if}{trans 'General comments (last first):'}
|
||||
|
||||
{foreach $gcomments as $c}{assign $who = $c.get_submitter()}# {blocktrans}By {$who|safe}, {$c.creation_dtime|date}:{/blocktrans}
|
||||
{$c.content|safe}
|
||||
|
||||
{/foreach}
|
||||
{trans 'Detailed file comments (last first):'}
|
||||
|
||||
{foreach $comments as $c}{assign $who = $c.get_comment().get_submitter()}# {blocktrans}By {$who|safe}, {$c.creation_dtime|date}, on file:
|
||||
{$c.cfile|safe}
|
||||
|
@ -78,10 +78,10 @@ to propose more contributions</strong>.
|
||||
{$def[0]}
|
||||
</tbody>
|
||||
</table>
|
||||
{assign $comments = $def[2]}
|
||||
{assign $nc = $comments.count()}
|
||||
{assign $fcomments = $def[2]}
|
||||
{assign $nc = $fcomments.count()}
|
||||
{assign $i = 1}
|
||||
{foreach $comments as $c}
|
||||
{foreach $fcomments as $c}
|
||||
<div class="issue-comment{if $i == 1} issue-comment-first{/if}{if $i == $nc} issue-comment-last{/if}" id="ic{$c.id}">{assign $who = $c.get_comment().get_submitter()}{aurl 'whourl', 'IDF_Views_User::view', array($who.login)}
|
||||
{aurl 'url', 'IDF_Views_Review::view', array($project.shortname, $review.id)}
|
||||
{assign $id = $c.id}
|
||||
@ -100,9 +100,60 @@ to propose more contributions</strong>.
|
||||
</td>
|
||||
</tr></table>{/if}
|
||||
{/foreach}
|
||||
|
||||
{assign $i = 1}
|
||||
{assign $nc = $comments.count()}
|
||||
{if $nc}<hr align="left" class="attach" />
|
||||
<h2>{trans 'General Comments'}</h2>
|
||||
{/if}
|
||||
{foreach $comments as $c}{ashowuser 'submitter', $c.get_submitter(), $request}{assign $who = $c.get_submitter()}
|
||||
<div class="issue-comment{if $i == 1} issue-comment-first{/if}{if $i == ($nc)} issue-comment-last{/if}" id="ic{$c.id}"><img style="float:right; position: relative;" src="http://www.gravatar.com/avatar/{$who.email|md5}.jpg?s=60&d={media}/idf/img/spacer.gif" alt=" " />
|
||||
{aurl 'url', 'IDF_Views_Review::view', array($project.shortname, $review.id)}
|
||||
{assign $id = $c.id}
|
||||
{assign $url = $url~'#ic'~$c.id}
|
||||
<p>{blocktrans}Comment <a href="{$url}">{$i}</a> by {$submitter}, {$c.creation_dtime|date}{/blocktrans}</p>
|
||||
|
||||
|
||||
|
||||
{if strlen($c.content) > 0}<pre class="issue-comment-text">{issuetext $c.content, $request}</pre>{/if}
|
||||
|
||||
{if $c.changedReview()}
|
||||
<div class="issue-changes">
|
||||
{foreach $c.changes as $w => $v}
|
||||
<strong>{if $w == 'su'}{trans 'Summary:'}{/if}{if $w == 'st'}{trans 'Status:'}{/if}</strong> {$v}<br />
|
||||
{/foreach}
|
||||
</div>
|
||||
{/if}
|
||||
</div>{assign $i = $i + 1}{if $i == $nc+1 and $user.isAnonymous()}
|
||||
<div class="issue-comment-signin">
|
||||
{aurl 'url', 'IDF_Views::login'}{blocktrans}<a href="{$url}">Sign in</a> to participate in the review.{/blocktrans}
|
||||
</div>
|
||||
{/if}
|
||||
{/foreach}
|
||||
|
||||
{if !$user.isAnonymous()}
|
||||
{if !$nc}<hr align="left" class="attach" />{/if}
|
||||
<table class="form" summary=" ">
|
||||
<tr>
|
||||
<th><strong>{$form.f.content.labelTag}:</strong></th>
|
||||
<td>{if $form.f.content.errors}{$form.f.content.fieldErrors}{/if}
|
||||
{$form.f.content|unsafe}
|
||||
</td>
|
||||
</tr>
|
||||
{if $isOwner or $isMember}
|
||||
<tr>
|
||||
<th><strong>{$form.f.summary.labelTag}:</strong></th>
|
||||
<td>{if $form.f.summary.errors}{$form.f.summary.fieldErrors}{/if}
|
||||
{$form.f.summary|unsafe}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><strong>{$form.f.status.labelTag}:</strong></th>
|
||||
<td>{if $form.f.status.errors}{$form.f.status.fieldErrors}{/if}
|
||||
{$form.f.status|unsafe}
|
||||
</td>
|
||||
</tr>{/if}
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td><input type="submit" value="{trans 'Submit Code Review'}" name="submit" /> | <a href="{url 'IDF_Views_Review::index', array($project.shortname)}">{trans 'Cancel'}</a>
|
||||
</td>
|
||||
@ -110,10 +161,11 @@ to propose more contributions</strong>.
|
||||
{/if}
|
||||
</form>
|
||||
{/block}
|
||||
u
|
||||
|
||||
{block javascript}
|
||||
<script type="text/javascript" src="{media '/idf/js/prettify.js'}"></script>
|
||||
<script type="text/javascript">
|
||||
prettyPrint();
|
||||
</script>
|
||||
{if $isOwner or $isMember}{include 'idf/issues/js-autocomplete.html'}{/if}
|
||||
{/block}
|
||||
|
Loading…
Reference in New Issue
Block a user