summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Fearn <jfearn@redhat.com>2021-08-26 14:20:26 +1000
committerJeff Fearn <jfearn@redhat.com>2021-08-26 14:20:26 +1000
commit5b9014c7828525cd5f8da8b0d0a4c1f95780403f (patch)
tree926c2c295c40dd339ac11e51207f8767864c542d
parentBug 1996083 - Setting BRE rules ordering is broken (diff)
downloadbugzilla-5b9014c7828525cd5f8da8b0d0a4c1f95780403f.tar.gz
bugzilla-5b9014c7828525cd5f8da8b0d0a4c1f95780403f.tar.bz2
bugzilla-5b9014c7828525cd5f8da8b0d0a4c1f95780403f.zip
Bug 1725579 - Block delete group when it's related to agile team
Prevented deleting group except when deleting the team. Change-Id: Ic76e80888815e80dd702388de49221599ddd1ce4
-rw-r--r--Bugzilla/Group.pm7
-rw-r--r--extensions/AgileTools/lib/Team.pm7
-rw-r--r--extensions/AgileTools/template/en/default/hook/global/user-error-errors.html.tmpl10
-rw-r--r--template/en/default/admin/groups/delete.html.tmpl8
-rw-r--r--template/en/default/admin/groups/list.html.tmpl15
5 files changed, 45 insertions, 2 deletions
diff --git a/Bugzilla/Group.pm b/Bugzilla/Group.pm
index 029141f74..d15fbfe72 100644
--- a/Bugzilla/Group.pm
+++ b/Bugzilla/Group.pm
@@ -261,6 +261,13 @@ sub check_remove {
ThrowUserError("system_group_not_deletable", {name => $self->name});
}
+ ## RED HAT EXTENSION START 1725579
+ # Agile groups cannot be deleted!
+ if ($self->category eq 'Agile') {
+ ThrowUserError("agile_group_not_deletable", {name => $self->name});
+ }
+ ## RED HAT EXTENSION END 1725579
+
# Groups having a special role cannot be deleted.
my @special_groups;
foreach my $special_group (GROUP_PARAMS) {
diff --git a/extensions/AgileTools/lib/Team.pm b/extensions/AgileTools/lib/Team.pm
index 3199a47c5..eda2f7ba6 100644
--- a/extensions/AgileTools/lib/Team.pm
+++ b/extensions/AgileTools/lib/Team.pm
@@ -569,6 +569,9 @@ sub create {
sub remove_from_db {
my $self = shift;
+ my $dbh = Bugzilla->dbh;
+ $dbh->bz_start_transaction();
+
# Remove sprints
my $sprints
= Bugzilla::Extension::AgileTools::Sprint->match({team_id => $self->id});
@@ -590,7 +593,6 @@ sub remove_from_db {
# Remove users from the group and change the group to non system group
# before deleting, so that if it fails, the group can be manually removed
# in the admin interface.
- my $dbh = Bugzilla->dbh;
$dbh->do(
"DELETE FROM user_group_map
WHERE group_id = ?", undef, $group->id
@@ -601,7 +603,10 @@ sub remove_from_db {
WHERE id = ?", undef, $group->id
);
$group->{isbuggroup} = 1;
+ $group->{category} = 'Deprecated';
$group->remove_from_db();
+ $dbh->bz_commit_transaction();
+ Bugzilla->memcached->clear_config();
return;
}
diff --git a/extensions/AgileTools/template/en/default/hook/global/user-error-errors.html.tmpl b/extensions/AgileTools/template/en/default/hook/global/user-error-errors.html.tmpl
index d2fac3a78..2925b655b 100644
--- a/extensions/AgileTools/template/en/default/hook/global/user-error-errors.html.tmpl
+++ b/extensions/AgileTools/template/en/default/hook/global/user-error-errors.html.tmpl
@@ -107,4 +107,12 @@
[% ELSIF error == "agile_invalid_team" %]
[% title = "No such team" %]
The team you specified does not exist: [% id FILTER html %]
-[%## RED HAT EXTENSION END 1737347 %][% END %]
+[%## RED HAT EXTENSION END 1737347 %]
+
+[%## RED HAT EXTENSION START 1725579 %]
+[% ELSIF error == "agile_group_not_deletable" %]
+ [% title = "Agile Groups not deletable" %]
+ <em>[% name FILTER html %]</em> is an Agile group.
+ This group cannot be deleted, you must delete the team.
+[%## RED HAT EXTENSION END 1725579 %]
+[% END %]
diff --git a/template/en/default/admin/groups/delete.html.tmpl b/template/en/default/admin/groups/delete.html.tmpl
index 465860761..651f51f54 100644
--- a/template/en/default/admin/groups/delete.html.tmpl
+++ b/template/en/default/admin/groups/delete.html.tmpl
@@ -39,6 +39,13 @@
</tr>
</table>
+[%## RED HAT EXTENSION START 1725579 %]
+[% IF group.category == 'Agile' %]
+ <p class="confirmation">
+ To delete groups used by Agile teams, you must delete the team.
+ </p>
+[% ELSE %]
+[%## RED HAT EXTENSION END 1725579 %]
<form method="post" action="editgroups.cgi">
[% IF group.members_non_inherited.size %]
<p><b>[% group.members_non_inherited.size FILTER html %] users belong
@@ -175,6 +182,7 @@
<input type="hidden" name="token" value="[% token FILTER html %]">
</p>
</form>
+[% END %]
Go back to the <a href="editgroups.cgi">group list</a>.
diff --git a/template/en/default/admin/groups/list.html.tmpl b/template/en/default/admin/groups/list.html.tmpl
index 65b15b4b4..6fb17aadb 100644
--- a/template/en/default/admin/groups/list.html.tmpl
+++ b/template/en/default/admin/groups/list.html.tmpl
@@ -95,6 +95,21 @@
[% END %]
[% END %]
+[%## RED HAT EXTENSION START 1725579 %]
+[%# No delete link for Agile groups %]
+[% FOREACH agile_group IN groups %]
+ [% IF agile_group.category == 'Agile' %]
+ [% overrides.action.name.${agile_group.name} = {
+ override_content => 1
+ content => ""
+ override_contentlink => 1
+ contentlink => ""
+ }
+ %]
+ [% END %]
+[% END %]
+[%## RED HAT EXTENSION END 1725579 %]
+
[% overrides.action.isbuggroup = {
"1" => {
override_content => 1