diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/Build.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/Build.pm index c120f8101d8..ee189526d40 100644 --- a/mozilla/webtools/testopia/Bugzilla/Testopia/Build.pm +++ b/mozilla/webtools/testopia/Bugzilla/Testopia/Build.pm @@ -228,6 +228,25 @@ sub description { return $_[0]->{'description'};} sub milestone { return $_[0]->{'milestone'};} sub isactive { return $_[0]->{'isactive'};} +sub bugs { + my $self = shift; + my $dbh = Bugzilla->dbh; + return $self->{'bugs'} if exists $self->{'bugs'}; + my $ref = $dbh->selectcol_arrayref( + "SELECT DISTINCT bug_id + FROM test_case_bugs b + JOIN test_case_runs r ON r.case_run_id = b.case_run_id + WHERE r.build_id = ?", + undef, $self->id); + my @bugs; + foreach my $id (@{$ref}){ + push @bugs, Bugzilla::Bug->new($id, Bugzilla->user->id); + } + $self->{'bugs'} = \@bugs if @bugs; + $self->{'bug_list'} = join(',', @$ref); + return $self->{'bugs'}; +} + sub product { my ($self) = @_; diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/Product.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/Product.pm index 23c702b1e8f..befd519a9d3 100644 --- a/mozilla/webtools/testopia/Bugzilla/Testopia/Product.pm +++ b/mozilla/webtools/testopia/Bugzilla/Testopia/Product.pm @@ -281,6 +281,14 @@ sub type { return $self->{'type'}; } +sub canview { + my $self = shift; + my ($user) = @_; + $user ||= Bugzilla->user; + return 1 if $user->can_see_product($self->name); + return 0; +} + sub canedit { my $self = shift; my ($user) = @_; diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/TestCase.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/TestCase.pm index aac716b0142..4d2dd19709b 100644 --- a/mozilla/webtools/testopia/Bugzilla/Testopia/TestCase.pm +++ b/mozilla/webtools/testopia/Bugzilla/Testopia/TestCase.pm @@ -821,17 +821,16 @@ Attaches the specified bug to this test case sub attach_bug { my $self = shift; - my ($bugids, $case_id) = @_; + my ($bugids, $caserun_id) = @_; my $dbh = Bugzilla->dbh; - $case_id ||= $self->{'case_id'}; $bugids = $self->_check_bugs($bugids, "ATTACH"); $dbh->bz_lock_tables('test_case_bugs WRITE'); foreach my $bug (@$bugids){ $dbh->do("INSERT INTO test_case_bugs (bug_id, case_run_id, case_id) - VALUES(?,?,?)", undef, ($bug, undef, $self->id)); + VALUES(?,?,?)", undef, ($bug, $caserun_id, $self->id)); } $dbh->bz_unlock_tables(); diff --git a/mozilla/webtools/testopia/extensions/testopia/code/post_bug-after_creation.pl b/mozilla/webtools/testopia/extensions/testopia/code/post_bug-after_creation.pl index 9d80df91424..19fce47fb3e 100644 --- a/mozilla/webtools/testopia/extensions/testopia/code/post_bug-after_creation.pl +++ b/mozilla/webtools/testopia/extensions/testopia/code/post_bug-after_creation.pl @@ -8,6 +8,7 @@ my $cgi = Bugzilla->cgi; if ($cgi->param('case_id')) { my $case = Bugzilla::Testopia::TestCase->new($cgi->param('case_id')); + ThrowUserError("testopia-read-only", {'object' => $case}) unless $case->canedit; $case->attach_bug($vars->{'id'}); @@ -15,6 +16,7 @@ if ($cgi->param('case_id')) { } if ($cgi->param('caserun_id')) { my $caserun = Bugzilla::Testopia::TestCaseRun->new($cgi->param('caserun_id')); + ThrowUserError("testopia-read-only", {'object' => $caserun}) unless $caserun->canedit; $caserun->attach_bug($vars->{'id'}); diff --git a/mozilla/webtools/testopia/template/en/default/hook/global/common-links.html.tmpl/links/testopia.html.tmpl b/mozilla/webtools/testopia/template/en/default/hook/global/common-links.html.tmpl/links/testopia.html.tmpl index da58c522e42..88d0b57186b 100644 --- a/mozilla/webtools/testopia/template/en/default/hook/global/common-links.html.tmpl/links/testopia.html.tmpl +++ b/mozilla/webtools/testopia/template/en/default/hook/global/common-links.html.tmpl/links/testopia.html.tmpl @@ -25,11 +25,11 @@ [% END %]
| Total: | [% total FILTER none %] | |
|---|---|---|
| Completed: | [% completed FILTER none %] | [% percent_completed || 0 FILTER none %]% |
| IDLE: | [% idle FILTER none %] | [% percent_idle || 0 FILTER none %]% |
| PASSED: | [% passed FILTER none %] | [% percent_passed || 0 FILTER none %]% |
| FAILED: | [% failed FILTER none %] | [% percent_failed || 0 FILTER none %]% |
| BLOCKED: | [% blocked FILTER none %] | [% percent_blocked || 0 FILTER none %]% |
| Total: | [% total FILTER none %] | |
| Completed: | [% completed FILTER none %] | [% percent_completed || 0 FILTER none %]% |
| IDLE: | [% idle FILTER none %] | [% percent_idle || 0 FILTER none %]% |
| PASSED: | [% passed FILTER none %] | [% percent_passed || 0 FILTER none %]% |
| FAILED: | [% failed FILTER none %] | [% percent_failed || 0 FILTER none %]% |
| BLOCKED: | [% blocked FILTER none %] | [% percent_blocked || 0 FILTER none %]% |