From b9b82cfe477bcbfd3541adfc969ff20210d56549 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 23 Mar 2014 19:09:11 -0400 Subject: [PATCH] Mirror updates --- .gobuild.yml | 3 ++- conf/app.ini | 2 ++ models/issue.go | 19 ++++++++++++++--- modules/base/conf.go | 13 ++++++++++++ routers/repo/issue.go | 40 +++++++++++++++++++++++++++++++++-- templates/admin/config.tmpl | 1 + templates/user/dashboard.tmpl | 2 +- templates/user/profile.tmpl | 2 +- web.go | 3 ++- 9 files changed, 76 insertions(+), 9 deletions(-) diff --git a/.gobuild.yml b/.gobuild.yml index d667c93082..78a38f2d31 100644 --- a/.gobuild.yml +++ b/.gobuild.yml @@ -4,4 +4,5 @@ filesets: - public - conf - LICENSE - - README.md \ No newline at end of file + - README.md + - README_ZH.md \ No newline at end of file diff --git a/conf/app.ini b/conf/app.ini index ee44dd408e..809ea61c07 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -52,6 +52,8 @@ DISENABLE_REGISTERATION = false REQUIRE_SIGNIN_VIEW = false ; Cache avatar as picture ENABLE_CACHE_AVATAR = false +; Mail notification +ENABLE_NOTIFY_MAIL = false [mailer] ENABLED = false diff --git a/models/issue.go b/models/issue.go index 929567b1b7..fe43a94b59 100644 --- a/models/issue.go +++ b/models/issue.go @@ -58,6 +58,7 @@ func CreateIssue(userId, repoId, milestoneId, assigneeId int64, name, labels, co Content: content, } _, err = orm.Insert(issue) + // TODO: newIssueAction return issue, err } @@ -67,9 +68,9 @@ func GetIssueCount(repoId int64) (int64, error) { } // GetIssueById returns issue object by given id. -func GetIssueById(id int64) (*Issue, error) { - issue := new(Issue) - has, err := orm.Id(id).Get(issue) +func GetIssueByIndex(repoId, index int64) (*Issue, error) { + issue := &Issue{RepoId: repoId, Index: index} + has, err := orm.Get(issue) if err != nil { return nil, err } else if !has { @@ -126,6 +127,18 @@ func GetIssues(userId, repoId, posterId, milestoneId int64, page int, isClosed, return issues, err } +// UpdateIssue updates information of issue. +func UpdateIssue(issue *Issue) error { + _, err := orm.Update(issue, &Issue{RepoId: issue.RepoId, Index: issue.Index}) + return err +} + +func CloseIssue() { +} + +func ReopenIssue() { +} + // Label represents a list of labels of repository for issues. type Label struct { Id int64 diff --git a/modules/base/conf.go b/modules/base/conf.go index b243a6ad58..2bf529d9d1 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -66,6 +66,7 @@ var Service struct { DisenableRegisteration bool RequireSignInView bool EnableCacheAvatar bool + NotifyMail bool ActiveCodeLives int ResetPwdCodeLives int } @@ -230,6 +231,17 @@ func newRegisterMailService() { log.Info("Register Mail Service Enabled") } +func newNotifyMailService() { + if !Cfg.MustBool("service", "ENABLE_NOTIFY_MAIL") { + return + } else if MailService == nil { + log.Warn("Notify Mail Service: Mail Service is not enabled") + return + } + Service.NotifyMail = true + log.Info("Notify Mail Service Enabled") +} + func NewConfigContext() { var err error workDir, err := exeDir() @@ -284,4 +296,5 @@ func NewServices() { newSessionService() newMailService() newRegisterMailService() + newNotifyMailService() } diff --git a/routers/repo/issue.go b/routers/repo/issue.go index a9d8799314..e03f115e24 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -67,13 +67,13 @@ func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat } func ViewIssue(ctx *middleware.Context, params martini.Params) { - issueid, err := base.StrTo(params["issueid"]).Int() + index, err := base.StrTo(params["index"]).Int() if err != nil { ctx.Handle(404, "issue.ViewIssue", err) return } - issue, err := models.GetIssueById(int64(issueid)) + issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, int64(index)) if err != nil { if err == models.ErrIssueNotExist { ctx.Handle(404, "issue.ViewIssue", err) @@ -87,3 +87,39 @@ func ViewIssue(ctx *middleware.Context, params martini.Params) { ctx.Data["Issue"] = issue ctx.HTML(200, "issue/view") } + +func UpdateIssue(ctx *middleware.Context, params martini.Params, form auth.CreateIssueForm) { + if !ctx.Repo.IsOwner { + ctx.Handle(404, "issue.UpdateIssue", nil) + return + } + + index, err := base.StrTo(params["index"]).Int() + if err != nil { + ctx.Handle(404, "issue.UpdateIssue", err) + return + } + + issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, int64(index)) + if err != nil { + if err == models.ErrIssueNotExist { + ctx.Handle(404, "issue.UpdateIssue", err) + } else { + ctx.Handle(200, "issue.UpdateIssue", err) + } + return + } + + issue.Name = form.IssueName + issue.MilestoneId = form.MilestoneId + issue.AssigneeId = form.AssigneeId + issue.Labels = form.Labels + issue.Content = form.Content + if err = models.UpdateIssue(issue); err != nil { + ctx.Handle(200, "issue.UpdateIssue", err) + return + } + + ctx.Data["Title"] = issue.Name + ctx.Data["Issue"] = issue +} diff --git a/templates/admin/config.tmpl b/templates/admin/config.tmpl index d33a07cc3f..1e26304602 100644 --- a/templates/admin/config.tmpl +++ b/templates/admin/config.tmpl @@ -46,6 +46,7 @@
Register Email Confirmation:
Disenable Registeration:
Require Sign In View:
+
Mail Notification:
Enable Cache Avatar:

Active Code Lives: {{.Service.ActiveCodeLives}} minutes
diff --git a/templates/user/dashboard.tmpl b/templates/user/dashboard.tmpl index 6594e54591..ca5fecf268 100644 --- a/templates/user/dashboard.tmpl +++ b/templates/user/dashboard.tmpl @@ -34,7 +34,7 @@
diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl index 2d76d9bf01..3422361474 100644 --- a/templates/user/profile.tmpl +++ b/templates/user/profile.tmpl @@ -50,7 +50,7 @@