summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo/repo.go6
-rw-r--r--routers/routes/macaron.go6
-rw-r--r--routers/user/home.go68
3 files changed, 47 insertions, 33 deletions
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go
index 048f7d6b1f..f1df31ccac 100644
--- a/routers/api/v1/repo/repo.go
+++ b/routers/api/v1/repo/repo.go
@@ -70,6 +70,11 @@ func Search(ctx *context.APIContext) {
// description: repo owner to prioritize in the results
// type: integer
// format: int64
+ // - name: team_id
+ // in: query
+ // description: search only for repos that belong to the given team id
+ // type: integer
+ // format: int64
// - name: starredBy
// in: query
// description: search only for repos that the user with the given id has starred
@@ -131,6 +136,7 @@ func Search(ctx *context.APIContext) {
Keyword: strings.Trim(ctx.Query("q"), " "),
OwnerID: ctx.QueryInt64("uid"),
PriorityOwnerID: ctx.QueryInt64("priority_owner_id"),
+ TeamID: ctx.QueryInt64("team_id"),
TopicOnly: ctx.QueryBool("topic"),
Collaborate: util.OptionalBoolNone,
Private: ctx.IsSigned && (ctx.Query("private") == "" || ctx.QueryBool("private")),
diff --git a/routers/routes/macaron.go b/routers/routes/macaron.go
index 16977b9470..019b476e71 100644
--- a/routers/routes/macaron.go
+++ b/routers/routes/macaron.go
@@ -444,13 +444,15 @@ func RegisterMacaronRoutes(m *macaron.Macaron) {
m.Group("/:org", func() {
m.Get("/dashboard", user.Dashboard)
+ m.Get("/dashboard/:team", user.Dashboard)
m.Get("/^:type(issues|pulls)$", user.Issues)
+ m.Get("/^:type(issues|pulls)$/:team", user.Issues)
m.Get("/milestones", reqMilestonesDashboardPageEnabled, user.Milestones)
+ m.Get("/milestones/:team", reqMilestonesDashboardPageEnabled, user.Milestones)
m.Get("/members", org.Members)
m.Post("/members/action/:action", org.MembersAction)
-
m.Get("/teams", org.Teams)
- }, context.OrgAssignment(true))
+ }, context.OrgAssignment(true, false, true))
m.Group("/:org", func() {
m.Get("/teams/:team", org.TeamMembers)
diff --git a/routers/user/home.go b/routers/user/home.go
index 92a9138475..27b7f3c29b 100644
--- a/routers/user/home.go
+++ b/routers/user/home.go
@@ -42,17 +42,8 @@ func getDashboardContextUser(ctx *context.Context) *models.User {
ctxUser := ctx.User
orgName := ctx.Params(":org")
if len(orgName) > 0 {
- // Organization.
- org, err := models.GetUserByName(orgName)
- if err != nil {
- if models.IsErrUserNotExist(err) {
- ctx.NotFound("GetUserByName", err)
- } else {
- ctx.ServerError("GetUserByName", err)
- }
- return nil
- }
- ctxUser = org
+ ctxUser = ctx.Org.Organization
+ ctx.Data["Teams"] = ctx.Org.Organization.Teams
}
ctx.Data["ContextUser"] = ctxUser
@@ -112,12 +103,13 @@ func Dashboard(ctx *context.Context) {
ctx.Data["PageIsDashboard"] = true
ctx.Data["PageIsNews"] = true
ctx.Data["SearchLimit"] = setting.UI.User.RepoPagingNum
+
// no heatmap access for admins; GetUserHeatmapDataByUser ignores the calling user
// so everyone would get the same empty heatmap
if setting.Service.EnableUserHeatmap && !ctxUser.KeepActivityPrivate {
- data, err := models.GetUserHeatmapDataByUser(ctxUser, ctx.User)
+ data, err := models.GetUserHeatmapDataByUserTeam(ctxUser, ctx.Org.Team, ctx.User)
if err != nil {
- ctx.ServerError("GetUserHeatmapDataByUser", err)
+ ctx.ServerError("GetUserHeatmapDataByUserTeam", err)
return
}
ctx.Data["HeatmapData"] = data
@@ -126,12 +118,16 @@ func Dashboard(ctx *context.Context) {
var err error
var mirrors []*models.Repository
if ctxUser.IsOrganization() {
- env, err := ctxUser.AccessibleReposEnv(ctx.User.ID)
- if err != nil {
- ctx.ServerError("AccessibleReposEnv", err)
- return
+ var env models.AccessibleReposEnvironment
+ if ctx.Org.Team != nil {
+ env = ctxUser.AccessibleTeamReposEnv(ctx.Org.Team)
+ } else {
+ env, err = ctxUser.AccessibleReposEnv(ctx.User.ID)
+ if err != nil {
+ ctx.ServerError("AccessibleReposEnv", err)
+ return
+ }
}
-
mirrors, err = env.MirrorRepos()
if err != nil {
ctx.ServerError("env.MirrorRepos", err)
@@ -155,6 +151,7 @@ func Dashboard(ctx *context.Context) {
retrieveFeeds(ctx, models.GetFeedsOptions{
RequestedUser: ctxUser,
+ RequestedTeam: ctx.Org.Team,
Actor: ctx.User,
IncludePrivate: true,
OnlyPerformedBy: false,
@@ -183,16 +180,20 @@ func Milestones(ctx *context.Context) {
return
}
- var (
- repoOpts = models.SearchRepoOptions{
- Actor: ctxUser,
- OwnerID: ctxUser.ID,
- Private: true,
- AllPublic: false, // Include also all public repositories of users and public organisations
- AllLimited: false, // Include also all public repositories of limited organisations
- HasMilestones: util.OptionalBoolTrue, // Just needs display repos has milestones
- }
+ repoOpts := models.SearchRepoOptions{
+ Actor: ctxUser,
+ OwnerID: ctxUser.ID,
+ Private: true,
+ AllPublic: false, // Include also all public repositories of users and public organisations
+ AllLimited: false, // Include also all public repositories of limited organisations
+ HasMilestones: util.OptionalBoolTrue, // Just needs display repos has milestones
+ }
+
+ if ctxUser.IsOrganization() && ctx.Org.Team != nil {
+ repoOpts.TeamID = ctx.Org.Team.ID
+ }
+ var (
userRepoCond = models.SearchRepositoryCondition(&repoOpts) // all repo condition user could visit
repoCond = userRepoCond
repoIDs []int64
@@ -412,10 +413,15 @@ func Issues(ctx *context.Context) {
var err error
var userRepoIDs []int64
if ctxUser.IsOrganization() {
- env, err := ctxUser.AccessibleReposEnv(ctx.User.ID)
- if err != nil {
- ctx.ServerError("AccessibleReposEnv", err)
- return
+ var env models.AccessibleReposEnvironment
+ if ctx.Org.Team != nil {
+ env = ctxUser.AccessibleTeamReposEnv(ctx.Org.Team)
+ } else {
+ env, err = ctxUser.AccessibleReposEnv(ctx.User.ID)
+ if err != nil {
+ ctx.ServerError("AccessibleReposEnv", err)
+ return
+ }
}
userRepoIDs, err = env.RepoIDs(1, ctxUser.NumRepos)
if err != nil {