Remove "additional scrum estimates" feature

hinted-selects
Vitaliy Filippov 2014-08-18 14:38:06 +04:00
parent 1886faf627
commit 1a63ab52c3
5 changed files with 6 additions and 208 deletions

View File

@ -1,119 +0,0 @@
#!/usr/bin/perl -wT
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Vitaliy Filippov <vfilippov@custis.ru>
use strict;
use lib qw(. lib);
use Bugzilla;
use Bugzilla::Constants;
use Bugzilla::Util;
use Bugzilla::Error;
use Bugzilla::Group;
use Bugzilla::Product;
use Bugzilla::User;
use Bugzilla::Token;
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
my $template = Bugzilla->template;
my $vars = {};
my $user = Bugzilla->login(LOGIN_REQUIRED);
my @bug_objects = map { Bugzilla::Bug->check($_) } ($cgi->param('id') =~ /(\d+)/gso);
# Make sure there are bugs
scalar(@bug_objects) || ThrowUserError("no_bugs_chosen", {action => 'scrum'});
my $sprint = $cgi->param('save') || $cgi->param('sprint_select') ? $cgi->param('sprint') || '' : undef;
my $type = $cgi->param('save') || $cgi->param('type_select') ? $cgi->param('type') || '' : undef;
defined $sprint and trick_taint($sprint);
defined $type and trick_taint($type);
my $sql = 'SELECT * FROM scrum_cards WHERE estimate!="" AND bug_id IN ('.join(',', ('?') x @bug_objects).')';
my @bind = map { $_->id } @bug_objects;
if (defined $sprint)
{
$sql .= ' AND sprint=?';
push @bind, $sprint;
}
if (defined $type)
{
$sql .= ' AND type=?';
push @bind, $type;
}
$sql .= ' ORDER BY bug_id, sprint, type';
$vars->{ids} = join ',', map { $_->id } @bug_objects;
$vars->{bugs} = \@bug_objects;
$vars->{sprint} = $sprint;
$vars->{type} = $type;
$vars->{sprint_select} = $cgi->param('sprint_select');
$vars->{type_select} = $cgi->param('type_select');
$vars->{cards} = [ grep { $_->{bug} = Bugzilla::Bug->new($_->{bug_id}) } @{ $dbh->selectall_arrayref($sql, {Slice=>{}}, @bind) || [] } ];
if (defined $sprint && defined $type)
{
if ($cgi->param('save'))
{
my $estimate = {};
my $del = {};
foreach ($cgi->param)
{
if (/^estimate_(\d+)$/s)
{
if ($cgi->param($_))
{
$estimate->{$1} = $cgi->param($_);
trick_taint($estimate->{$1});
}
else
{
$del->{$1} = 1;
}
}
}
if (%$del)
{
$sql = 'DELETE FROM scrum_cards WHERE sprint=? AND type=? AND bug_id IN ('.join(',', ('?') x keys %$del).')';
@bind = ($sprint, $type, keys %$del);
$dbh->do($sql, undef, @bind);
}
if (%$estimate)
{
$sql = 'REPLACE INTO scrum_cards (bug_id, sprint, type, estimate) VALUES '.
join(',', ('(?, ?, ?, ?)') x keys %$estimate);
@bind = map { ($_, $sprint, $type, $estimate->{$_}) } keys %$estimate;
$dbh->do($sql, undef, @bind);
}
print $cgi->redirect(-location => 'editscrum.cgi?sprint_select=1&type_select=1&sprint='.url_quote($sprint).'&type='.url_quote($type).'&id='.join(',', map { $_->id } @bug_objects));
exit;
}
$vars->{estimates} = { map { $_->{bug_id} => $_->{estimate} } @{$vars->{cards}} };
}
$template->process('scrum/edit.html.tmpl', $vars)
|| ThrowTemplateError($template->error());
exit;

View File

@ -112,11 +112,9 @@ sub refresh_some_views
$dbh->do($drop.'bugs');
$dbh->do($drop.'longdescs');
$dbh->do($drop.'bugs_activity');
$dbh->do($drop.'scrum_cards');
$dbh->do($create.'bugs AS '.$sql);
$dbh->do($create.'longdescs AS SELECT l.bug_id, u.login_name, l.bug_when, l.thetext, l.work_time FROM longdescs l INNER JOIN '.$bugids.' b ON b.bug_id=l.bug_id INNER JOIN profiles u ON u.userid=l.who'.($userobj->is_insider?'':' WHERE l.isprivate=0'));
$dbh->do($create.'bugs_activity AS SELECT a.bug_id, u.login_name, a.bug_when, f.name field_name, a.removed, a.added FROM bugs_activity a INNER JOIN '.$bugids.' b ON b.bug_id=a.bug_id INNER JOIN profiles u ON u.userid=a.who INNER JOIN fielddefs f ON f.id=a.fieldid');
$dbh->do($create.'scrum_cards AS SELECT s.* FROM scrum_cards s INNER JOIN '.$bugids.' b ON b.bug_id=s.bug_id');
}
# Restore current user
Bugzilla->request_cache->{user} = $old_user;

