[Codestriker-commits] CVS update: codestriker/lib/Codestriker/Action SubmitNewTopic.pm CreateTopic.
Brought to you by:
sits
From: <si...@us...> - 2008-08-19 10:50:20
|
User: sits Date: 08/08/19 03:50:18 Modified: lib/Codestriker/Model Topic.pm bin codestriker.pl.base . CHANGELOG lib/Codestriker/Http Input.pm template/en/default viewtopicproperties.html.tmpl createtopic.html.tmpl lib/Codestriker/Action SubmitNewTopic.pm CreateTopic.pm Log: * Added a drop-down on the topic create page where the initial topic state can be set. By default, this is set to "Open", however in situations where a review has already been performed but needs to be recorded, or a topic is automatically created from a post-commit script from an SCM, sometimes another initial state is desirable. Index: Topic.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Model/Topic.pm,v retrieving revision 1.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- Topic.pm 15 Aug 2008 06:30:38 -0000 1.50 +++ Topic.pm 19 Aug 2008 10:50:14 -0000 1.51 @@ -117,11 +117,21 @@ # Create a new topic with all of the specified properties. sub create($$$$$$$$$$$$) { - my ($self, $topicid, $author, $title, $bug_ids, $reviewers, $cc, + my ($self, $topicid, $author, $title, $state, $bug_ids, $reviewers, $cc, $description, $document, $start_tag, $end_tag, $module, $repository, $projectid, $deltas_ref, $obsoleted_topics) = @_; my $timestamp = Codestriker->get_timestamp(time); + + # Map the state to its number. + my $stateid; + for ($stateid = 0; $stateid <= $#Codestriker::topic_states; + $stateid++) { + last if ($Codestriker::topic_states[$stateid] eq $state); + } + if ($stateid > $#Codestriker::topic_states) { + die "Unable to create topic to invalid state: \"$state\""; + } $self->{topicid} = $topicid; $self->{author} = $author; @@ -133,8 +143,8 @@ $self->{document} = $document; $self->{creation_ts} = $timestamp; $self->{modified_ts} = $timestamp; - $self->{topic_state} = 0; - $self->{topic_state_id} = 0; + $self->{topic_state} = $state; + $self->{topic_state_id} = $stateid; $self->{project_id} = $projectid; $self->{version} = 0; $self->{start_tag} = $start_tag; @@ -157,10 +167,9 @@ 'VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'); my $success = defined $insert_topic; - # Create all of the necessary rows. It is assumed state 0 is the initial - # state. + # Create all of the necessary rows. $success &&= $insert_topic->execute($topicid, $author, $title, - $description, $document, 0, + $description, $document, $stateid, $timestamp, $timestamp, 0, $start_tag, $end_tag, $module, $repository, $projectid); Index: codestriker.pl.base =================================================================== RCS file: /cvsroot/codestriker/codestriker/bin/codestriker.pl.base,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- codestriker.pl.base 13 Aug 2008 11:30:47 -0000 1.27 +++ codestriker.pl.base 19 Aug 2008 10:50:14 -0000 1.28 @@ -128,7 +128,6 @@ # Process the HTTP input to ensure it is consistent. my $http_input = Codestriker::Http::Input->new($query, $http_response); - $http_input->process(); my $dispatcher = Codestriker::Http::Dispatcher->new($query); $dispatcher->dispatch($http_input, $http_response); Index: CHANGELOG =================================================================== RCS file: /cvsroot/codestriker/codestriker/CHANGELOG,v retrieving revision 1.260 retrieving revision 1.261 diff -u -r1.260 -r1.261 --- CHANGELOG 13 Aug 2008 05:09:05 -0000 1.260 +++ CHANGELOG 19 Aug 2008 10:50:15 -0000 1.261 @@ -13,7 +13,13 @@ * Creating Perforce topics directly from already committed files in the depot did not work if the depot was on a different machine to the - web-server. This has now been fixed. + web-server. This has now been fixed. + +* Added a drop-down on the topic create page where the initial topic + state can be set. By default, this is set to "Open", however in + situations where a review has already been performed but needs to + be recorded, or a topic is automatically created from a post-commit + script from an SCM, sometimes another initial state is desirable. Version 1.9.6 Index: Input.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/Input.pm,v retrieving revision 1.48 retrieving revision 1.49 diff -u -r1.48 -r1.49 --- Input.pm 10 Aug 2008 12:18:44 -0000 1.48 +++ Input.pm 19 Aug 2008 10:50:16 -0000 1.49 @@ -105,16 +105,9 @@ my @selected_comments = $query->param('selected_comments'); $self->{selected_comments} = \@selected_comments; $self->{default_to_head} = $query->param('default_to_head'); -} - -# Process the CGI parameters, and untaint them. If any of them look -# suspicious, immediately output an error. -sub process($) { - my ($self) = @_; - my $query = $self->{query}; + # Set any missing parameters from the cookie. my %cookie = Codestriker::Http::Cookie->get($query); - $self->extract_cgi_parameters(); # Set things to the empty string rather than undefined. $self->{cc} = "" if ! defined $self->{cc}; @@ -293,7 +286,7 @@ my %cookie = Codestriker::Http::Cookie->get($self->{query}); if (! defined $self->{$name} || $self->{$name} eq "") { - $self->{$name} = exists $cookie{$name} ? $cookie{$name} : $default; + $self->{$name} = exists $cookie{$name} && $cookie{$name} ne "" ? $cookie{$name} : $default; } } Index: viewtopicproperties.html.tmpl =================================================================== RCS file: /cvsroot/codestriker/codestriker/template/en/default/viewtopicproperties.html.tmpl,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- viewtopicproperties.html.tmpl 8 Aug 2008 07:02:08 -0000 1.28 +++ viewtopicproperties.html.tmpl 19 Aug 2008 10:50:17 -0000 1.29 @@ -195,7 +195,7 @@ <tr class="tt1"> <td>State: <FONT SIZE="-2"><A HREF="javascript:alert(' -When a topic is created, it is initialised in state \'open\'.\n +When a topic is created, it is by default in state \'open\'.\n Once a topic has been reviewed, and the code has been committed,\n the state should be updated to \'committed\'. If the code\n in this review is not to be committed, perhaps because a\n Index: createtopic.html.tmpl =================================================================== RCS file: /cvsroot/codestriker/codestriker/template/en/default/createtopic.html.tmpl,v retrieving revision 1.55 retrieving revision 1.56 diff -u -r1.55 -r1.56 --- createtopic.html.tmpl 17 Aug 2008 22:25:37 -0000 1.55 +++ createtopic.html.tmpl 19 Aug 2008 10:50:17 -0000 1.56 @@ -20,8 +20,8 @@ <p> [% END %] -<FORM METHOD="post" ENCTYPE="multipart/form-data" ACCEPT-CHARSET="UTF-8" action="[% add_topic_url %]"> -<!-- <INPUT TYPE="hidden" NAME="action" VALUE="submit_new_topic" /> --> +<FORM METHOD="post" ENCTYPE="multipart/form-data" ACCEPT-CHARSET="UTF-8"> +<INPUT TYPE="hidden" NAME="action" VALUE="submit_new_topic" /> <INPUT TYPE="hidden" NAME="obsoletes" VALUE="[% obsoletes %]" /> [%# The topic title input field #%] @@ -256,6 +256,40 @@ </TD> <TD COLSPAN="3"><INPUT TYPE="text" NAME="cc" VALUE="[% cc | html_entity %]" SIZE=50 MAXLENGTH=1024 /></TD> </TR> + +<tr> + <td>State: + <FONT SIZE="-2"><a href="javascript:void(0);" +onmouseover="return create_window('When a topic is created, it is by default in state \'open\'.\ +Once a topic has been reviewed, and the code has been committed, \ +the state should be updated to \'committed\'. If the code \ +in this review is not to be committed, perhaps because a \ +new review will superceed this one, or because it was rejected, \ +the state should be changed to \'closed\'. \ +\ +If a topic is linked to Bugzilla bugs, each time the topic \ +state is changed, an appropriate comment will be appended to \ +all associated bugs, as a form of tracking. \ +\ +The topic states are also useful as a form of filtering, when \ +retrieving lists of topics from the search page. \ +\ +This topic can be superceeded by a new topic, by selecting the \ +state \'obsoleted\'')">(?)</A></FONT> + </td> + <td> + [%# Now display the option button for changing the topic state #%] + <select name="topic_state"> + [% FOREACH state = states %] + [% IF state == 'Open' %] + <option selected value="[% state %]">[% state %]</option> + [% ELSIF state != 'Deleted' && state != 'Obsoleted' %] + <option value="[% state %]">[% state %]</option> + [% END %] + [% END %] + </select> + </td> +</tr> </TABLE> <P> Index: SubmitNewTopic.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/SubmitNewTopic.pm,v retrieving revision 1.36 retrieving revision 1.37 diff -u -r1.36 -r1.37 --- SubmitNewTopic.pm 17 Aug 2008 22:25:36 -0000 1.36 +++ SubmitNewTopic.pm 19 Aug 2008 10:50:17 -0000 1.37 @@ -45,6 +45,7 @@ my $module = $http_input->get('module'); my $obsoletes = $http_input->get('obsoletes'); my $default_to_head = $http_input->get('default_to_head'); + my $topic_state = $http_input->get('topic_state'); my $feedback = ""; my $topic_text = ""; @@ -66,6 +67,11 @@ } } + # Check if the state is valid. + if (! grep /^$topic_state$/, @Codestriker::topic_states) { + $http_response->error("Topic state $topic_state unrecognised"); + } + if ($topic_title eq "") { $feedback .= "No topic title was entered.\n"; } @@ -325,7 +331,7 @@ # Create the topic in the model. my $topic = Codestriker::Model::Topic->new($topicid); - $topic->create($topicid, $email, $topic_title, + $topic->create($topicid, $email, $topic_title, $topic_state, $bug_ids, $reviewers, $cc, $topic_description, $topic_text, $start_tag, $end_tag, $module, @@ -346,7 +352,7 @@ # Tell all of the topic listener classes that a topic has # just been created. $feedback = Codestriker::TopicListeners::Manager::topic_create($topic); - + # Obtain a URL builder object and determine the URL to the topic. my $topic_url = $url_builder->view_url(topicid => $topicid, projectid => $projectid); Index: CreateTopic.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/CreateTopic.pm,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- CreateTopic.pm 17 Aug 2008 22:25:36 -0000 1.32 +++ CreateTopic.pm 19 Aug 2008 10:50:17 -0000 1.33 @@ -33,6 +33,7 @@ $vars->{'topic_description'} = ""; $vars->{'topic_title'} = $http_input->get('topic_title'); $vars->{'bug_ids'} = $http_input->get('bug_ids'); + $vars->{'states'} = \@Codestriker::topic_states; $vars->{'feedback'} = $http_input->get('feedback'); $vars->{'default_to_head'} = ""; |