Mercurial > gemma
annotate pkg/controllers/printtemplates.go @ 2153:cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 08 Feb 2019 12:11:15 +0100 |
parents | 2c67c51d57ad |
children | 51c5aead78c0 |
rev | line source |
---|---|
2148
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 // This is Free Software under GNU Affero General Public License v >= 3.0 |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 // without warranty, see README.md and license for details. |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 // |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 // SPDX-License-Identifier: AGPL-3.0-or-later |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 // License-Filename: LICENSES/AGPL-3.0.txt |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 // |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 // Copyright (C) 2018 by via donau |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 // – Österreichische Wasserstraßen-Gesellschaft mbH |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 // Software engineering by Intevation GmbH |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 // |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 // Author(s): |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 package controllers |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 import ( |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 "database/sql" |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 "net/http" |
2150
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
19 "time" |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
20 |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
21 "gemma.intevation.de/gemma/pkg/models" |
2153
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
22 "github.com/gorilla/mux" |
2150
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
23 ) |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
24 |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
25 const ( |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
26 listPrintTemplatesSQL = ` |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
27 SELECT |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
28 template_name, |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
29 date_info |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
30 FROM |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
31 users.templates |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
32 ORDER BY date_info DESC` |
2153
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
33 |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
34 hasPrintTemplateSQL = ` |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
35 SELECT true FROM users.templates WHERE name = $1` |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
36 |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
37 deletePrintTemplateSQL = ` |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
38 DELETE FROM users.templates WHERE name = $1` |
2148
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 ) |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 func listPrintTemplates( |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 _ interface{}, |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 req *http.Request, |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 conn *sql.Conn, |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 ) (jr JSONResult, err error) { |
2150
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
46 |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
47 type template struct { |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
48 Name string `json:"name"` |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
49 Time models.Time `json:"time"` |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
50 } |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
51 |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
52 var rows *sql.Rows |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
53 if rows, err = conn.QueryContext(req.Context(), listPrintTemplatesSQL); err != nil { |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
54 return |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
55 } |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
56 defer rows.Close() |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
57 |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
58 templates := []*template{} |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
59 |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
60 for rows.Next() { |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
61 var tmpl template |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
62 var w time.Time |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
63 if err = rows.Scan(&tmpl.Name, &w); err != nil { |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
64 return |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
65 } |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
66 tmpl.Time = models.Time{w} |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
67 templates = append(templates, &tmpl) |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
68 } |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
69 |
2c67c51d57ad
Print templates: Implemented GET of all templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2148
diff
changeset
|
70 jr = JSONResult{Result: templates} |
2148
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 return |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 } |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 func fetchPrintTemplate( |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 _ interface{}, |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 req *http.Request, |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 conn *sql.Conn, |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 ) (jr JSONResult, err error) { |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
79 // TODO: Implement me! |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
80 return |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
81 } |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 func createPrintTemplate( |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 _ interface{}, |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
85 req *http.Request, |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
86 conn *sql.Conn, |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
87 ) (jr JSONResult, err error) { |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
88 // TODO: Implement me! |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
89 return |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 } |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 func deletePrintTemplate( |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
93 _ interface{}, |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 req *http.Request, |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 conn *sql.Conn, |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 ) (jr JSONResult, err error) { |
2153
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
97 |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
98 ctx := req.Context() |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
99 |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
100 name := mux.Vars(req)["name"] |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
101 |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
102 var tx *sql.Tx |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
103 if tx, err = conn.BeginTx(ctx, nil); err != nil { |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
104 return |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
105 } |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
106 defer tx.Rollback() |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
107 |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
108 var dummy bool |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
109 err = tx.QueryRowContext(ctx, hasPrintTemplateSQL, name).Scan(&dummy) |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
110 |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
111 switch { |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
112 case err == sql.ErrNoRows: |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
113 err = JSONError{ |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
114 Code: http.StatusNotFound, |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
115 Message: "No such template found", |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
116 } |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
117 return |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
118 case err != nil: |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
119 return |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
120 case !dummy: |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
121 err = JSONError{ |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
122 Code: http.StatusInternalServerError, |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
123 Message: "Unexpected return value from database query", |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
124 } |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
125 } |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
126 |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
127 if _, err = tx.ExecContext(ctx, deletePrintTemplateSQL, name); err != nil { |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
128 return |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
129 } |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
130 |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
131 if err = tx.Commit(); err != nil { |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
132 return |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
133 } |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
134 |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
135 jr = JSONResult{ |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
136 Result: map[string]string{ |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
137 "deleted": name, |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
138 }, |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
139 } |
cdd68f555ad7
Print templates: Implemented /api/templates/print/{name} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2150
diff
changeset
|
140 |
2148
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
141 return |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
142 } |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
143 |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
144 func updatePrintTemplate( |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
145 _ interface{}, |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
146 req *http.Request, |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
147 conn *sql.Conn, |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
148 ) (jr JSONResult, err error) { |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
149 // TODO: Implement me! |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
150 return |
4057a1f15174
Print templates: Forget to add controller file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
151 } |