View File

@ -571,7 +571,7 @@ document.changeform = document.[% cfname %];
[% IF Param('webdotbase') %]
/&nbsp;<a href="showdependencygraph.cgi?id=[% bug.bug_id %]">graph</a>
[% END %]
[% PROCESS scrum_cards %]
</td>
</tr>

View File

@ -1,3 +1,8 @@
[%# SCRUM-like cards for bugs
# License: Dual-license GPL 3.0+ or MPL 1.1+
# Author(s): Vitaliy Filippov <vitalif@mail.ru>
#%]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

View File

@ -1,86 +0,0 @@
[% PROCESS global/header.html.tmpl
title = "Edit SCRUM card data for bugs"
style = style
%]
<p>Select sprint and type to edit time estimates. Both can be empty even when selected.</p>
<form action="?" method="GET">
<input type="hidden" name="id" value="[% ids | html %]" />
<input type="checkbox" name="sprint_select" id="sprint_select" onchange="document.getElementById('sprint').disabled=(this.checked?false:true)" value="1" [% " checked" IF sprint_select %] /> <label for="sprint_select">Filter by sprint:</label> <input type="text" name="sprint" [% ' disabled="false"' IF NOT sprint_select %] id="sprint" value="[% sprint | html %]" />
&nbsp; <input type="checkbox" name="type_select" id="type_select" onchange="document.getElementById('type').disabled=(this.checked?false:true)" value="1" [% " checked" IF type_select %] /> <label for="type_select">Filter by type:</label> <input type="text" name="type" id="type" [% ' disabled="false"' IF NOT type_select %] value="[% type | html %]" />
&nbsp; <input type="submit" value=" Select " />
</form>
[% IF estimates %]
<p><a href="buglist.cgi?regetlastlist=1&amp;columnlist=bug_severity%2Cpriority%2Cshort_desc%2Cestimated_time%2Cactual_time%2Ctarget_milestone&amp;format=scrum&amp;scrum_select=1&amp;scrum_sprint=[% sprint | url_quote | html %]&amp;scrum_type=[% type | url_quote | html %]">View Scrum Cards for last search</a></p>
<form action="?save=1" method="POST">
<input type="hidden" name="sprint" value="[% sprint | html %]" />
<input type="hidden" name="type" value="[% type | html %]" />
<input type="hidden" name="id" value="[% ids | html %]" />
<table cellpadding="3" id="estimates_table">
<tr style="background-color: #c0c0c0"><th>Bug</th><th>Sprint</th><th>Type</th><th>Time Estimate</th></tr>
[% FOR b = bugs %]
<tr>
<td><a href="show_bug.cgi?id=[% b.id %]">[% b.id %] - [% b.short_desc | html %]</a></td>
[% IF sprint %]
<td>[% sprint | html %]</td>
[% ELSE %]
<td style="background-color: #c0c0c0; color: gray">&lt;empty&gt;</td>
[% END %]
[% IF type %]
<td>[% type | html %]</td>
[% ELSE %]
<td style="background-color: #c0c0c0; color: gray">&lt;empty&gt;</td>
[% END %]
<td><input type="text" id="estimate_[% loop.count %]" name="estimate_[% b.id %]" value="[% estimates.${b.id} | html %]" onchange="update_hours_total()" /></td>
</tr>
[% END %]
<tr>
<th colspan="3" style="text-align: right; background-color: #c0c0c0">TOTAL:</th>
<td style="background-color: #c0c0c0" id="hours_total"></td>
</tr>
</table>
<script language="JavaScript">
function update_hours_total()
{
var i = 1, e, v, s = 0;
while (e = document.getElementById('estimate_'+i))
{
v = parseInt(e.value);
if (v == v)
s += v;
i++;
}
document.getElementById('hours_total').innerHTML = s;
}
update_hours_total();
</script>
<input type="submit" value="Save estimates" />
</form>
[% ELSIF cards.size %]
<table cellpadding="3">
<tr><th>Bug</th><th>Sprint</th><th>Type</th><th>Time Estimate</th></tr>
[% FOR c = cards %]
<tr>
<td><a href="show_bug.cgi?id=[% c.bug_id %]">[% c.bug.id %] - [% c.bug.short_desc | html %]</a></td>
[% IF c.sprint %]
<td>[% c.sprint | html %]</td>
[% ELSE %]
<td style="background-color: #c0c0c0; color: gray">&lt;empty&gt;</td>
[% END %]
[% IF c.type %]
<td>[% c.type | html %]</td>
[% ELSE %]
<td style="background-color: #c0c0c0; color: gray">&lt;empty&gt;</td>
[% END %]
<td align="center">[% c.estimate | html %]</td>
</tr>
[% END %]
</table>
[% ELSE %]
<p>No additional time estimates for these bugs are available yet.</p>
[% END %]
[% PROCESS global/footer.html.tmpl %]