-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.go
57 lines (46 loc) · 1.18 KB
/
model.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package jobs
import (
"html/template"
"cloud.google.com/go/datastore"
"github.com/dmcalpin/go-cms/db"
"github.com/dmcalpin/go-cms/services/shared/templates"
)
const JobKind = "Job"
var multiTemplate, oneTemplate *template.Template
func init() {
multiTemplate = templates.GetTemplateWithLayout("services/jobs/templates/jobs_list.gohtml")
oneTemplate = templates.GetTemplateWithLayout("services/jobs/templates/jobs_details.gohtml")
}
type Job struct {
db.DatastoreModel
Title string `datastore:"title" json:"title"`
Description string `datastore:"description" json:"description"`
}
func (j *Job) New(key *datastore.Key) db.Patchable {
job := &Job{}
job.Kind = JobKind
job.Key = key
return job
}
func (u *Job) Patch(i interface{}) {
input := i.(*Job)
if input.Title != "" {
u.Title = input.Title
}
if input.Description != "" {
u.Description = input.Description
}
}
// Template config
func (u *Job) CreateTemplate() *template.Template {
return nil
}
func (u *Job) UpdateTemplate() *template.Template {
return nil
}
func (u *Job) GetMultiTemplate() *template.Template {
return multiTemplate
}
func (u *Job) GetOneTemplate() *template.Template {
return oneTemplate
}