...
Cette révision appartient à :
Parent
22d22b241a
révision
d2c2de2ef9
2 fichiers modifiés avec 7 ajouts et 4 suppressions
|
@ -1,5 +1,9 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// TODO Add field to specify kind of reports
|
||||
// TODO Add CreatedAt field
|
||||
// INFO User can be null (anonymous reports)
|
||||
|
@ -10,6 +14,8 @@ type TorrentReport struct {
|
|||
TorrentID uint `gorm:"column:torrent_id"`
|
||||
UserID uint `gorm:"column:user_id"`
|
||||
|
||||
CreatedAt time.Time `gorm:"column:created_at"`
|
||||
|
||||
Torrent *Torrent `gorm:"AssociationForeignKey:TorrentID;ForeignKey:torrent_id"`
|
||||
User *User `gorm:"AssociationForeignKey:UserID;ForeignKey:user_id"`
|
||||
}
|
||||
|
|
|
@ -82,14 +82,11 @@ func ReportTorrentHandler(w http.ResponseWriter, r *http.Request) {
|
|||
idNum, err := strconv.Atoi(id)
|
||||
userID := currentUser.ID
|
||||
|
||||
torrent, _ := torrentService.GetTorrentById(id)
|
||||
|
||||
report := model.TorrentReport{
|
||||
Description: r.FormValue("report_type"),
|
||||
TorrentID: uint(idNum),
|
||||
UserID: userID,
|
||||
Torrent: &torrent,
|
||||
User: currentUser,
|
||||
CreatedAt: time.Now(),
|
||||
}
|
||||
|
||||
err = db.ORM.Create(&report).Error
|
||||
|
|
Référencer dans un nouveau ticket