Edit Hashtags permission

Change-Id: I5ca20cbeb6504e6efbd3448bfa1a62aa846fe7b1
This commit is contained in:
Gustaf Lundh 2014-09-09 15:57:53 +02:00
parent 8c9d00e005
commit f8a247477f
6 changed files with 32 additions and 1 deletions

View File

@ -29,6 +29,7 @@ public class ChangeDetail {
protected boolean canAbandon;
protected boolean canEditCommitMessage;
protected boolean canCherryPick;
protected boolean canEditHashtags;
protected boolean canPublish;
protected boolean canRebase;
protected boolean canRestore;
@ -93,6 +94,14 @@ public class ChangeDetail {
canCherryPick = a;
}
public boolean getCanEditHashtags() {
return canEditHashtags;
}
public void setCanEditHashtags(final boolean a) {
canEditHashtags = a;
}
public boolean canPublish() {
return canPublish;
}

View File

@ -24,6 +24,7 @@ public class Permission implements Comparable<Permission> {
public static final String ABANDON = "abandon";
public static final String CREATE = "create";
public static final String DELETE_DRAFTS = "deleteDrafts";
public static final String EDIT_HASHTAGS = "editHashtags";
public static final String EDIT_TOPIC_NAME = "editTopicName";
public static final String FORGE_AUTHOR = "forgeAuthor";
public static final String FORGE_COMMITTER = "forgeCommitter";
@ -68,6 +69,7 @@ public class Permission implements Comparable<Permission> {
NAMES_LC.add(SUBMIT_AS.toLowerCase());
NAMES_LC.add(VIEW_DRAFTS.toLowerCase());
NAMES_LC.add(EDIT_TOPIC_NAME.toLowerCase());
NAMES_LC.add(EDIT_HASHTAGS.toLowerCase());
NAMES_LC.add(DELETE_DRAFTS.toLowerCase());
NAMES_LC.add(PUBLISH_DRAFTS.toLowerCase());

View File

@ -85,7 +85,10 @@ public class ReviewResult {
DEST_BRANCH_NOT_FOUND,
/** Not permitted to edit the topic name */
EDIT_TOPIC_NAME_NOT_PERMITTED
EDIT_TOPIC_NAME_NOT_PERMITTED,
/** Not permitted to edit the hashtags */
EDIT_HASHTAGS_NOT_PERMITTED
}
protected Type type;

View File

@ -109,6 +109,7 @@ permissionNames = \
abandon, \
create, \
deleteDrafts, \
editHashtags, \
editTopicName, \
forgeAuthor, \
forgeCommitter, \
@ -129,6 +130,7 @@ permissionNames = \
abandon = Abandon
create = Create Reference
deleteDrafts = Delete Drafts
editHashtags = Edit Hashtags
editTopicName = Edit Topic Name
forgeAuthor = Forge Author Identity
forgeCommitter = Forge Committer Identity

View File

@ -413,6 +413,16 @@ public class ChangeControl {
}
}
/** Can this user edit the hashtag name? */
public boolean canEditHashtags() {
return isOwner() // owner (aka creator) of the change can edit hashtags
|| getRefControl().isOwner() // branch owner can edit hashtags
|| getProjectControl().isOwner() // project owner can edit hashtags
|| getCurrentUser().getCapabilities().canAdministrateServer() // site administers are god
|| getRefControl().canEditHashtags(); // user can edit hashtag on a specific ref
}
public List<SubmitRecord> getSubmitRecords(ReviewDb db, PatchSet patchSet) {
return canSubmit(db, patchSet, null, false, true, false);
}

View File

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