@@ -10,6 +10,8 @@ import (
10
10
"strings"
11
11
12
12
"code.gitea.io/gitea/models"
13
+ "code.gitea.io/gitea/models/unit"
14
+ user_model "code.gitea.io/gitea/models/user"
13
15
"code.gitea.io/gitea/modules/context"
14
16
"code.gitea.io/gitea/modules/log"
15
17
"code.gitea.io/gitea/modules/setting"
@@ -44,9 +46,9 @@ func repoAssignment() func(ctx *context.APIContext) {
44
46
owner , err = models .GetUserByName (userName )
45
47
if err != nil {
46
48
if models .IsErrUserNotExist (err ) {
47
- if redirectUserID , err := models .LookupUserRedirect (userName ); err == nil {
49
+ if redirectUserID , err := user_model .LookupUserRedirect (userName ); err == nil {
48
50
context .RedirectToUser (ctx .Context , userName , redirectUserID )
49
- } else if models .IsErrUserRedirectNotExist (err ) {
51
+ } else if user_model .IsErrUserRedirectNotExist (err ) {
50
52
ctx .NotFound ("GetUserByName" , err )
51
53
} else {
52
54
ctx .Error (http .StatusInternalServerError , "LookupUserRedirect" , err )
@@ -198,10 +200,10 @@ func orgAssignment(args ...bool) func(ctx *context.APIContext) {
198
200
ctx .Org .Organization , err = models .GetOrgByName (ctx .Params (":org" ))
199
201
if err != nil {
200
202
if models .IsErrOrgNotExist (err ) {
201
- redirectUserID , err := models .LookupUserRedirect (ctx .Params (":org" ))
203
+ redirectUserID , err := user_model .LookupUserRedirect (ctx .Params (":org" ))
202
204
if err == nil {
203
205
context .RedirectToUser (ctx .Context , ctx .Params (":org" ), redirectUserID )
204
- } else if models .IsErrUserRedirectNotExist (err ) {
206
+ } else if user_model .IsErrUserRedirectNotExist (err ) {
205
207
ctx .NotFound ("GetOrgByName" , err )
206
208
} else {
207
209
ctx .Error (http .StatusInternalServerError , "LookupUserRedirect" , err )
@@ -228,22 +230,22 @@ func orgAssignment(args ...bool) func(ctx *context.APIContext) {
228
230
}
229
231
230
232
func mustEnableIssuesOrPulls (ctx * context.APIContext ) {
231
- if ! ctx .Repo .CanRead (models . UnitTypeIssues ) &&
232
- ! (ctx .Repo .Repository .CanEnablePulls () && ctx .Repo .CanRead (models . UnitTypePullRequests )) {
233
+ if ! ctx .Repo .CanRead (unit . TypeIssues ) &&
234
+ ! (ctx .Repo .Repository .CanEnablePulls () && ctx .Repo .CanRead (unit . TypePullRequests )) {
233
235
if ctx .Repo .Repository .CanEnablePulls () && log .IsTrace () {
234
236
if ctx .IsSigned {
235
237
log .Trace ("Permission Denied: User %-v cannot read %-v and %-v in Repo %-v\n " +
236
238
"User in Repo has Permissions: %-+v" ,
237
239
ctx .User ,
238
- models . UnitTypeIssues ,
239
- models . UnitTypePullRequests ,
240
+ unit . TypeIssues ,
241
+ unit . TypePullRequests ,
240
242
ctx .Repo .Repository ,
241
243
ctx .Repo .Permission )
242
244
} else {
243
245
log .Trace ("Permission Denied: Anonymous user cannot read %-v and %-v in Repo %-v\n " +
244
246
"Anonymous user in Repo has Permissions: %-+v" ,
245
- models . UnitTypeIssues ,
246
- models . UnitTypePullRequests ,
247
+ unit . TypeIssues ,
248
+ unit . TypePullRequests ,
247
249
ctx .Repo .Repository ,
248
250
ctx .Repo .Permission )
249
251
}
0 commit comments