summaryrefslogtreecommitdiffstats
path: root/modules/context
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2017-10-15 02:17:39 +0300
committerGitHub <noreply@github.com>2017-10-15 02:17:39 +0300
commitf42dbdbae59600266d03357f9693c659adc9cab3 (patch)
tree90b42df32a5f064d9055fec37c909aa83c432dcc /modules/context
parent8863e74f2aa7150605712eb21468b6f1305289f7 (diff)
downloadgitea-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 'modules/context')
-rw-r--r--modules/context/repo.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/modules/context/repo.go b/modules/context/repo.go
index ce65bfd045..788588f8e4 100644
--- a/modules/context/repo.go
+++ b/modules/context/repo.go
@@ -573,7 +573,7 @@ func LoadRepoUnits() macaron.Handler {
}
}
-// CheckUnit will check whether
+// CheckUnit will check whether unit type is enabled
func CheckUnit(unitType models.UnitType) macaron.Handler {
return func(ctx *Context) {
if !ctx.Repo.Repository.UnitEnabled(unitType) {
@@ -582,6 +582,15 @@ func CheckUnit(unitType models.UnitType) macaron.Handler {
}
}
+// CheckAnyUnit will check whether any of the unit types are enabled
+func CheckAnyUnit(unitTypes ...models.UnitType) macaron.Handler {
+ return func(ctx *Context) {
+ if !ctx.Repo.Repository.AnyUnitEnabled(unitTypes...) {
+ ctx.Handle(404, "CheckAnyUnit", fmt.Errorf("%s: %v", ctx.Tr("units.error.unit_not_allowed"), unitTypes))
+ }
+ }
+}
+
// GitHookService checks if repository Git hooks service has been enabled.
func GitHookService() macaron.Handler {
return func(ctx *Context) {