diff --git a/routers/web/repo/activity.go b/routers/web/repo/activity.go index 6f6641cc65..ba776c84d3 100644 --- a/routers/web/repo/activity.go +++ b/routers/web/repo/activity.go @@ -57,7 +57,7 @@ func Activity(ctx *context.Context) { ctx.Repo.CanRead(unit.TypeReleases), ctx.Repo.CanRead(unit.TypeIssues), ctx.Repo.CanRead(unit.TypePullRequests), - ctx.Repo.CanRead(unit.TypeCode)); err != nil { + ctx.Repo.CanRead(unit.TypeCode) && !ctx.Repo.Repository.IsEmpty); err != nil { ctx.ServerError("GetActivityStats", err) return } diff --git a/routers/web/web.go b/routers/web/web.go index 154e1ce24b..8faedca178 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -1423,16 +1423,16 @@ func registerRoutes(m *web.Route) { m.Group("/contributors", func() { m.Get("", repo.Contributors) m.Get("/data", repo.ContributorsData) - }) + }, repo.MustBeNotEmpty, context.RequireRepoReaderOr(unit.TypeCode)) m.Group("/code-frequency", func() { m.Get("", repo.CodeFrequency) m.Get("/data", repo.CodeFrequencyData) - }) + }, repo.MustBeNotEmpty, context.RequireRepoReaderOr(unit.TypeCode)) m.Group("/recent-commits", func() { m.Get("", repo.RecentCommits) m.Get("/data", repo.RecentCommitsData) - }) - }, context.RepoRef(), repo.MustBeNotEmpty, context.RequireRepoReaderOr(unit.TypePullRequests, unit.TypeIssues, unit.TypeReleases)) + }, repo.MustBeNotEmpty, context.RequireRepoReaderOr(unit.TypeCode)) + }, context.RepoRef(), context.RequireRepoReaderOr(unit.TypeCode, unit.TypePullRequests, unit.TypeIssues, unit.TypeReleases)) m.Group("/activity_author_data", func() { m.Get("", repo.ActivityAuthors) diff --git a/templates/repo/activity.tmpl b/templates/repo/activity.tmpl index a19fb66261..19a09b99b0 100644 --- a/templates/repo/activity.tmpl +++ b/templates/repo/activity.tmpl @@ -2,9 +2,11 @@