EnableUnit() -> UnitEnabled() (#2242)

This commit is contained in:
Ethan Koenig 2017-08-02 01:46:54 -07:00 committed by Lauris BH
parent 539d9f4c30
commit f29458bd3a
9 changed files with 29 additions and 36 deletions

View file

@ -523,14 +523,7 @@ func LoadRepoUnits() macaron.Handler {
// CheckUnit will check whether
func CheckUnit(unitType models.UnitType) macaron.Handler {
return func(ctx *Context) {
var find bool
for _, unit := range ctx.Repo.Repository.Units {
if unit.Type == unitType {
find = true
break
}
}
if !find {
if !ctx.Repo.Repository.UnitEnabled(unitType) {
ctx.Handle(404, "CheckUnit", fmt.Errorf("%s: %v", ctx.Tr("units.error.unit_not_allowed"), unitType))
}
}