diff --git a/.gobuild.yml b/.gobuild.yml index d667c9308..78a38f2d3 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 ee44dd408..809ea61c0 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 929567b1b..fe43a94b5 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 b243a6ad5..2bf529d9d 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 a9d879931..e03f115e2 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 d33a07cc3..1e2630460 100644 --- a/templates/admin/config.tmpl +++ b/templates/admin/config.tmpl @@ -46,6 +46,7 @@