Indefero

Indefero Commit Details


Date:2009-10-29 07:25:50 (15 years 1 month ago)
Author:Loic d'Anterroches
Branch:develop, feature-issue_links, feature.better-home, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, master, release-1.1, release-1.2, release-1.3
Commit:646cf6479b61a9e8f5f9c6edc9ce18341420497c
Parents: 1d24432f8d8824848945d8b6f3b00fb31d8a5628
Message:Fixed issue 145, code reviews don't show up in the timeline.

Changes:

File differences

src/IDF/Form/ReviewFileComment.php
3030
3131
3232
33
3334
3435
3536
3637
3738
3839
40
41
3942
4043
4144
......
4851
4952
5053
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
5189
5290
5391
......
64102
65103
66104
105
106
107
108
109
110
111
112
113
114
67115
68116
69117
......
80128
81129
82130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
83149
84150
85151
......
91157
92158
93159
94
95
160
96161
97162
98163
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,
),
));
}
$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,
),
));
}
}
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.
*
$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)])) {
$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;
}
}
src/IDF/Review.php
171171
172172
173173
174
175
174176
175177
176178
function postSave($create=false)
{
// At creation, we index after saving the associated patch.
if (!$create) IDF_Search::index($this);
}
/**
src/IDF/Review/Comment.php
117117
118118
119119
120
121
122
123
124
125
126
127
128
129
120
121
122
123
130124
131
132125
133126
134127
135128
136
129
130
131
132
133
134
135
136
137
138
139
140
141
142
137143
138144
139145
140146
141
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
142167
143168
144169
......
165190
166191
167192
193
168194
169195
170196
171197
172198
199
173200
174201
175202
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&nbsp;%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);
}
/**
$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'),
)
src/IDF/Review/Patch.php
116116
117117
118118
119
119120
120121
121122
......
127128
128129
129130
131
132
133
134
135
136
130137
131138
132139
133140
134
141
142
143
144
145
146
147
148
149
150
151
152
153
154
135155
136156
137157
138158
139
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
140178
141179
142180
function preDelete()
{
IDF_Timeline::remove($this);
}
function preSave($create=false)
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&nbsp;%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)
src/IDF/Timeline.php
128128
129129
130130
131
131
132132
133133
134134
$t->model_id = $item->id;
$t->model_class = $item->_model;
$t->create();
return true;
return $t;
}
/**
src/IDF/Views/Project.php
9292
9393
9494
95
96
97
98
9599
96100
97101
......
169173
170174
171175
176
177
178
179
172180
173181
174182
$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\'';
}
$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\'';
}
src/IDF/Views/Review.php
150150
151151
152152
153
153154
154155
155156
......
166167
167168
168169
170
169171
170172
171173
......
192194
193195
194196
197
195198
196199
197200
......
202205
203206
204207
208
209
205210
206211
207212
array('files' => $diff->files,
'user' => $request->user,
'patch' => $patch,
'project' => $prj,
));
if ($form->isValid()) {
$review_comment = $form->save();
$form = new IDF_Form_ReviewFileComment(null,
array('files' => $diff->files,
'user' => $request->user,
'project' => $prj,
'patch' => $patch,));
}
$scm = IDF_Scm::get($request->project);
}
$reviewers = Pluf_Model_RemoveDuplicates($reviewers);
return Pluf_Shortcuts_RenderToResponse('idf/review/view.html',
array_merge(
array(
'page_title' => $title,
'review' => $review,
'form' => $form,
'reviewers' => $reviewers,
),
IDF_Views_Issue::autoCompleteArrays($prj)
),
$request);
}
}
src/IDF/templates/idf/review/feedfragment.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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>
src/IDF/templates/idf/review/review-updated-email.txt
1010
1111
1212
13
13
14
15
16
17
18
19
1420
1521
1622
{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}
src/IDF/templates/idf/review/view.html
7878
7979
8080
81
82
81
82
8383
84
84
8585
8686
8787
......
100100
101101
102102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
103134
135
104136
105137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
106157
107158
108159
......
110161
111162
112163
113
164
114165
115166
116167
117168
118169
170
119171
{$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}
</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&amp;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>&nbsp;</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>
{/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}

Archive Download the corresponding diff file

Page rendered in 0.11559s using 14 queries.