Support for moving patches to another CommitFest.
authorRobert Haas <[email protected]>
Sun, 28 Jun 2009 01:25:57 +0000 (21:25 -0400)
committerRobert Haas <[email protected]>
Sun, 28 Jun 2009 01:25:57 +0000 (21:25 -0400)
perl-lib/PgCommitFest/Handler.pm
perl-lib/PgCommitFest/Patch.pm
template/patch_bump.tt2 [new file with mode: 0644]
template/patch_form.tt2

index 89ed0247e0438e584a5203743c1e7f44bfadf706..d94e0421e6c4bd999ba79d15ec040e8c8c4456bc 100644 (file)
@@ -19,6 +19,7 @@ our %ACTION = (
        'commitfest_topic_delete'   => \&PgCommitFest::CommitFestTopic::delete,
        'commitfest_topic_form'     => \&PgCommitFest::CommitFestTopic::form,
        'commitfest_topic_search'   => \&PgCommitFest::CommitFestTopic::search,
+       'patch_bump'                        => \&PgCommitFest::Patch::bump,
        'patch_form'                        => \&PgCommitFest::Patch::form,
        'patch_delete'                      => \&PgCommitFest::Patch::delete,
        'patch_view'                        => \&PgCommitFest::Patch::view,
index eda67d7b797e1d2955ea5b837d927c62df0646f8..adad145d89834ab3bf83fafed6d61001a9b84b43 100644 (file)
@@ -2,6 +2,30 @@ package PgCommitFest::Patch;
 use strict;
 use warnings;
 
+sub bump {
+       my ($r) = @_;
+       $r->authenticate('require_login' => 1);
+       $r->set_title('Move Patch To New CommitFest');
+
+       # Fetch patch.
+       my $d = $r->db->select_one(<<EOM, $r->cgi_required_id);
+SELECT id, name, commitfest_id FROM patch_view WHERE id = ?
+EOM
+       $r->error_exit('Patch not found.') if !defined $d;
+       $r->set_title("Move Patch %s To Another CommitFest", $d->{'name'});
+       $r->add_link('/action/patch_view?id=' . $d->{'id'},
+               'Return to Patch View');
+
+       # Fetch list of commitfests.
+       my $list = $r->db->select(<<EOM, $d->{'commitfest_id'});
+SELECT id, name, commitfest_status FROM commitfest_view WHERE id != ?
+       ORDER BY name DESC
+EOM
+
+       # Display template.
+       $r->render_template('patch_bump', { 'd' => $d, 'list' => $list });
+}
+
 sub delete {
        my ($r) = @_;
        $r->authenticate('require_login' => 1);
@@ -38,7 +62,7 @@ sub form {
 
        # Decide whether this is a new patch or an edit of an existing
        # patch, and if editing reload data from database.
-       my $d;
+       my ($d, $cf);
        my $id = $r->cgi_id();
        if (defined $id) {
                $r->set_title('Edit Patch');
@@ -49,6 +73,14 @@ FROM patch_view WHERE id = ?
 EOM
                $r->error_exit('Patch not found.') if !defined $d;
                $r->redirect('/action/patch_view?id=' . $id) if $r->cgi('cancel');
+               my $cfid = $r->cgi_id('commitfest');
+               if (defined $cfid && $cfid != $d->{'commitfest_id'}) {
+                       $cf = $r->db->select_one(<<EOM, $cfid);
+SELECT id, name FROM commitfest WHERE id = ?
+EOM
+                       $r->error_exit('New CommitFest not found.') if !defined $cf;
+                       $d->{'commitfest_id'} = $cf->{'id'};
+               }
        }
        else {
                $d = $r->db->select_one(<<EOM, $r->cgi_required_id('commitfest'));
@@ -67,6 +99,7 @@ EOM
        my $commitfest_topic = $r->db->select(<<EOM, $d->{'commitfest_id'});
 SELECT id, name FROM commitfest_topic WHERE commitfest_id = ? ORDER BY name
 EOM
+       unshift @$commitfest_topic, { 'id' => '', 'name' => '(None Selected)' };
        $r->control('commitfest_topic')->choice($commitfest_topic);
        $r->add_control('patch_status', 'select', 'Patch Status', 'required' => 1);
        $r->control('patch_status')->choice($r->db->select(<<EOM));
@@ -120,7 +153,8 @@ EOM
 
        # Display template.
        $r->render_template('patch_form', { 'id' => $id, 'd' => $d,
-               'commitfest_topic_warning' => !@$commitfest_topic });
+               'commitfest_topic_warning' => !@$commitfest_topic,
+               'new_commitfest' => $cf });
 }
 
 sub view {
@@ -143,6 +177,8 @@ EOM
        $r->add_link('/action/patch_comment_form?patch=' . $id,
                'New Comment');
        $r->add_link('/action/patch_form?id=' . $id, 'Edit Patch');
+       $r->add_link('/action/patch_bump?id=' . $id,
+               'Move To Another CommitFest');
        $r->add_link('/action/patch_delete?id=' . $id, 'Delete Patch',
                'Are you sure you want to delete this patch?');
        $r->render_template('patch_view', { 'd' => $d, 'patch_comment_list'
diff --git a/template/patch_bump.tt2 b/template/patch_bump.tt2
new file mode 100644 (file)
index 0000000..da5730b
--- /dev/null
@@ -0,0 +1,20 @@
+<p>Please select the CommitFest to which you wish to move this patch.</p>
+
+[% IF list.size == 0 %]
+<p><b>No other CommitFests exist.</b></p>
+[% ELSE %]
+<div class='tblBasic'>
+<table cellspacing='0' class='tblBasicGrey'>
+<tr>
+  <th class='colFirst'>CommitFest Name</th>
+  <th class='colLast'>Status</th>
+</tr>
+[% FOREACH x = list %]
+<tr[% IF loop.last %] class='lastrow'[% END %]>
+  <td class='colFirst'><a href='/action/patch_form?id=[% d.id %]&commitfest=[% x.id %]'>[% x.name | htmlsafe %]</a></td>
+  <td class='colLast'>[% x.commitfest_status | htmlsafe %]</td>
+</tr>
+[% END %]
+</table>
+</div>
+[% END %]
index 6505fe9f41b00404d64eaee6481956a8aa28636a..91ed836ac2f8cb335e091907893f65021cba3be3 100644 (file)
@@ -1,9 +1,20 @@
+[% IF new_commitfest %]
+<p class='error'>You are moving this patch to a different CommitFest.  Since
+topics are CommitFest-specific, you must select an appropriate topic for this
+patch from among those defined for the target CommitFest.
+<input name='commitfest' type='hidden' value='[% new_commitfest.id %]'></p>
+[% SET nopara = 1 %]
+[% END %]
+
 [% IF commitfest_topic_warning %]
 <p class='error'>Note: No topics have been defined for this CommitFest.
 Before you can add patches to this CommitFest, you will need to visit the
 <a href='/action/commitfest_topic_search?id=[% d.commitfest_id %]'>CommitFest
-Topics</a> page and add one or more topics.
-[% ELSE %]
+Topics</a> page and add one or more topics.</p>
+[% SET nopara = 1 %]
+[% END %]
+
+[% IF !nopara  %]
 <p></p>
 [% END %]