Esempio n. 1
0
func updateAttributesFromForm(res *wcg.Response, req *wcg.Request, e *event.Event) error {
	var err error
	if err = eventFormValidator.Eval(req.HttpRequest().PostForm); err != nil {
		return err
	}
	e.Title = req.Form("title")
	e.Link = req.Form("link")
	e.ImageLink = req.Form("image_link")
	e.YAKeyword = req.Form("ya_keyword")
	e.EventType = event.ParseEventType(req.Form("event_type"))
	return nil
}
Esempio n. 2
0
func (d *EventDriver) Save(t *event.Event) (*event.Event, error) {
	_now := now()
	if t.Id == "" {
		uid, _ := wcg.UUID()
		t.Id = uid
		t.CreatedAt = _now
		t.UpdatedAt = _now
	} else {
		t.UpdatedAt = _now
	}
	key := d.NewKey(t.Id, 0, nil)
	_, err := d.Put(key, t)
	return t, err
}