Add new "Delete Changes" permission

Changes can only be deleted by Administrators, or by the change owner
when they are granted the "Delete Own Changes" permission either on the
"Change Owners" virtual group or an internal group they are a member of.

This means that it is not possible to allow users to delete other users'
changes other than by granting the "Administrate Server" permission,
which also gives them all the other administrative capabilities. This is
also inconsistent with how the "Delete Drafts" permission works.

An example of where it would be better to have more flexible permissions
is allowing changes to be deleted by Project Owners on a per-project
basis, or by a group of users who are trusted (but not enough to grant
them Administrator capabilities).

Add a new permission "Delete Changes" which allows these use cases, thus
a change can now also be deleted by users who are:

- Member of a group that is explicitly granted "Delete Changes" on the
  change's destination branch.
- Member of a group that is given the "Owner" permission on the project,
  when the virtual group "Project Owners" is granted "Delete Changes" on
  the change's destination branch.

Bug: Issue 9354
Change-Id: I9d5d779eb0a6ce18faca02b9fc90904ec5da91d9
This commit is contained in:
David Pursehouse
2018-07-05 13:24:47 +09:00
parent 1697a2bd2b
commit 42488f88ce
6 changed files with 58 additions and 6 deletions

View File

@@ -27,6 +27,7 @@ public class Permission implements Comparable<Permission> {
public static final String DELETE = "delete";
public static final String CREATE_TAG = "createTag";
public static final String CREATE_SIGNED_TAG = "createSignedTag";
public static final String DELETE_CHANGES = "deleteChanges";
public static final String DELETE_DRAFTS = "deleteDrafts";
public static final String DELETE_OWN_CHANGES = "deleteOwnChanges";
public static final String EDIT_HASHTAGS = "editHashtags";
@@ -79,6 +80,7 @@ public class Permission implements Comparable<Permission> {
NAMES_LC.add(EDIT_ASSIGNEE.toLowerCase());
NAMES_LC.add(DELETE_DRAFTS.toLowerCase());
NAMES_LC.add(DELETE_OWN_CHANGES.toLowerCase());
NAMES_LC.add(DELETE_CHANGES.toLowerCase());
NAMES_LC.add(PUBLISH_DRAFTS.toLowerCase());
LABEL_INDEX = NAMES_LC.indexOf(Permission.LABEL);