Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Cette révision appartient à :
ayame-git 2017-05-11 01:10:42 +03:00
Parent 22d22b241a
révision d2c2de2ef9
2 fichiers modifiés avec 7 ajouts et 4 suppressions

Voir le fichier

@ -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"`
}

Voir le fichier

@ -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