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 { ...@@ -930,7 +930,7 @@ sub _check_component {
$name = trim($name); $name = trim($name);
$name || ThrowUserError("require_component"); $name || ThrowUserError("require_component");
($product = $invocant->product_obj) if ref $invocant; ($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; return $obj;
} }
......
...@@ -147,6 +147,7 @@ use File::Basename; ...@@ -147,6 +147,7 @@ use File::Basename;
MAX_LEN_QUERY_NAME MAX_LEN_QUERY_NAME
MAX_MILESTONE_SIZE MAX_MILESTONE_SIZE
MAX_COMPONENT_SIZE
); );
@Bugzilla::Constants::EXPORT_OK = qw(contenttypes); @Bugzilla::Constants::EXPORT_OK = qw(contenttypes);
...@@ -410,6 +411,9 @@ use constant MAX_LEN_QUERY_NAME => 64; ...@@ -410,6 +411,9 @@ use constant MAX_LEN_QUERY_NAME => 64;
# The longest milestone name allowed. # The longest milestone name allowed.
use constant MAX_MILESTONE_SIZE => 20; use constant MAX_MILESTONE_SIZE => 20;
# The longest component name allowed.
use constant MAX_COMPONENT_SIZE => 64;
sub bz_locations { sub bz_locations {
# We know that Bugzilla/Constants.pm must be in %INC at this point. # 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 # 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. ...@@ -431,6 +431,10 @@ A hash with one element, C<id>. This is the id of the newly-filed bug.
=over =over
=item 51 (Invalid Object)
The component you specified is not valid for this Product.
=item 103 (Invalid Alias) =item 103 (Invalid Alias)
The alias you specified is invalid for some reason. See the error message The alias you specified is invalid for some reason. See the error message
...@@ -443,8 +447,7 @@ have more detail. ...@@ -443,8 +447,7 @@ have more detail.
=item 105 (Invalid Component) =item 105 (Invalid Component)
Either you didn't specify a component, or the component you specified was You didn't specify a component.
invalid.
=item 106 (Invalid Product) =item 106 (Invalid Product)
......
...@@ -50,6 +50,9 @@ use base qw(Exporter); ...@@ -50,6 +50,9 @@ use base qw(Exporter);
# comment that it was retired. Also, if an error changes its name, you'll # comment that it was retired. Also, if an error changes its name, you'll
# have to fix it here. # have to fix it here.
use constant WS_ERROR_CODE => { 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. # Bug errors usually occupy the 100-200 range.
improper_bug_id_field_value => 100, improper_bug_id_field_value => 100,
bug_id_does_not_exist => 101, bug_id_does_not_exist => 101,
...@@ -65,7 +68,6 @@ use constant WS_ERROR_CODE => { ...@@ -65,7 +68,6 @@ use constant WS_ERROR_CODE => {
# Component errors # Component errors
require_component => 105, require_component => 105,
component_name_too_long => 105, component_name_too_long => 105,
component_not_valid => 105,
# Invalid Product # Invalid Product
no_products => 106, no_products => 106,
entry_access_denied => 106, entry_access_denied => 106,
......
...@@ -600,7 +600,8 @@ sub validateComponent { ...@@ -600,7 +600,8 @@ sub validateComponent {
($product && $product->id) ($product && $product->id)
|| ThrowUserError("flag_type_component_without_product"); || 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; return $component;
} }
......
...@@ -196,8 +196,8 @@ sub queue { ...@@ -196,8 +196,8 @@ sub queue {
push(@criteria, "bugs.product_id = " . $product->id); push(@criteria, "bugs.product_id = " . $product->id);
push(@excluded_columns, 'product') unless $cgi->param('do_union'); push(@excluded_columns, 'product') unless $cgi->param('do_union');
if (defined $cgi->param('component') && $cgi->param('component') ne "") { if (defined $cgi->param('component') && $cgi->param('component') ne "") {
my $component = my $component = Bugzilla::Component->check({ product => $product,
Bugzilla::Component::check_component($product, scalar $cgi->param('component')); name => scalar $cgi->param('component') });
push(@criteria, "bugs.component_id = " . $component->id); push(@criteria, "bugs.component_id = " . $component->id);
push(@excluded_columns, 'component') unless $cgi->param('do_union'); push(@excluded_columns, 'component') unless $cgi->param('do_union');
} }
......
...@@ -95,8 +95,6 @@ ...@@ -95,8 +95,6 @@
<hr> <hr>
<input type="submit" id="create" value="Add"> <input type="submit" id="create" value="Add">
<input type="hidden" name="action" value="new"> <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='product' value="[% product.name FILTER html %]">
<input type="hidden" name="token" value="[% token FILTER html %]"> <input type="hidden" name="token" value="[% token FILTER html %]">
</form> </form>
......
...@@ -21,27 +21,12 @@ ...@@ -21,27 +21,12 @@
#%] #%]
[%# INTERFACE: [%# INTERFACE:
# # changes: hashref; contains changes made to the component.
# '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
# #
# comp: object; Bugzilla::Component object representing the component # comp: object; Bugzilla::Component object representing the component
# user updated. # user updated.
# product: object; Bugzilla::Product object representing the product to # product: object; Bugzilla::Product object representing the product to
# which the component belongs. # 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 [% title = BLOCK %]Updating Component '[% comp.name FILTER html %]' of Product
...@@ -50,7 +35,11 @@ ...@@ -50,7 +35,11 @@
title = title 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> <table>
<tr> <tr>
<td>Updated description to:</td> <td>Updated description to:</td>
...@@ -59,11 +48,11 @@ ...@@ -59,11 +48,11 @@
</table> </table>
[% END %] [% END %]
[% IF updated_initialowner %] [% IF changes.initialowner.defined %]
<p>Updated Default Assignee to: '[% comp.default_assignee.login FILTER html %]'.</p> <p>Updated Default Assignee to: '[% comp.default_assignee.login FILTER html %]'.</p>
[% END %] [% END %]
[% IF updated_initialqacontact %] [% IF changes.initialqacontact.defined %]
<p> <p>
[% IF comp.default_qa_contact.id %] [% IF comp.default_qa_contact.id %]
Updated Default QA Contact to '[% comp.default_qa_contact.login FILTER html %]'. Updated Default QA Contact to '[% comp.default_qa_contact.login FILTER html %]'.
...@@ -73,22 +62,19 @@ ...@@ -73,22 +62,19 @@
</p> </p>
[% END %] [% END %]
[% IF updated_name %] [% IF changes.cc_list.defined %]
<p>Updated Component name to: '[% comp.name FILTER html %]'.</p> [% IF comp.initial_cc.size %]
[% END %] [% cc_list = [] %]
[% FOREACH cc_user = comp.initial_cc %]
[% IF updated_initialcc %] [% cc_list.push(cc_user.login) %]
[% IF initial_cc_names %] [% END %]
<p>Updated Default CC list to: <p>Updated Default CC list to: [% cc_list.join(", ") FILTER html %].</p>
'[% initial_cc_names FILTER html %]'.</p>
[% ELSE %] [% ELSE %]
<p>Removed the Default CC list.</p> <p>Removed the Default CC list.</p>
[% END %] [% END %]
[% END %] [% END %]
[% UNLESS updated_description || updated_initialowner || [% UNLESS changes.keys.size %]
updated_initialqacontact || updated_name ||
updated_initialcc %]
<p>Nothing changed for component '[% comp.name FILTER html %]'.</p> <p>Nothing changed for component '[% comp.name FILTER html %]'.</p>
[% END %] [% END %]
......
...@@ -451,6 +451,12 @@ ...@@ -451,6 +451,12 @@
# we can still use get_text(). %] # we can still use get_text(). %]
[% PROCESS "admin/sanitycheck/messages.html.tmpl" %] [% 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" %] [% ELSIF message_tag == "sudo_started" %]
[% title = "Sudo session started" %] [% title = "Sudo session started" %]
The sudo session has been started. For the next 6 hours, or until you The sudo session has been started. For the next 6 hours, or until you
......
...@@ -298,12 +298,13 @@ ...@@ -298,12 +298,13 @@
[% ELSIF error == "component_already_exists" %] [% ELSIF error == "component_already_exists" %]
[% title = "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" %] [% ELSIF error == "component_blank_description" %]
[% title = "Blank Component Description Not Allowed" %] [% 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" %] [% ELSIF error == "component_blank_name" %]
[% title = "Blank Component Name Not Allowed" %] [% title = "Blank Component Name Not Allowed" %]
You must enter a name for this new component. You must enter a name for this new component.
...@@ -317,16 +318,11 @@ ...@@ -317,16 +318,11 @@
[% ELSIF error == "component_name_too_long" %] [% ELSIF error == "component_name_too_long" %]
[% title = "Component Name Is Too Long" %] [% title = "Component Name Is Too Long" %]
The name of a component is limited to 64 characters. 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" %] [% ELSIF error == "component_need_initialowner" %]
[% title = "Component Requires Default Assignee" %] [% title = "Component Requires Default Assignee" %]
You must enter a default assignee for component '[% name FILTER html %]'. A default assignee is required for this component.
[% ELSIF error == "component_not_valid" %]
[% title = "Specified Component Does Not Exist" %]
Product [% product FILTER html %] does not have a component
named [% name FILTER html %].
[% ELSIF error == "customfield_nonexistent" %] [% ELSIF error == "customfield_nonexistent" %]
[% title = "Unknown Custom Field" %] [% title = "Unknown Custom Field" %]
...@@ -1620,6 +1616,8 @@ ...@@ -1620,6 +1616,8 @@
[% BLOCK object_name %] [% BLOCK object_name %]
[% IF class == "Bugzilla::User" %] [% IF class == "Bugzilla::User" %]
user user
[% ELSIF class == "Bugzilla::Component" %]
component
[% ELSIF class == "Bugzilla::Version" %] [% ELSIF class == "Bugzilla::Version" %]
version version
[% ELSIF class == "Bugzilla::Milestone" %] [% 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