diff options
Diffstat (limited to 'extensions/MozProjectReview/Extension.pm')
-rw-r--r-- | extensions/MozProjectReview/Extension.pm | 155 |
1 files changed, 33 insertions, 122 deletions
diff --git a/extensions/MozProjectReview/Extension.pm b/extensions/MozProjectReview/Extension.pm index fcad6916c..f85822d4d 100644 --- a/extensions/MozProjectReview/Extension.pm +++ b/extensions/MozProjectReview/Extension.pm @@ -12,23 +12,14 @@ use warnings; use base qw(Bugzilla::Extension); +our $VERSION = '0.01'; + use Bugzilla::User; use Bugzilla::Group; use Bugzilla::Error; use Bugzilla::Constants; -our $VERSION = '0.01'; - -# these users will be cc'd to the parent bug when the corresponding child bug -# is created, as well as the child bug. -our %auto_cc = ( - 'legal' => ['liz@mozilla.com'], - 'finance' => ['waoieong@mozilla.com', 'mcristobal@mozilla.com', 'echoe@mozilla.com'], - 'privacy-vendor' => ['smartin@mozilla.com'], - 'privacy-project' => ['ahua@mozilla.com'], - 'privacy-tech' => ['ahua@mozilla.com'], - 'policy-business-partner' => ['smartin@mozilla.com'] -); +use List::MoreUtils qw(any); sub post_bug_after_creation { my ($self, $args) = @_; @@ -39,50 +30,28 @@ sub post_bug_after_creation { my $params = Bugzilla->input_params; my $template = Bugzilla->template; - return if !($params->{format} - && $params->{format} eq 'moz-project-review' - && $bug->component eq 'Project Review'); + return if !($params->{format} && $params->{format} eq 'moz-project-review'); # do a match if applicable Bugzilla::User::match_field({ - 'legal_cc' => { 'type' => 'multi' } + 'sow_vendor_mozcontact' => { 'type' => 'single' }, }); - my ($do_sec_review, $do_legal, $do_finance, $do_data_compliance); - - if ($params->{'mozilla_data'} eq 'Yes') { - $do_legal = 1; - $do_data_compliance = 1; + my $do_sec_review = 0; + my @sec_review_needed = ( + 'Engaging a new vendor company', + 'Engaging an individual (independent contractor, temp agency worker, incorporated)', + 'Adding a new SOW with a vendor', + 'Extending an SOW or renewing a contract', + 'Purchasing software', + 'Signing up for an online service', + ); + if ((any { $_ eq $params->{contract_type} } @sec_review_needed) + || $params->{mozilla_data} eq 'Yes') { $do_sec_review = 1; } - if ($params->{'separate_party'} eq 'Yes') { - if ($params->{'relationship_type'} ne 'Hardware Purchase') { - $do_legal = 1; - } - - if ($params->{'data_access'} eq 'Yes') { - $do_data_compliance = 1; - $do_legal = 1; - $do_sec_review = 1; - } - - if ($params->{'data_access'} eq 'Yes' - && $params->{'privacy_policy_vendor_user_data'} eq 'Yes') - { - $do_data_compliance = 1; - } - - if ($params->{'vendor_cost'} eq '> $25,000' - || ($params->{'vendor_cost'} eq '<= $25,000' - && $params->{'po_needed'} eq 'Yes')) - { - $do_finance = 1; - } - } - - my ($sec_review_bug, $legal_bug, $finance_bug, $data_compliance_bug, - $error, @dep_comment, @dep_errors, @send_mail); + my ($sec_review_bug, $finance_bug, $error, @dep_comment, @dep_errors, @send_mail); # Common parameters always passed to _file_child_bug # bug_data and template_suffix will be different for each bug @@ -105,79 +74,27 @@ sub post_bug_after_creation { rep_platform => 'All', version => 'unspecified', blocked => $bug->bug_id, + cc => $params->{cc}, }; $child_params->{'template_suffix'} = 'sec-review'; _file_child_bug($child_params); } - if ($do_legal) { - my $component = 'General'; - - if ($params->{separate_party} eq 'Yes' - && $params->{relationship_type}) - { - $component = ($params->{relationship_type} eq 'Other' - || $params->{relationship_type} eq 'Hardware Purchase') - ? 'General' - : $params->{relationship_type}; - } - - my $legal_summary = "Legal Review: "; - $legal_summary .= $params->{legal_other_party} . " - " if $params->{legal_other_party}; - $legal_summary .= $bug->short_desc; - - $child_params->{'bug_data'} = { - short_desc => $legal_summary, - product => 'Legal', - component => $component, - bug_severity => 'normal', - priority => '--', - groups => [ 'legal' ], - op_sys => 'All', - rep_platform => 'All', - version => 'unspecified', - blocked => $bug->bug_id, - cc => $params->{'legal_cc'}, - }; - $child_params->{'template_suffix'} = 'legal'; - _file_child_bug($child_params); - } - - if ($do_finance) { - $child_params->{'bug_data'} = { - short_desc => 'Finance Review: ' . $bug->short_desc, - product => 'Finance', - component => 'Purchase Request Form', - bug_severity => 'normal', - priority => '--', - groups => [ 'finance' ], - op_sys => 'All', - rep_platform => 'All', - version => 'unspecified', - blocked => $bug->bug_id, - }; - $child_params->{'template_suffix'} = 'finance'; - _file_child_bug($child_params); - } - - if ($do_data_compliance) { - $child_params->{'bug_data'} = { - short_desc => 'Data Compliance Review: ' . $bug->short_desc, - product => 'Data Compliance', - component => 'General', - bug_severity => 'normal', - priority => '--', - bug_severity => $params->{data_comp_urgency}, - groups => [ 'mozilla-employee-confidential' ], - op_sys => 'All', - rep_platform => 'All', - version => 'unspecified', - cf_due_date => $params->{release_date}, - blocked => $bug->bug_id, - }; - $child_params->{'template_suffix'} = 'data-compliance'; - _file_child_bug($child_params); - } + $child_params->{'bug_data'} = { + short_desc => 'Finance Review: ' . $bug->short_desc, + product => 'Finance', + component => 'Purchase Request Form', + bug_severity => 'normal', + priority => '--', + groups => [ 'finance' ], + op_sys => 'All', + rep_platform => 'All', + version => 'unspecified', + blocked => $bug->bug_id, + cc => $params->{cc}, + }; + $child_params->{'template_suffix'} = 'finance'; + _file_child_bug($child_params); if (scalar @dep_errors) { warn "[Bug " . $bug->id . "] Failed to create additional moz-project-review bugs:\n" . @@ -214,16 +131,10 @@ sub _file_child_bug { Bugzilla->template->process($full_template, $template_vars, \$comment) || ThrowTemplateError(Bugzilla->template->error()); $bug_data->{'comment'} = $comment; - if (exists $auto_cc{$template_suffix}) { - $bug_data->{'cc'} = $auto_cc{$template_suffix}; - } if ($new_bug = Bugzilla::Bug->create($bug_data)) { my $set_all = { dependson => { add => [ $new_bug->bug_id ] } }; - if (exists $auto_cc{$template_suffix}) { - $set_all->{'cc'} = { add => $auto_cc{$template_suffix} }; - } $parent_bug->set_all($set_all); $parent_bug->update($parent_bug->creation_ts); } |