Commit 52abf10f authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 313123: Implement $component->create and $component->update based on…

Bug 313123: Implement $component->create and $component->update based on Object.pm - Patch by Fré©ric Buclin <LpSolit@gmail.com> r/a=mkanat
parent 52fecc3e
......@@ -930,7 +930,7 @@ sub _check_component {
$name = trim($name);
$name || ThrowUserError("require_component");
($product = $invocant->product_obj) if ref $invocant;
my $obj = Bugzilla::Component::check_component($product, $name);
my $obj = Bugzilla::Component->check({ product => $product, name => $name });
return $obj;
}
......
......@@ -147,6 +147,7 @@ use File::Basename;
MAX_LEN_QUERY_NAME
MAX_MILESTONE_SIZE
MAX_COMPONENT_SIZE
);
@Bugzilla::Constants::EXPORT_OK = qw(contenttypes);
......@@ -410,6 +411,9 @@ use constant MAX_LEN_QUERY_NAME => 64;
# The longest milestone name allowed.
use constant MAX_MILESTONE_SIZE => 20;
# The longest component name allowed.
use constant MAX_COMPONENT_SIZE => 64;
sub bz_locations {
# We know that Bugzilla/Constants.pm must be in %INC at this point.
# So the only question is, what's the name of the directory
......
......@@ -431,6 +431,10 @@ A hash with one element, C<id>. This is the id of the newly-filed bug.
=over
=item 51 (Invalid Object)
The component you specified is not valid for this Product.
=item 103 (Invalid Alias)
The alias you specified is invalid for some reason. See the error message
......@@ -443,8 +447,7 @@ have more detail.
=item 105 (Invalid Component)
Either you didn't specify a component, or the component you specified was
invalid.
You didn't specify a component.
=item 106 (Invalid Product)
......
......@@ -50,6 +50,9 @@ use base qw(Exporter);
# comment that it was retired. Also, if an error changes its name, you'll
# have to fix it here.
use constant WS_ERROR_CODE => {
# Generic Bugzilla::Object errors are 50-99.
object_name_not_specified => 50,
object_does_not_exist => 51,
# Bug errors usually occupy the 100-200 range.
improper_bug_id_field_value => 100,
bug_id_does_not_exist => 101,
......@@ -65,7 +68,6 @@ use constant WS_ERROR_CODE => {
# Component errors
require_component => 105,
component_name_too_long => 105,
component_not_valid => 105,
# Invalid Product
no_products => 106,
entry_access_denied => 106,
......
......@@ -600,7 +600,8 @@ sub validateComponent {
($product && $product->id)
|| ThrowUserError("flag_type_component_without_product");
my $component = Bugzilla::Component::check_component($product, $component_name);
my $component = Bugzilla::Component->check({ product => $product,
name => $component_name });
return $component;
}
......
......@@ -196,8 +196,8 @@ sub queue {
push(@criteria, "bugs.product_id = " . $product->id);
push(@excluded_columns, 'product') unless $cgi->param('do_union');
if (defined $cgi->param('component') && $cgi->param('component') ne "") {
my $component =
Bugzilla::Component::check_component($product, scalar $cgi->param('component'));
my $component = Bugzilla::Component->check({ product => $product,
name => scalar $cgi->param('component') });
push(@criteria, "bugs.component_id = " . $component->id);
push(@excluded_columns, 'component') unless $cgi->param('do_union');
}
......
......@@ -95,8 +95,6 @@
<hr>
<input type="submit" id="create" value="Add">
<input type="hidden" name="action" value="new">
<input type="hidden" name='open_name' value='All Open'>
<input type="hidden" name='nonopen_name' value='All Closed'>
<input type="hidden" name='product' value="[% product.name FILTER html %]">
<input type="hidden" name="token" value="[% token FILTER html %]">
</form>
......
......@@ -21,27 +21,12 @@
#%]
[%# INTERFACE:
#
# 'updated_XXX' variables are booleans, and are defined if the
# 'XXX' field was updated during the edit just being handled.
#
# updated_name: the name of the component updated
#
# updated_description: the component description updated
#
# updated_initialowner: the default assignee updated
#
# updated_initialqacontact: the default qa contact updated
#
# updated_initialcc: the default initial cc list
# changes: hashref; contains changes made to the component.
#
# comp: object; Bugzilla::Component object representing the component
# user updated.
# product: object; Bugzilla::Product object representing the product to
# which the component belongs.
#
# initial_cc_names: a comma-separated list of the login names of
# the Initial CC, if it was updated.
#%]
[% title = BLOCK %]Updating Component '[% comp.name FILTER html %]' of Product
......@@ -50,7 +35,11 @@
title = title
%]
[% IF updated_description %]
[% IF changes.name.defined %]
<p>Updated Component name to: '[% comp.name FILTER html %]'.</p>
[% END %]
[% IF changes.description.defined %]
<table>
<tr>
<td>Updated description to:</td>
......@@ -59,11 +48,11 @@
</table>
[% END %]
[% IF updated_initialowner %]
[% IF changes.initialowner.defined %]
<p>Updated Default Assignee to: '[% comp.default_assignee.login FILTER html %]'.</p>
[% END %]
[% IF updated_initialqacontact %]
[% IF changes.initialqacontact.defined %]
<p>
[% IF comp.default_qa_contact.id %]
Updated Default QA Contact to '[% comp.default_qa_contact.login FILTER html %]'.
......@@ -73,22 +62,19 @@
</p>
[% END %]
[% IF updated_name %]
<p>Updated Component name to: '[% comp.name FILTER html %]'.</p>
[% END %]
[% IF updated_initialcc %]
[% IF initial_cc_names %]
<p>Updated Default CC list to:
'[% initial_cc_names FILTER html %]'.</p>
[% IF changes.cc_list.defined %]
[% IF comp.initial_cc.size %]
[% cc_list = [] %]
[% FOREACH cc_user = comp.initial_cc %]
[% cc_list.push(cc_user.login) %]
[% END %]
<p>Updated Default CC list to: [% cc_list.join(", ") FILTER html %].</p>
[% ELSE %]
<p>Removed the Default CC list.</p>
[% END %]
[% END %]
[% UNLESS updated_description || updated_initialowner ||
updated_initialqacontact || updated_name ||
updated_initialcc %]
[% UNLESS changes.keys.size %]
<p>Nothing changed for component '[% comp.name FILTER html %]'.</p>
[% END %]
......
......@@ -451,6 +451,12 @@
# we can still use get_text(). %]
[% PROCESS "admin/sanitycheck/messages.html.tmpl" %]
[% ELSIF message_tag == "series_all_open" %]
All Open
[% ELSIF message_tag == "series_all_closed" %]
All Closed
[% ELSIF message_tag == "sudo_started" %]
[% title = "Sudo session started" %]
The sudo session has been started. For the next 6 hours, or until you
......
......@@ -298,12 +298,13 @@
[% ELSIF error == "component_already_exists" %]
[% title = "Component Already Exists" %]
A component with the name '[% name FILTER html %]' already exists.
The <em>[% product.name FILTER html %]</em> product already has
a component named <em>[% name FILTER html %]</em>.
[% ELSIF error == "component_blank_description" %]
[% title = "Blank Component Description Not Allowed" %]
You must enter a non-blank description for component '[% name FILTER html %]'.
You must enter a non-blank description for this component.
[% ELSIF error == "component_blank_name" %]
[% title = "Blank Component Name Not Allowed" %]
You must enter a name for this new component.
......@@ -317,16 +318,11 @@
[% ELSIF error == "component_name_too_long" %]
[% title = "Component Name Is Too Long" %]
The name of a component is limited to 64 characters.
'[% name FILTER html %]' is too long ([% name.size %] characters).
'[% name FILTER html %]' is too long ([% name.length %] characters).
[% ELSIF error == "component_need_initialowner" %]
[% title = "Component Requires Default Assignee" %]
You must enter a default assignee for component '[% name FILTER html %]'.
[% ELSIF error == "component_not_valid" %]
[% title = "Specified Component Does Not Exist" %]
Product [% product FILTER html %] does not have a component
named [% name FILTER html %].
A default assignee is required for this component.
[% ELSIF error == "customfield_nonexistent" %]
[% title = "Unknown Custom Field" %]
......@@ -1620,6 +1616,8 @@
[% BLOCK object_name %]
[% IF class == "Bugzilla::User" %]
user
[% ELSIF class == "Bugzilla::Component" %]
component
[% ELSIF class == "Bugzilla::Version" %]
version
[% ELSIF class == "Bugzilla::Milestone" %]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment