|
|
@ -27,11 +27,23 @@ func Dashboard(ctx *middleware.Context) { |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.Data["MyRepos"] = repos |
|
|
|
ctx.Data["MyRepos"] = repos |
|
|
|
|
|
|
|
|
|
|
|
feeds, err := models.GetFeeds(ctx.User.Id, 0, false) |
|
|
|
actions, err := models.GetFeeds(ctx.User.Id, 0, false) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.Handle(500, "user.Dashboard", err) |
|
|
|
ctx.Handle(500, "user.Dashboard", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
feeds := make([]*models.Action, 0, len(actions)) |
|
|
|
|
|
|
|
for _, act := range actions { |
|
|
|
|
|
|
|
if act.IsPrivate { |
|
|
|
|
|
|
|
if has, _ := models.HasAccess(ctx.User.Name, act.RepoUserName+"/"+act.RepoName, |
|
|
|
|
|
|
|
models.AU_READABLE); !has { |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
feeds = append(feeds, act) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ctx.Data["Feeds"] = feeds |
|
|
|
ctx.Data["Feeds"] = feeds |
|
|
|
ctx.HTML(200, "user/dashboard") |
|
|
|
ctx.HTML(200, "user/dashboard") |
|
|
|
} |
|
|
|
} |
|
|
@ -39,7 +51,6 @@ func Dashboard(ctx *middleware.Context) { |
|
|
|
func Profile(ctx *middleware.Context, params martini.Params) { |
|
|
|
func Profile(ctx *middleware.Context, params martini.Params) { |
|
|
|
ctx.Data["Title"] = "Profile" |
|
|
|
ctx.Data["Title"] = "Profile" |
|
|
|
|
|
|
|
|
|
|
|
// TODO: Need to check view self or others.
|
|
|
|
|
|
|
|
user, err := models.GetUserByName(params["username"]) |
|
|
|
user, err := models.GetUserByName(params["username"]) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.Handle(500, "user.Profile", err) |
|
|
|
ctx.Handle(500, "user.Profile", err) |
|
|
@ -95,12 +106,19 @@ func Feeds(ctx *middleware.Context, form auth.FeedsForm) { |
|
|
|
actions, err := models.GetFeeds(form.UserId, form.Page*20, false) |
|
|
|
actions, err := models.GetFeeds(form.UserId, form.Page*20, false) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.JSON(500, err) |
|
|
|
ctx.JSON(500, err) |
|
|
|
|
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
feeds := make([]string, len(actions)) |
|
|
|
feeds := make([]string, 0, len(actions)) |
|
|
|
for i := range actions { |
|
|
|
for _, act := range actions { |
|
|
|
feeds[i] = fmt.Sprintf(TPL_FEED, base.ActionIcon(actions[i].OpType), |
|
|
|
if act.IsPrivate { |
|
|
|
base.TimeSince(actions[i].Created), base.ActionDesc(actions[i])) |
|
|
|
if has, _ := models.HasAccess(ctx.User.Name, act.RepoUserName+"/"+act.RepoName, |
|
|
|
|
|
|
|
models.AU_READABLE); !has { |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
feeds = append(feeds, fmt.Sprintf(TPL_FEED, base.ActionIcon(act.OpType), |
|
|
|
|
|
|
|
base.TimeSince(act.Created), base.ActionDesc(act))) |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.JSON(200, &feeds) |
|
|
|
ctx.JSON(200, &feeds) |
|
|
|
} |
|
|
|
} |
|
|
|