Simplified "CanCreateIssueDependencies"
This commit is contained in:
parent
30ae70a4d0
commit
dd5cfbf656
|
|
@ -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.
|
||||
func (r *Repository) CanCreateIssueDependencies(issue *models.Issue, user *models.User) bool {
|
||||
func (r *Repository) CanCreateIssueDependencies(user *models.User) bool {
|
||||
// Checks for following:
|
||||
// 1. Are dependencies enabled
|
||||
// 2. Has the user write access?
|
||||
|
|
|
|||
|
|
@ -302,6 +302,9 @@ func RetrieveRepoMetas(ctx *context.Context, repo *models.Repository) []*models.
|
|||
}
|
||||
ctx.Data["Branches"] = brs
|
||||
|
||||
//
|
||||
ctx.Data["CanCreateIssueDependencies"] = ctx.Repo.CanCreateIssueDependencies(ctx.User)
|
||||
|
||||
return labels
|
||||
}
|
||||
|
||||
|
|
@ -651,7 +654,7 @@ func ViewIssue(ctx *context.Context) {
|
|||
}
|
||||
|
||||
// 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.
|
||||
participants[0] = issue.Poster
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ func AddDependency(ctx *context.Context) {
|
|||
}
|
||||
|
||||
// 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)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ func RemoveDependency(ctx *context.Context) {
|
|||
}
|
||||
|
||||
// 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)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user