...
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
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
// TODO Add field to specify kind of reports
|
// TODO Add field to specify kind of reports
|
||||||
// TODO Add CreatedAt field
|
// TODO Add CreatedAt field
|
||||||
// INFO User can be null (anonymous reports)
|
// INFO User can be null (anonymous reports)
|
||||||
|
@ -10,6 +14,8 @@ type TorrentReport struct {
|
||||||
TorrentID uint `gorm:"column:torrent_id"`
|
TorrentID uint `gorm:"column:torrent_id"`
|
||||||
UserID uint `gorm:"column:user_id"`
|
UserID uint `gorm:"column:user_id"`
|
||||||
|
|
||||||
|
CreatedAt time.Time `gorm:"column:created_at"`
|
||||||
|
|
||||||
Torrent *Torrent `gorm:"AssociationForeignKey:TorrentID;ForeignKey:torrent_id"`
|
Torrent *Torrent `gorm:"AssociationForeignKey:TorrentID;ForeignKey:torrent_id"`
|
||||||
User *User `gorm:"AssociationForeignKey:UserID;ForeignKey:user_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)
|
idNum, err := strconv.Atoi(id)
|
||||||
userID := currentUser.ID
|
userID := currentUser.ID
|
||||||
|
|
||||||
torrent, _ := torrentService.GetTorrentById(id)
|
|
||||||
|
|
||||||
report := model.TorrentReport{
|
report := model.TorrentReport{
|
||||||
Description: r.FormValue("report_type"),
|
Description: r.FormValue("report_type"),
|
||||||
TorrentID: uint(idNum),
|
TorrentID: uint(idNum),
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
Torrent: &torrent,
|
CreatedAt: time.Now(),
|
||||||
User: currentUser,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = db.ORM.Create(&report).Error
|
err = db.ORM.Create(&report).Error
|
||||||
|
|
Référencer dans un nouveau ticket