|
|
@ -20,26 +20,27 @@ import ( |
|
|
|
func Dashboard(ctx *middleware.Context) { |
|
|
|
func Dashboard(ctx *middleware.Context) { |
|
|
|
ctx.Data["Title"] = "Dashboard" |
|
|
|
ctx.Data["Title"] = "Dashboard" |
|
|
|
ctx.Data["PageIsUserDashboard"] = true |
|
|
|
ctx.Data["PageIsUserDashboard"] = true |
|
|
|
repos, err := models.GetRepositories(&models.User{Id: ctx.User.Id}, true) |
|
|
|
|
|
|
|
|
|
|
|
var err error |
|
|
|
|
|
|
|
ctx.Data["MyRepos"], err = models.GetRepositories(ctx.User.Id, true) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.Handle(500, "home.Dashboard(GetRepositories)", err) |
|
|
|
ctx.Handle(500, "home.Dashboard(GetRepositories)", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.Data["MyRepos"] = repos |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
collaRepos, err := models.GetCollaborativeRepos(ctx.User.Name) |
|
|
|
ctx.Data["CollaborativeRepos"], err = models.GetCollaborativeRepos(ctx.User.Name) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.Handle(500, "home.Dashboard(GetCollaborativeRepos)", err) |
|
|
|
ctx.Handle(500, "home.Dashboard(GetCollaborativeRepos)", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.Data["CollaborativeRepos"] = collaRepos |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
actions, 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, "home.Dashboard", err) |
|
|
|
ctx.Handle(500, "home.Dashboard(GetFeeds)", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check access of private repositories.
|
|
|
|
feeds := make([]*models.Action, 0, len(actions)) |
|
|
|
feeds := make([]*models.Action, 0, len(actions)) |
|
|
|
for _, act := range actions { |
|
|
|
for _, act := range actions { |
|
|
|
if act.IsPrivate { |
|
|
|
if act.IsPrivate { |
|
|
@ -50,47 +51,42 @@ func Dashboard(ctx *middleware.Context) { |
|
|
|
} |
|
|
|
} |
|
|
|
feeds = append(feeds, act) |
|
|
|
feeds = append(feeds, act) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ctx.Data["Feeds"] = feeds |
|
|
|
ctx.Data["Feeds"] = feeds |
|
|
|
ctx.HTML(200, "user/dashboard") |
|
|
|
ctx.HTML(200, "user/dashboard") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func Profile(ctx *middleware.Context, params martini.Params) { |
|
|
|
func Profile(ctx *middleware.Context, params martini.Params) { |
|
|
|
ctx.Data["Title"] = "Profile" |
|
|
|
ctx.Data["Title"] = "Profile" |
|
|
|
|
|
|
|
ctx.Data["PageIsUserProfile"] = true |
|
|
|
|
|
|
|
|
|
|
|
user, err := models.GetUserByName(params["username"]) |
|
|
|
user, err := models.GetUserByName(params["username"]) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
if err == models.ErrUserNotExist { |
|
|
|
if err == models.ErrUserNotExist { |
|
|
|
ctx.Handle(404, "user.Profile", err) |
|
|
|
ctx.Handle(404, "user.Profile(GetUserByName)", err) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ctx.Handle(500, "user.Profile", err) |
|
|
|
ctx.Handle(500, "user.Profile(GetUserByName)", err) |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ctx.Data["Owner"] = user |
|
|
|
ctx.Data["Owner"] = user |
|
|
|
|
|
|
|
|
|
|
|
tab := ctx.Query("tab") |
|
|
|
tab := ctx.Query("tab") |
|
|
|
ctx.Data["TabName"] = tab |
|
|
|
ctx.Data["TabName"] = tab |
|
|
|
|
|
|
|
|
|
|
|
switch tab { |
|
|
|
switch tab { |
|
|
|
case "activity": |
|
|
|
case "activity": |
|
|
|
feeds, err := models.GetFeeds(user.Id, 0, true) |
|
|
|
ctx.Data["Feeds"], err = models.GetFeeds(user.Id, 0, true) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.Handle(500, "user.Profile", err) |
|
|
|
ctx.Handle(500, "user.Profile(GetFeeds)", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.Data["Feeds"] = feeds |
|
|
|
|
|
|
|
default: |
|
|
|
default: |
|
|
|
repos, err := models.GetRepositories(user, ctx.IsSigned && ctx.User.Id == user.Id) |
|
|
|
ctx.Data["Repos"], err = models.GetRepositories(user.Id, ctx.IsSigned && ctx.User.Id == user.Id) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.Handle(500, "user.Profile", err) |
|
|
|
ctx.Handle(500, "user.Profile(GetRepositories)", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.Data["Repos"] = repos |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ctx.Data["PageIsUserProfile"] = true |
|
|
|
|
|
|
|
ctx.HTML(200, "user/profile") |
|
|
|
ctx.HTML(200, "user/profile") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -98,13 +94,12 @@ func Email2User(ctx *middleware.Context) { |
|
|
|
u, err := models.GetUserByEmail(ctx.Query("email")) |
|
|
|
u, err := models.GetUserByEmail(ctx.Query("email")) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
if err == models.ErrUserNotExist { |
|
|
|
if err == models.ErrUserNotExist { |
|
|
|
ctx.Handle(404, "user.Email2User", err) |
|
|
|
ctx.Handle(404, "user.Email2User(GetUserByEmail)", err) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ctx.Handle(500, "user.Email2User(GetUserByEmail)", err) |
|
|
|
ctx.Handle(500, "user.Email2User(GetUserByEmail)", err) |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ctx.Redirect("/user/" + u.Name) |
|
|
|
ctx.Redirect("/user/" + u.Name) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -145,36 +140,32 @@ func Issues(ctx *middleware.Context) { |
|
|
|
|
|
|
|
|
|
|
|
isShowClosed := ctx.Query("state") == "closed" |
|
|
|
isShowClosed := ctx.Query("state") == "closed" |
|
|
|
|
|
|
|
|
|
|
|
var assigneeId, posterId int64 |
|
|
|
|
|
|
|
var filterMode int |
|
|
|
var filterMode int |
|
|
|
switch viewType { |
|
|
|
switch viewType { |
|
|
|
case "assigned": |
|
|
|
case "assigned": |
|
|
|
assigneeId = ctx.User.Id |
|
|
|
|
|
|
|
filterMode = models.FM_ASSIGN |
|
|
|
filterMode = models.FM_ASSIGN |
|
|
|
case "created_by": |
|
|
|
case "created_by": |
|
|
|
posterId = ctx.User.Id |
|
|
|
|
|
|
|
filterMode = models.FM_CREATE |
|
|
|
filterMode = models.FM_CREATE |
|
|
|
} |
|
|
|
} |
|
|
|
_, _ = assigneeId, posterId |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rid, _ := base.StrTo(ctx.Query("repoid")).Int64() |
|
|
|
repoId, _ := base.StrTo(ctx.Query("repoid")).Int64() |
|
|
|
issueStats := models.GetUserIssueStats(ctx.User.Id, filterMode) |
|
|
|
issueStats := models.GetUserIssueStats(ctx.User.Id, filterMode) |
|
|
|
|
|
|
|
|
|
|
|
// Get all repositories.
|
|
|
|
// Get all repositories.
|
|
|
|
repos, err := models.GetRepositories(ctx.User, true) |
|
|
|
repos, err := models.GetRepositories(ctx.User.Id, true) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.Handle(500, "user.Issues(GetRepositories)", err) |
|
|
|
ctx.Handle(500, "user.Issues(GetRepositories)", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
rids := make([]int64, 0, len(repos)) |
|
|
|
repoIds := make([]int64, 0, len(repos)) |
|
|
|
showRepos := make([]*models.Repository, 0, len(repos)) |
|
|
|
showRepos := make([]*models.Repository, 0, len(repos)) |
|
|
|
for _, repo := range repos { |
|
|
|
for _, repo := range repos { |
|
|
|
if repo.NumIssues == 0 { |
|
|
|
if repo.NumIssues == 0 { |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
rids = append(rids, repo.Id) |
|
|
|
repoIds = append(repoIds, repo.Id) |
|
|
|
repo.NumOpenIssues = repo.NumIssues - repo.NumClosedIssues |
|
|
|
repo.NumOpenIssues = repo.NumIssues - repo.NumClosedIssues |
|
|
|
issueStats.AllCount += int64(repo.NumOpenIssues) |
|
|
|
issueStats.AllCount += int64(repo.NumOpenIssues) |
|
|
|
|
|
|
|
|
|
|
@ -195,8 +186,8 @@ func Issues(ctx *middleware.Context) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if rid > 0 { |
|
|
|
if repoId > 0 { |
|
|
|
rids = []int64{rid} |
|
|
|
repoIds = []int64{repoId} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
page, _ := base.StrTo(ctx.Query("page")).Int() |
|
|
|
page, _ := base.StrTo(ctx.Query("page")).Int() |
|
|
@ -207,9 +198,9 @@ func Issues(ctx *middleware.Context) { |
|
|
|
case "assigned": |
|
|
|
case "assigned": |
|
|
|
fallthrough |
|
|
|
fallthrough |
|
|
|
case "created_by": |
|
|
|
case "created_by": |
|
|
|
ius, err = models.GetIssueUserPairsByMode(ctx.User.Id, rid, isShowClosed, page, filterMode) |
|
|
|
ius, err = models.GetIssueUserPairsByMode(ctx.User.Id, repoId, isShowClosed, page, filterMode) |
|
|
|
default: |
|
|
|
default: |
|
|
|
ius, err = models.GetIssueUserPairsByRepoIds(rids, isShowClosed, page) |
|
|
|
ius, err = models.GetIssueUserPairsByRepoIds(repoIds, isShowClosed, page) |
|
|
|
} |
|
|
|
} |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.Handle(500, "user.Issues(GetAllIssueUserPairs)", err) |
|
|
|
ctx.Handle(500, "user.Issues(GetAllIssueUserPairs)", err) |
|
|
@ -251,7 +242,7 @@ func Issues(ctx *middleware.Context) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ctx.Data["RepoId"] = rid |
|
|
|
ctx.Data["RepoId"] = repoId |
|
|
|
ctx.Data["Repos"] = showRepos |
|
|
|
ctx.Data["Repos"] = showRepos |
|
|
|
ctx.Data["Issues"] = issues |
|
|
|
ctx.Data["Issues"] = issues |
|
|
|
ctx.Data["ViewType"] = viewType |
|
|
|
ctx.Data["ViewType"] = viewType |
|
|
@ -263,7 +254,7 @@ func Issues(ctx *middleware.Context) { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ctx.Data["ShowCount"] = issueStats.OpenCount |
|
|
|
ctx.Data["ShowCount"] = issueStats.OpenCount |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.HTML(200, "issue/user") |
|
|
|
ctx.HTML(200, "user/issue") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func Pulls(ctx *middleware.Context) { |
|
|
|
func Pulls(ctx *middleware.Context) { |
|
|
|