diff options
author | Lauris BH <lauris@nix.lv> | 2017-10-15 02:17:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-15 02:17:39 +0300 |
commit | f42dbdbae59600266d03357f9693c659adc9cab3 (patch) | |
tree | 90b42df32a5f064d9055fec37c909aa83c432dcc /models/repo.go | |
parent | 8863e74f2aa7150605712eb21468b6f1305289f7 (diff) | |
download | gitea-f42dbdbae59600266d03357f9693c659adc9cab3.tar.gz gitea-f42dbdbae59600266d03357f9693c659adc9cab3.zip |
Add Activity page to repository (#2674)
* Add Activity page to repository
* Add request data for activity
* Add issue data for activity
* Add user unit right checks
* Add releases to activity
* Log repository unit loading error
Diffstat (limited to 'models/repo.go')
-rw-r--r-- | models/repo.go | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/models/repo.go b/models/repo.go index 7ad9ad4dc9..a6817f6514 100644 --- a/models/repo.go +++ b/models/repo.go @@ -383,7 +383,9 @@ func (repo *Repository) getUnitsByUserID(e Engine, userID int64, isAdmin bool) ( // UnitEnabled if this repository has the given unit enabled func (repo *Repository) UnitEnabled(tp UnitType) bool { - repo.getUnits(x) + if err := repo.getUnits(x); err != nil { + log.Warn("Error loading repository (ID: %d) units: %s", repo.ID, err.Error()) + } for _, unit := range repo.Units { if unit.Type == tp { return true @@ -392,6 +394,21 @@ func (repo *Repository) UnitEnabled(tp UnitType) bool { return false } +// AnyUnitEnabled if this repository has the any of the given units enabled +func (repo *Repository) AnyUnitEnabled(tps ...UnitType) bool { + if err := repo.getUnits(x); err != nil { + log.Warn("Error loading repository (ID: %d) units: %s", repo.ID, err.Error()) + } + for _, unit := range repo.Units { + for _, tp := range tps { + if unit.Type == tp { + return true + } + } + } + return false +} + var ( // ErrUnitNotExist organization does not exist ErrUnitNotExist = errors.New("Unit does not exist") |