diff options
author | Robert Haas | 2009-07-04 02:57:19 +0000 |
---|---|---|
committer | Robert Haas | 2009-07-04 02:57:19 +0000 |
commit | 79cc52bfb6d11862080b1d03e674e39355289ec2 (patch) | |
tree | 12a176a0b72c46710f8194d3eb7b3a2c1335dd23 | |
parent | 62159b9e086d901b37e9b7ca1d2b58264e4f574e (diff) |
Add comments to patches from patch view page.
As suggested by Tom Lane and others.
-rw-r--r-- | perl-lib/PgCommitFest/Patch.pm | 16 | ||||
-rw-r--r-- | perl-lib/PgCommitFest/PatchComment.pm | 21 | ||||
-rw-r--r-- | template/patch_comment_form.tt2 | 2 | ||||
-rw-r--r-- | template/patch_view.tt2 | 9 |
4 files changed, 37 insertions, 11 deletions
diff --git a/perl-lib/PgCommitFest/Patch.pm b/perl-lib/PgCommitFest/Patch.pm index adad145..fe9a720 100644 --- a/perl-lib/PgCommitFest/Patch.pm +++ b/perl-lib/PgCommitFest/Patch.pm @@ -159,6 +159,7 @@ EOM sub view { my ($r) = @_; + my $aa = $r->authenticate(); my $id = $r->cgi_id(); my $d = $r->db->select_one(<<EOM, $id) if defined $id; SELECT id, name, commitfest_id, commitfest, commitfest_topic_id, @@ -174,8 +175,19 @@ to_char(v.creation_time, 'YYYY-MM-DD HH:MI:SS AM') AS creation_time FROM patch_comment_view v WHERE v.patch_id = ? ORDER BY v.creation_time EOM - $r->add_link('/action/patch_comment_form?patch=' . $id, - 'New Comment'); + # Add patch comment controls, so that users can add a patch comment + # without needing to visit a separate page. + if (defined $aa) { + my %value = PgCommitFest::PatchComment::controls($r, {}); + if ($r->cgi('go') && ! $r->is_error()) { + $value{'patch_id'} = $d->{'id'}; + $value{'creator'} = $aa->{'userid'}; + $r->db->insert('patch_comment', \%value); + $r->db->commit; + $r->redirect('/action/patch_view?id=' . $d->{'id'}); + } + } + $r->add_link('/action/patch_form?id=' . $id, 'Edit Patch'); $r->add_link('/action/patch_bump?id=' . $id, 'Move To Another CommitFest'); diff --git a/perl-lib/PgCommitFest/PatchComment.pm b/perl-lib/PgCommitFest/PatchComment.pm index 101a784..ccc804c 100644 --- a/perl-lib/PgCommitFest/PatchComment.pm +++ b/perl-lib/PgCommitFest/PatchComment.pm @@ -2,6 +2,18 @@ package PgCommitFest::PatchComment; use strict; use warnings; +sub controls { + my ($r, $d) = @_; + $r->add_control('patch_comment_type', 'select', 'Comment Type', + 'required' => 1); + $r->control('patch_comment_type')->choice($r->db->select(<<EOM)); +SELECT id, name FROM patch_comment_type ORDER BY id +EOM + $r->add_control('message_id', 'text', 'Message-ID', 'maxlength' => 255); + $r->add_control('content', 'textarea', 'Content', 'required' => 1); + return $r->initialize_controls($d); +} + sub delete { my ($r) = @_; my $aa = $r->authenticate('require_login' => 1); @@ -65,14 +77,7 @@ EOM if $r->cgi('cancel'); # Add controls. - $r->add_control('patch_comment_type', 'select', 'Comment Type', - 'required' => 1); - $r->control('patch_comment_type')->choice($r->db->select(<<EOM)); -SELECT id, name FROM patch_comment_type ORDER BY id -EOM - $r->add_control('message_id', 'text', 'Message-ID', 'maxlength' => 255); - $r->add_control('content', 'textarea', 'Content', 'required' => 1); - my %value = $r->initialize_controls($d); + my %value = controls($r, $d); # Handle commit. if ($r->cgi('go') && ! $r->is_error()) { diff --git a/template/patch_comment_form.tt2 b/template/patch_comment_form.tt2 index 624f73a..18fb56f 100644 --- a/template/patch_comment_form.tt2 +++ b/template/patch_comment_form.tt2 @@ -22,4 +22,4 @@ provided.</p> <div><input type='submit' value='Submit'> <input name='cancel' type='submit' value='Cancel'> <input name='go' type='hidden' value='1'> -[% IF id %]<input name='id' type='hidden' value='[% id %]'>[% ELSE %]<input name='patch' type='hidden' value='[% d.patch_id %]'>[% END %]</div> +[% IF is_included %]<input name='id' type='hidden' value='[% d.id %]'>[% ELSIF id %]<input name='id' type='hidden' value='[% id %]'>[% ELSE %]<input name='patch' type='hidden' value='[% d.patch_id %]'>[% END %]</div> diff --git a/template/patch_view.tt2 b/template/patch_view.tt2 index 37a9fa0..6448011 100644 --- a/template/patch_view.tt2 +++ b/template/patch_view.tt2 @@ -37,3 +37,12 @@ </tr> </table> </div> + +<h2 style='margin: 0px'>Add Comment</h2> +[% IF authenticate %] +[% INCLUDE patch_comment_form.tt2 is_included='1' %] +[% ELSE %] +<p>Please +<a href='/https/git.postgresql.org/action/login?uri=/action/patch_view?id=[% d.id %]'>log in</a> +to comment on this patch.</p> +[% END %] |