révision
985c6f9e68
|
@ -132,7 +132,11 @@ func (t *Torrent) ToJSON() TorrentJSON {
|
||||||
commentsJSON = append(commentsJSON, CommentJSON{Username: c.Username, UserID: -1, Content: template.HTML(c.Content), Date: c.Date.UTC()})
|
commentsJSON = append(commentsJSON, CommentJSON{Username: c.Username, UserID: -1, Content: template.HTML(c.Content), Date: c.Date.UTC()})
|
||||||
}
|
}
|
||||||
for _, c := range t.Comments {
|
for _, c := range t.Comments {
|
||||||
|
if (c.User != nil) {
|
||||||
commentsJSON = append(commentsJSON, CommentJSON{Username: c.User.Username, UserID: int(c.User.ID), Content: util.MarkdownToHTML(c.Content), Date: c.CreatedAt.UTC()})
|
commentsJSON = append(commentsJSON, CommentJSON{Username: c.User.Username, UserID: int(c.User.ID), Content: util.MarkdownToHTML(c.Content), Date: c.CreatedAt.UTC()})
|
||||||
|
} else {
|
||||||
|
commentsJSON = append(commentsJSON, CommentJSON{})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fileListJSON := make([]FileJSON, 0, len(t.FileList))
|
fileListJSON := make([]FileJSON, 0, len(t.FileList))
|
||||||
for _, f := range t.FileList {
|
for _, f := range t.FileList {
|
||||||
|
|
|
@ -146,7 +146,7 @@ func getTorrentsOrderBy(parameters *serviceBase.WhereParams, orderBy string, lim
|
||||||
if limit != 0 || offset != 0 { // if limits provided
|
if limit != 0 || offset != 0 { // if limits provided
|
||||||
dbQuery = dbQuery + " LIMIT " + strconv.Itoa(limit) + " OFFSET " + strconv.Itoa(offset)
|
dbQuery = dbQuery + " LIMIT " + strconv.Itoa(limit) + " OFFSET " + strconv.Itoa(offset)
|
||||||
}
|
}
|
||||||
err = db.ORM.Raw(dbQuery, params...).Find(&torrents).Error
|
err = db.ORM.Preload("Comments").Raw(dbQuery, params...).Find(&torrents).Error
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
<a href="{{genRoute "view_torrent" "id" .ID }}">
|
<a href="{{genRoute "view_torrent" "id" .ID }}">
|
||||||
{{.Name}}
|
{{.Name}}
|
||||||
</a>
|
</a>
|
||||||
|
<span class="badge pull-right hidden-xs">{{ len .Comments }}</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="hidden-xs"><b class="text-success">{{.Seeders}}</b></td>
|
<td class="hidden-xs"><b class="text-success">{{.Seeders}}</b></td>
|
||||||
<td class="hidden-xs"><b class="text-danger">{{.Leechers}}</b></td>
|
<td class="hidden-xs"><b class="text-danger">{{.Leechers}}</b></td>
|
||||||
|
|
Référencer dans un nouveau ticket