update
parent
03cc592768
commit
72a783bdd3
|
@ -37,6 +37,16 @@ func (e *Event) BeforeSave(tx *gorm.DB) (err error) {
|
||||||
tx.Raw("select name from calendars where id = ?", e.CalendarID).Scan(&loc)
|
tx.Raw("select name from calendars where id = ?", e.CalendarID).Scan(&loc)
|
||||||
e.Location = loc
|
e.Location = loc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test for collide
|
||||||
|
cnt := 0
|
||||||
|
db.Raw(`select count(*) from events e where
|
||||||
|
(? >= "start" and ? <= "end" )
|
||||||
|
or
|
||||||
|
(? >= "start" and ? <= "end" )
|
||||||
|
and calendar_id = ?`,
|
||||||
|
e.End, e.End, e.Start, e.Start, e.CalendarID).Scan(&cnt)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue