Пример #1
0
func jobToTpldata(job model.Job, user model.User) *jobTpldata {
	excerpt := string(job.Content())
	if len(excerpt) > 100 {
		excerpt = string([]rune(excerpt)[0:100]) + " (...)"
	}

	return &jobTpldata{
		ID:      job.ID().String(),
		Subject: job.Subject(),
		Excerpt: excerpt,
		Next:    job.Next().In(user.Location()).Format("2006-Jan-02 15:04:05"),
	}
}
Пример #2
0
func (jt *jobeditTpldata) fillFromJob(job model.Job, u model.User) {
	jt.JobID = job.ID().String()
	jt.Subject = job.Subject()
	jt.Content = string(job.Content())
	jt.Schedules = make([]scheduleTpldata, maxSchedules)

	for i, sched := range job.Schedule() {
		if i == maxSchedules {
			log.Printf("Job %s has more than %d schedule entries!", job.ID(), maxSchedules)
			break
		}

		jt.Schedules[i] = schedToSchedTL(sched, u)
	}
}