From 23c416f30f4a1e69e76b70d71f6a9a7da4a020f1 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Thu, 10 Apr 2014 18:58:09 -0400 Subject: [PATCH] Hook-up comprensive command cleanup (destroy) --- src/main/java/com/gitblit/models/UserModel.java | 23 ++++++++++++++++++++--- 1 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gitblit/models/UserModel.java b/src/main/java/com/gitblit/models/UserModel.java index fbf311a..675835d 100644 --- a/src/main/java/com/gitblit/models/UserModel.java +++ b/src/main/java/com/gitblit/models/UserModel.java @@ -447,16 +447,29 @@ return canAdmin() || model.isUsersPersonalRepository(username) || model.isOwner(username); } + public boolean canEdit(TicketModel ticket, RepositoryModel repository) { + return isAuthenticated() && + (canPush(repository) + || (ticket != null && username.equals(ticket.responsible)) + || (ticket != null && username.equals(ticket.createdBy))); + } + + public boolean canAdmin(TicketModel ticket, RepositoryModel repository) { + return isAuthenticated() && + (canPush(repository) + || ticket != null && username.equals(ticket.responsible)); + } + public boolean canReviewPatchset(RepositoryModel model) { - return isAuthenticated && canClone(model); + return isAuthenticated() && canClone(model); } public boolean canApprovePatchset(RepositoryModel model) { - return isAuthenticated && canPush(model); + return isAuthenticated() && canPush(model); } public boolean canVetoPatchset(RepositoryModel model) { - return isAuthenticated && canPush(model); + return isAuthenticated() && canPush(model); } /** @@ -540,6 +553,10 @@ return false; } + public boolean isAuthenticated() { + return !UserModel.ANONYMOUS.equals(this) && isAuthenticated; + } + public boolean isTeamMember(String teamname) { for (TeamModel team : teams) { if (team.name.equalsIgnoreCase(teamname)) { -- Gitblit v1.9.1