@@ -67,7 +67,7 @@ func MustAllowUserComment(ctx *context.Context) {
67
67
return
68
68
}
69
69
70
- if issue .IsLocked && ! ctx .Repo .CanWrite ( models . UnitTypeIssues ) && ! ctx .User .IsAdmin {
70
+ if issue .IsLocked && ! ctx .Repo .CanWriteIssuesOrPulls ( issue . IsPull ) && ! ctx .User .IsAdmin {
71
71
ctx .Flash .Error (ctx .Tr ("repo.issues.comment_on_locked" ))
72
72
ctx .Redirect (issue .HTMLURL ())
73
73
return
@@ -346,8 +346,8 @@ func RetrieveRepoMilestonesAndAssignees(ctx *context.Context, repo *models.Repos
346
346
}
347
347
348
348
// RetrieveRepoMetas find all the meta information of a repository
349
- func RetrieveRepoMetas (ctx * context.Context , repo * models.Repository ) []* models.Label {
350
- if ! ctx .Repo .CanWrite ( models . UnitTypeIssues ) {
349
+ func RetrieveRepoMetas (ctx * context.Context , repo * models.Repository , isPull bool ) []* models.Label {
350
+ if ! ctx .Repo .CanWriteIssuesOrPulls ( isPull ) {
351
351
return nil
352
352
}
353
353
@@ -371,7 +371,7 @@ func RetrieveRepoMetas(ctx *context.Context, repo *models.Repository) []*models.
371
371
ctx .Data ["Branches" ] = brs
372
372
373
373
// Contains true if the user can create issue dependencies
374
- ctx .Data ["CanCreateIssueDependencies" ] = ctx .Repo .CanCreateIssueDependencies (ctx .User )
374
+ ctx .Data ["CanCreateIssueDependencies" ] = ctx .Repo .CanCreateIssueDependencies (ctx .User , isPull )
375
375
376
376
return labels
377
377
}
@@ -441,7 +441,7 @@ func NewIssue(ctx *context.Context) {
441
441
setTemplateIfExists (ctx , issueTemplateKey , IssueTemplateCandidates )
442
442
renderAttachmentSettings (ctx )
443
443
444
- RetrieveRepoMetas (ctx , ctx .Repo .Repository )
444
+ RetrieveRepoMetas (ctx , ctx .Repo .Repository , false )
445
445
if ctx .Written () {
446
446
return
447
447
}
@@ -456,7 +456,7 @@ func ValidateRepoMetas(ctx *context.Context, form auth.CreateIssueForm, isPull b
456
456
err error
457
457
)
458
458
459
- labels := RetrieveRepoMetas (ctx , ctx .Repo .Repository )
459
+ labels := RetrieveRepoMetas (ctx , ctx .Repo .Repository , isPull )
460
460
if ctx .Written () {
461
461
return nil , nil , 0
462
462
}
@@ -776,8 +776,16 @@ func ViewIssue(ctx *context.Context) {
776
776
}
777
777
}
778
778
779
+ if issue .IsPull && ! ctx .Repo .CanRead (models .UnitTypeIssues ) {
780
+ ctx .Data ["IssueType" ] = "pulls"
781
+ } else if ! issue .IsPull && ! ctx .Repo .CanRead (models .UnitTypePullRequests ) {
782
+ ctx .Data ["IssueType" ] = "issues"
783
+ } else {
784
+ ctx .Data ["IssueType" ] = "all"
785
+ }
786
+
779
787
// Check if the user can use the dependencies
780
- ctx .Data ["CanCreateIssueDependencies" ] = ctx .Repo .CanCreateIssueDependencies (ctx .User )
788
+ ctx .Data ["CanCreateIssueDependencies" ] = ctx .Repo .CanCreateIssueDependencies (ctx .User , issue . IsPull )
781
789
782
790
// Render comments and and fetch participants.
783
791
participants [0 ] = issue .Poster
@@ -963,7 +971,6 @@ func ViewIssue(ctx *context.Context) {
963
971
ctx .Data ["IsIssuePoster" ] = ctx .IsSigned && issue .IsPoster (ctx .User .ID )
964
972
ctx .Data ["IsIssueWriter" ] = ctx .Repo .CanWriteIssuesOrPulls (issue .IsPull )
965
973
ctx .Data ["IsRepoAdmin" ] = ctx .IsSigned && (ctx .Repo .IsAdmin () || ctx .User .IsAdmin )
966
- ctx .Data ["IsRepoIssuesWriter" ] = ctx .IsSigned && (ctx .Repo .CanWrite (models .UnitTypeIssues ) || ctx .User .IsAdmin )
967
974
ctx .Data ["LockReasons" ] = setting .Repository .Issue .LockReasons
968
975
ctx .HTML (200 , tplIssueView )
969
976
}
@@ -1208,7 +1215,7 @@ func NewComment(ctx *context.Context, form auth.CreateCommentForm) {
1208
1215
ctx .Error (403 )
1209
1216
}
1210
1217
1211
- if issue .IsLocked && ! ctx .Repo .CanWrite ( models . UnitTypeIssues ) && ! ctx .User .IsAdmin {
1218
+ if issue .IsLocked && ! ctx .Repo .CanWriteIssuesOrPulls ( issue . IsPull ) && ! ctx .User .IsAdmin {
1212
1219
ctx .Flash .Error (ctx .Tr ("repo.issues.comment_on_locked" ))
1213
1220
ctx .Redirect (issue .HTMLURL (), http .StatusSeeOther )
1214
1221
return
0 commit comments