update
parent
8f207bf356
commit
0d58e402f8
|
@ -19,7 +19,6 @@ type Calendar struct {
|
|||
|
||||
Name string `gorm:"index:idx_cal,unique"`
|
||||
Description string
|
||||
ExtLink string
|
||||
|
||||
Timezone string
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package calendar
|
|||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
"kumoly.io/kumoly/app/auth"
|
||||
"kumoly.io/kumoly/app/errors"
|
||||
)
|
||||
|
@ -33,3 +34,18 @@ func HasEventAccess(c *gin.Context, e *Event, cid string) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ChangeCalGroup(cal_id, to string) error {
|
||||
return db.Transaction(func(tx *gorm.DB) error {
|
||||
affected := tx.Exec(`update events set group_id = (
|
||||
select id from groups where name = ?
|
||||
) where calendar_id = ?`, to, cal_id).RowsAffected
|
||||
if affected == 0 {
|
||||
return errors.ErrorNotFound
|
||||
}
|
||||
tx.Exec(`update events set group_id = (
|
||||
select id from groups where name = ?
|
||||
) where calendar_id = ?`, to, cal_id)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue