From 1a97030017cd09b75f6c8d484e075f4eced1e001 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 1 May 2018 21:05:28 +0200 Subject: Issue due date (#3794) * Started adding deadline to ui * Implemented basic issue due date managing * Improved UI for due date managing * Added at least write access to the repo in order to modify issue due dates * Ui improvements * Added issue comments creation when adding/modifying/removing a due date * Show due date in issue list * Added api support for issue due dates * Fixed lint suggestions * Added deadline to sdk * Updated css * Added support for adding/modifiying deadlines for pull requests via api * Fixed comments not created when updating or removing a deadline * update sdk (will do properly once go-gitea/go-sdk#103 is merged) * enhanced updateIssueDeadline * Removed unnessecary Issue.DeadlineString * UI improvements * Small improvments to comment creation + ui & validation improvements * Check if an issue is overdue is now a seperate function * Updated go-sdk with govendor as it was merged * Simplified isOverdue method * removed unessecary deadline to 0 set * Update swagger definitions * Added missing return * Added an explanary comment * Improved updateIssueDeadline method so it'll only update `deadline_unix` * Small changes and improvements * no need to explicitly load the issue when updating a deadline, just use whats already there * small optimisations * Added check if a deadline was modified before updating it * Moved comment creating logic into its own function * Code cleanup for creating deadline comment * locale improvement * When modifying a deadline, the old deadline is saved with the comment * small improvments to xorm session handling when updating an issue deadline + style nitpicks * style nitpicks * Moved checking for if the user has write acces to middleware --- modules/auth/repo_form.go | 10 ++++++++++ modules/templates/helper.go | 3 +++ 2 files changed, 13 insertions(+) (limited to 'modules') diff --git a/modules/auth/repo_form.go b/modules/auth/repo_form.go index da9a845807..4aa9ce5f58 100644 --- a/modules/auth/repo_form.go +++ b/modules/auth/repo_form.go @@ -521,3 +521,13 @@ func (f *AddTimeManuallyForm) Validate(ctx *macaron.Context, errs binding.Errors type SaveTopicForm struct { Topics []string `binding:"topics;Required;"` } + +// DeadlineForm hold the validation rules for deadlines +type DeadlineForm struct { + DateString string `form:"date" binding:"Required;Size(10)"` +} + +// Validate validates the fields +func (f *DeadlineForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { + return validate(errs, ctx.Data, f, ctx.Locale) +} diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 74e775cc63..bf5c0130b6 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -183,6 +183,9 @@ func NewFuncMap() []template.FuncMap { "Printf": fmt.Sprintf, "Escape": Escape, "Sec2Time": models.SecToTime, + "ParseDeadline": func(deadline string) []string { + return strings.Split(deadline, "|") + }, }} } -- cgit v1.2.3