Edit Assignee Permissions

Permission deciding who is able to edit the assignee of a change.
Besides the users with edit assignee permission change owner, ref owner, and
the currently assigned user are allowed to change the assignee of a change.

Change-Id: I7cbc950c66b3d5f1e931d5f8d985d8112682971f
This commit is contained in:
Sven Selberg
2016-09-13 16:16:54 +02:00
committed by Sven Selberg
parent f99aca2f16
commit a3ca604a6c
5 changed files with 33 additions and 0 deletions

View File

@@ -352,6 +352,16 @@ public class ChangeControl {
return false;
}
/** Is this user assigned to this change? */
public boolean isAssignee() {
Account.Id currentAssignee = notes.getAssignee();
if (currentAssignee != null && getUser().isIdentifiedUser()) {
Account.Id id = getUser().getAccountId();
return id.equals(currentAssignee);
}
return false;
}
/** Is this user a reviewer for the change? */
public boolean isReviewer(ReviewDb db) throws OrmException {
return isReviewer(db, null);
@@ -414,6 +424,13 @@ public class ChangeControl {
return getRefControl().canForceEditTopicName();
}
public boolean canEditAssignee() {
return isOwner()
|| getProjectControl().isOwner()
|| getRefControl().canEditAssignee()
|| isAssignee();
}
/** Can this user edit the hashtag name? */
public boolean canEditHashtags() {
return isOwner() // owner (aka creator) of the change can edit hashtags

View File

@@ -447,6 +447,10 @@ public class RefControl {
return canPerform(Permission.EDIT_HASHTAGS);
}
public boolean canEditAssignee() {
return canPerform(Permission.EDIT_ASSIGNEE);
}
/** @return true if this user can force edit topic names. */
public boolean canForceEditTopicName() {
return canForcePerform(Permission.EDIT_TOPIC_NAME);