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 | |
parent | 1ebc05578d5550f80a16fce84124f9f55f8373d4 (diff) |
Support for moving patches to another CommitFest.
-rw-r--r-- | perl-lib/PgCommitFest/Handler.pm | 1 | ||||
-rw-r--r-- | perl-lib/PgCommitFest/Patch.pm | 40 | ||||
-rw-r--r-- | template/patch_bump.tt2 | 20 | ||||
-rw-r--r-- | template/patch_form.tt2 | 15 |
4 files changed, 72 insertions, 4 deletions
diff --git a/perl-lib/PgCommitFest/Handler.pm b/perl-lib/PgCommitFest/Handler.pm index 89ed024..d94e042 100644 --- a/perl-lib/PgCommitFest/Handler.pm +++ b/perl-lib/PgCommitFest/Handler.pm @@ -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, 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' diff --git a/template/patch_bump.tt2 b/template/patch_bump.tt2 new file mode 100644 index 0000000..da5730b --- /dev/null +++ b/template/patch_bump.tt2 @@ -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='/https/git.postgresql.org/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 %] diff --git a/template/patch_form.tt2 b/template/patch_form.tt2 index 6505fe9..91ed836 100644 --- a/template/patch_form.tt2 +++ b/template/patch_form.tt2 @@ -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='/https/git.postgresql.org/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 %] |