aboutsummaryrefslogtreecommitdiffstats
path: root/routers/user
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-03-27 16:31:32 -0400
committerUnknown <joe2010xtmf@163.com>2014-03-27 16:31:32 -0400
commit34f4af9ebf179dbb24a7da6091b4259d66a3c426 (patch)
tree41be4b8840f28b03dd12551d6403cd459b9ced10 /routers/user
parentf76eb8a6662dd705f4c59fd59e583a315a1900d2 (diff)
downloadgitea-34f4af9ebf179dbb24a7da6091b4259d66a3c426.tar.gz
gitea-34f4af9ebf179dbb24a7da6091b4259d66a3c426.zip
Working on issue and install page
Diffstat (limited to 'routers/user')
-rw-r--r--routers/user/user.go60
1 files changed, 60 insertions, 0 deletions
diff --git a/routers/user/user.go b/routers/user/user.go
index d3ef96211e..052a277498 100644
--- a/routers/user/user.go
+++ b/routers/user/user.go
@@ -286,6 +286,66 @@ func Feeds(ctx *middleware.Context, form auth.FeedsForm) {
func Issues(ctx *middleware.Context) {
ctx.Data["Title"] = "Your Issues"
+ ctx.Data["ViewType"] = "all"
+
+ page, _ := base.StrTo(ctx.Query("page")).Int()
+
+ var posterId int64 = 0
+ if ctx.Query("type") == "created_by" {
+ posterId = ctx.User.Id
+ ctx.Data["ViewType"] = "created_by"
+ }
+
+ // Get all repositories.
+ repos, err := models.GetRepositories(ctx.User)
+ if err != nil {
+ ctx.Handle(200, "user.Issues(get repository)", err)
+ return
+ }
+
+ var closedIssueCount, createdByCount int
+
+ // Get all issues.
+ allIssues := make([]models.Issue, 0, 5*len(repos))
+ for i, repo := range repos {
+ issues, err := models.GetIssues(0, repo.Id, posterId, 0, page, false, false, "", "")
+ if err != nil {
+ ctx.Handle(200, "user.Issues(get issues)", err)
+ return
+ }
+
+ closedIssueCount += repo.NumClosedIssues
+ repos[i].NumOpenIssues = repo.NumIssues - repo.NumClosedIssues
+ allIssues = append(allIssues, issues...)
+ }
+
+ showIssues := make([]models.Issue, 0, len(allIssues))
+ isShowClosed := ctx.Query("state") == "closed"
+ ctx.Data["IsShowClosed"] = isShowClosed
+
+ // Get posters and filter issues.
+ for i := range allIssues {
+ u, err := models.GetUserById(allIssues[i].PosterId)
+ if err != nil {
+ ctx.Handle(200, "user.Issues(get poster): %v", err)
+ return
+ }
+ allIssues[i].Poster = u
+ if u.Id == ctx.User.Id {
+ createdByCount++
+ }
+
+ if isShowClosed == allIssues[i].IsClosed {
+ showIssues = append(showIssues, allIssues[i])
+ }
+ }
+
+ ctx.Data["Repos"] = repos
+ ctx.Data["Issues"] = showIssues
+ ctx.Data["AllIssueCount"] = len(allIssues)
+ ctx.Data["ClosedIssueCount"] = closedIssueCount
+ ctx.Data["OpenIssueCount"] = len(allIssues) - closedIssueCount
+ ctx.Data["CreatedByCount"] = createdByCount
ctx.HTML(200, "issue/user")
}