We'd love to move the routes to their own file.
And then being able to add them via `custom/`.
mj-v1.12
domi41 4 years ago
parent 0afecf40c3
commit 6aa4841e08

@ -1199,7 +1199,9 @@ milestones.filter_sort.least_issues = Least issues
polls = Polls
polls.create = Create Poll
polls.create.success = You created the poll '%s'.
polls.cancel = Cancel
polls.delete.success = You deleted the poll. Why would you do such a thing?! I'm hurt.
polls.modify = Update Poll
polls.operate.edit = Edit
polls.operate.delete = Delete
@ -1218,6 +1220,7 @@ polls.candidates.pool.indices = All of these
polls.candidates.pool.indices.help = Comma-separated list of issues
polls.edit = Edit Poll
polls.edit.subheader = Should one be allowed to change the subject after the poll has started?
polls.edit.success = You edited the poll '%s' successfully.
polls.modal.deletion.header = Are you sure you want to delete this poll?
polls.modal.deletion.description = This operation CANNOT be undone! It will also delete all attached judgments.
polls.judgments.create.success = Your judgment was recorded. Thank you ! (+0.618 karma)

@ -59,8 +59,7 @@ func NewPoll(ctx *context.Context) {
// NewPollPost processes the "new poll" form and redirects
func NewPollPost(ctx *context.Context, form auth.CreatePollForm) {
ctx.Data["Title"] = ctx.Tr("repo.polls.new")
//ctx.Data["DateLang"] = setting.DateLang(ctx.Locale.Language())
ctx.Data["PageIsPolls"] = true
if ctx.HasError() {
ctx.HTML(200, tplPollsNew)
return
@ -76,16 +75,17 @@ func NewPollPost(ctx *context.Context, form auth.CreatePollForm) {
return
}
ctx.Flash.Success(ctx.Tr("repo.polls.create_success", form.Subject))
ctx.Flash.Success(ctx.Tr("repo.polls.create.success", form.Subject))
ctx.Redirect(ctx.Repo.RepoLink + "/polls")
}
// ViewPoll renders display poll page
func ViewPoll(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.polls.view")
ctx.Data["PageIsPolls"] = true
poll, err := models.GetPollByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
if err != nil {
if nil != err {
if models.IsErrPollNotFound(err) {
ctx.NotFound("", nil)
} else {
@ -109,7 +109,7 @@ func EditPoll(ctx *context.Context) {
//ctx.Data["DateLang"] = setting.DateLang(ctx.Locale.Language())
m, err := models.GetPollByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
if err != nil {
if nil != err {
if models.IsErrPollNotFound(err) {
ctx.NotFound("", nil)
} else {
@ -125,7 +125,7 @@ func EditPoll(ctx *context.Context) {
// EditPollPost response for edting poll
func EditPollPost(ctx *context.Context, form auth.CreatePollForm) {
ctx.Data["Title"] = ctx.Tr("repo.polls.edit")
//ctx.Data["PageIsPolls"] = true
ctx.Data["PageIsPolls"] = true
ctx.Data["PageIsEditPoll"] = true
//ctx.Data["DateLang"] = setting.DateLang(ctx.Locale.Language())
@ -163,7 +163,7 @@ func EditPollPost(ctx *context.Context, form auth.CreatePollForm) {
return
}
ctx.Flash.Success(ctx.Tr("repo.polls.edit_success", m.Subject))
ctx.Flash.Success(ctx.Tr("repo.polls.edit.success", m.Subject))
ctx.Redirect(ctx.Repo.RepoLink + "/polls")
}
@ -172,7 +172,7 @@ func DeletePoll(ctx *context.Context) {
if err := models.DeletePollByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")); err != nil {
ctx.Flash.Error("DeletePollByRepoID: " + err.Error())
} else {
ctx.Flash.Success(ctx.Tr("repo.polls.deletion_success"))
ctx.Flash.Success(ctx.Tr("repo.polls.delete.success"))
}
ctx.JSON(200, map[string]interface{}{

@ -715,6 +715,10 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Combo("/compare/*", repo.MustBeNotEmpty, reqRepoCodeReader, repo.SetEditorconfigIfExists).
Get(ignSignIn, repo.SetDiffViewStyle, repo.CompareDiff).
Post(reqSignIn, context.RepoMustNotBeArchived(), reqRepoPullsReader, repo.MustAllowPulls, bindIgnErr(auth.CreateIssueForm{}), repo.CompareAndPullRequestPost)
m.Group("/polls", func() {
m.Get("", repo.IndexPolls)
m.Get("/:id", repo.ViewPoll)
}, context.RepoAssignment(), context.RepoRef())
}, context.RepoAssignment(), context.UnitTypes())
// Grouping for those endpoints that do require authentication
@ -775,17 +779,18 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Post("/:id/:action", repo.ChangeMilestonStatus)
m.Post("/delete", repo.DeleteMilestone)
}, context.RepoMustNotBeArchived(), reqRepoIssuesOrPullsWriter, context.RepoRef())
m.Group("/polls", func() {
m.Get("", repo.IndexPolls)
m.Combo("/new").
Get(repo.NewPoll).
Post(bindIgnErr(auth.CreatePollForm{}), repo.NewPollPost)
m.Get("/:id", repo.ViewPoll)
m.Get("/:id/edit", repo.EditPoll)
m.Post("/:id/edit", bindIgnErr(auth.CreatePollForm{}), repo.EditPollPost)
m.Post("/:id/delete", repo.DeletePoll)
m.Post("/:id/judgments", repo.EmitJudgment)
})
//m.Delete("/:id/judgments", repo.DeleteJudgment)
}, context.RepoMustNotBeArchived())
m.Group("/pull", func() {
m.Post("/:index/target_branch", repo.UpdatePullRequestTarget)
}, context.RepoMustNotBeArchived())

Loading…
Cancel
Save