diff options
author | Robert Haas | 2009-06-28 01:25:57 +0000 |
---|---|---|
committer | Robert Haas | 2009-06-28 01:25:57 +0000 |
commit | 4a189a0de87434c858dbb81b66220d70491ef8db (patch) | |
tree | ddcd729a25b56367e972151ba8690d3c098c5806 /perl-lib/PgCommitFest/Patch.pm | |
parent | 1ebc05578d5550f80a16fce84124f9f55f8373d4 (diff) |
Support for moving patches to another CommitFest.
Diffstat (limited to 'perl-lib/PgCommitFest/Patch.pm')
-rw-r--r-- | perl-lib/PgCommitFest/Patch.pm | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/perl-lib/PgCommitFest/Patch.pm b/perl-lib/PgCommitFest/Patch.pm index eda67d7..adad145 100644 --- a/perl-lib/PgCommitFest/Patch.pm +++ b/perl-lib/PgCommitFest/Patch.pm @@ -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' |