Add a repo header nav item for polls.

Ideally this whole thing should be a plugin and not a fork.
Not sure how to add new Db models and Routes.
We'd also need a custom spot in the issue view template,
but that can probably be merged upstream.
mj-v1.12
domi41 4 years ago
parent de1d54ada9
commit 0afecf40c3

@ -1197,6 +1197,7 @@ milestones.filter_sort.most_complete = Most complete
milestones.filter_sort.most_issues = Most issues
milestones.filter_sort.least_issues = Least issues
polls = Polls
polls.create = Create Poll
polls.cancel = Cancel
polls.modify = Update Poll

@ -24,7 +24,7 @@ const (
// IndexPolls renders an index of all the polls
func IndexPolls(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.polls.index.title")
//ctx.Data["PageIsMilestones"] = true
ctx.Data["PageIsPolls"] = true
page := ctx.QueryInt("page") // 0 if not defined ?
if page <= 1 {
@ -49,6 +49,7 @@ func IndexPolls(ctx *context.Context) {
// NewPoll renders the "new poll" page with its form
func NewPoll(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.polls.new")
ctx.Data["PageIsPolls"] = true
//ctx.Data["DateLang"] = setting.DateLang(ctx.Locale.Language())
@ -103,7 +104,7 @@ func ViewPoll(ctx *context.Context) {
// EditPoll renders editing poll page
func EditPoll(ctx *context.Context) {
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())

@ -127,6 +127,13 @@
</a>
{{end}}
{{/* TODO: make a permission for reading polls and use it here */}}
{{ if (.Permission.CanReadAny $.UnitTypePullRequests $.UnitTypeIssues $.UnitTypeReleases) }}
<a class="{{ if .PageIsPolls }}active{{ end }} item" href="{{ .RepoLink }}/polls">
{{svg "octicon-law" 16}} {{.i18n.Tr "repo.polls"}}
</a>
{{ end }}
{{if and (.Permission.CanReadAny $.UnitTypePullRequests $.UnitTypeIssues $.UnitTypeReleases) (not .IsEmptyRepo)}}
<a class="{{if .PageIsActivity}}active{{end}} item" href="{{.RepoLink}}/activity">
{{svg "octicon-pulse" 16}} {{.i18n.Tr "repo.activity"}}

Loading…
Cancel
Save