Simplified "CanCreateIssueDependencies"

This commit is contained in:
kolaente 2018-01-14 20:20:18 +01:00 committed by Konrad
parent 30ae70a4d0
commit dd5cfbf656
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
4 changed files with 7 additions and 4 deletions

View File

@ -104,7 +104,7 @@ func (r *Repository) CanUseTimetracker(issue *models.Issue, user *models.User) b
} }
// CanCreateIssueDependencies returns whether or not a user can create dependencies. // CanCreateIssueDependencies returns whether or not a user can create dependencies.
func (r *Repository) CanCreateIssueDependencies(issue *models.Issue, user *models.User) bool { func (r *Repository) CanCreateIssueDependencies(user *models.User) bool {
// Checks for following: // Checks for following:
// 1. Are dependencies enabled // 1. Are dependencies enabled
// 2. Has the user write access? // 2. Has the user write access?

View File

@ -302,6 +302,9 @@ func RetrieveRepoMetas(ctx *context.Context, repo *models.Repository) []*models.
} }
ctx.Data["Branches"] = brs ctx.Data["Branches"] = brs
//
ctx.Data["CanCreateIssueDependencies"] = ctx.Repo.CanCreateIssueDependencies(ctx.User)
return labels return labels
} }
@ -651,7 +654,7 @@ func ViewIssue(ctx *context.Context) {
} }
// Check if the user can use the dependencies // Check if the user can use the dependencies
ctx.Data["CanCreateIssueDependencies"] = ctx.Repo.CanCreateIssueDependencies(issue, ctx.User) ctx.Data["CanCreateIssueDependencies"] = ctx.Repo.CanCreateIssueDependencies(ctx.User)
// Render comments and and fetch participants. // Render comments and and fetch participants.
participants[0] = issue.Poster participants[0] = issue.Poster

View File

@ -25,7 +25,7 @@ func AddDependency(ctx *context.Context) {
} }
// Check if the Repo is allowed to have dependencies // Check if the Repo is allowed to have dependencies
if !ctx.Repo.CanCreateIssueDependencies(issue, ctx.User) { if !ctx.Repo.CanCreateIssueDependencies(ctx.User) {
ctx.NotFound("NotAllowedToCreateIssueDependencies", nil) ctx.NotFound("NotAllowedToCreateIssueDependencies", nil)
return return
} }

View File

@ -24,7 +24,7 @@ func RemoveDependency(ctx *context.Context) {
} }
// Check if the Repo is allowed to have dependencies // Check if the Repo is allowed to have dependencies
if !ctx.Repo.CanCreateIssueDependencies(issue, ctx.User) { if !ctx.Repo.CanCreateIssueDependencies(ctx.User) {
ctx.NotFound("NotAllowedToCreateIssueDependencies", nil) ctx.NotFound("NotAllowedToCreateIssueDependencies", nil)
return return
} }