Mercurial > gemma
changeset 2270:1c8b8a4476af
Print templates: Add country to listing if template has one.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 14 Feb 2019 16:05:02 +0100 |
parents | dfa4db82e784 |
children | 91ca0cdd2e35 a3e7e727209a |
files | pkg/controllers/printtemplates.go |
diffstat | 1 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/controllers/printtemplates.go Thu Feb 14 15:42:35 2019 +0100 +++ b/pkg/controllers/printtemplates.go Thu Feb 14 16:05:02 2019 +0100 @@ -32,7 +32,8 @@ listPrintTemplatesSQL = ` SELECT template_name, - date_info + date_info, + country FROM users.templates ORDER BY date_info DESC` @@ -66,8 +67,9 @@ ) (jr JSONResult, err error) { type template struct { - Name string `json:"name"` - Time models.Time `json:"time"` + Name string `json:"name"` + Time models.Time `json:"time"` + Country *string `json:"country,omitempty"` } var rows *sql.Rows @@ -81,10 +83,14 @@ for rows.Next() { var tmpl template var w time.Time - if err = rows.Scan(&tmpl.Name, &w); err != nil { + var country sql.NullString + if err = rows.Scan(&tmpl.Name, &w, &country); err != nil { return } tmpl.Time = models.Time{w} + if country.Valid { + tmpl.Country = &country.String + } templates = append(templates, &tmpl) }