Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Jun 16, 2024
1 parent 66dab87 commit 4f38c75
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion models/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func (repo *Repository) LoadUnits(ctx context.Context) (err error) {
if log.IsTrace() {
unitTypeStrings := make([]string, len(repo.Units))
for i, unit := range repo.Units {
unitTypeStrings[i] = unit.Type.String()
unitTypeStrings[i] = unit.Type.LogString()
}
log.Trace("repo.Units, ID=%d, Types: [%s]", repo.ID, strings.Join(unitTypeStrings, ", "))
}
Expand Down
2 changes: 1 addition & 1 deletion models/repo/repo_unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func IsErrUnitTypeNotExist(err error) bool {
}

func (err ErrUnitTypeNotExist) Error() string {
return fmt.Sprintf("Unit type does not exist: %s", err.UT.String())
return fmt.Sprintf("Unit type does not exist: %s", err.UT.LogString())
}

func (err ErrUnitTypeNotExist) Unwrap() error {
Expand Down
8 changes: 4 additions & 4 deletions routers/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,18 +384,18 @@ func registerRoutes(m *web.Route) {
return func(ctx *context.Context) {
// only check global disabled units when ignoreGlobal is false
if !ignoreGlobal && unitType.UnitGlobalDisabled() {
ctx.NotFound(unitType.String(), nil)
ctx.NotFound("Repo unit is is disabled:"+unitType.LogString(), nil)
return
}

if ctx.ContextUser == nil {
ctx.NotFound(unitType.String(), nil)
ctx.NotFound("ContextUser is nil", nil)
return
}

if ctx.ContextUser.IsOrganization() {
if ctx.Org.Organization.UnitPermission(ctx, ctx.Doer, unitType) < accessMode {
ctx.NotFound(unitType.String(), nil)
ctx.NotFound("ContextUser is org but doer has no access to unit", nil)
return
}
}
Expand Down Expand Up @@ -487,7 +487,7 @@ func registerRoutes(m *web.Route) {
m.Get("/organizations", explore.Organizations)
m.Get("/code", func(ctx *context.Context) {
if unit.TypeCode.UnitGlobalDisabled() {
ctx.NotFound(unit.TypeCode.String(), nil)
ctx.NotFound("Rep unit code is disabled", nil)
return
}
}, explore.Code)
Expand Down

0 comments on commit 4f38c75

Please sign in to comment.