Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

make user torrent list display

Cette révision appartient à :
Andrew Zhao 2017-05-08 22:21:14 -07:00
Parent d0069b6249
révision 1c44a24ab0
3 fichiers modifiés avec 5 ajouts et 4 suppressions

Voir le fichier

@ -27,7 +27,7 @@ type User struct {
Md5 string `json:"md5"` Md5 string `json:"md5"`
TokenExpiration time.Time `gorm:"column:api_token_expiry"` TokenExpiration time.Time `gorm:"column:api_token_expiry"`
Language string `gorm:"column:language"` Language string `gorm:"column:language"`
Torrents []Torrents `gorm:"ForeignKey:owner_id"` Torrents []Torrents `gorm:"ForeignKey:UploaderId"`
} }
type PublicUser struct { type PublicUser struct {
@ -38,4 +38,4 @@ type PublicUser struct {
type UsersFollowers struct { type UsersFollowers struct {
UserID uint `gorm:"column:userId"` UserID uint `gorm:"column:userId"`
FollowerID uint `gorm:"column:follower_id"` FollowerID uint `gorm:"column:follower_id"`
} }

Voir le fichier

@ -243,10 +243,9 @@ func RetrieveUserByUsername(username string) (*model.PublicUser, string, int, er
// RetrieveUserForAdmin retrieves a user for an administrator. // RetrieveUserForAdmin retrieves a user for an administrator.
func RetrieveUserForAdmin(id string) (model.User, int, error) { func RetrieveUserForAdmin(id string) (model.User, int, error) {
var user model.User var user model.User
if db.ORM.First(&user, id).RecordNotFound() { if db.ORM.Preload("Torrents").First(&user, id).RecordNotFound() {
return user, http.StatusNotFound, errors.New("User is not found.") return user, http.StatusNotFound, errors.New("User is not found.")
} }
db.ORM.Model(&user).Related("Torrents").Find(&model.Torrents{})
return user, http.StatusOK, nil return user, http.StatusOK, nil
} }

Voir le fichier

@ -11,6 +11,7 @@
<th>{{T "links"}}</th> <th>{{T "links"}}</th>
</tr> </tr>
{{ range .Torrents }} {{ range .Torrents }}
{{ with .ToJson }}
<tr class="torrent-info <tr class="torrent-info
{{if eq .Status 2}}remake{{end}} {{if eq .Status 2}}remake{{end}}
{{if eq .Status 3}}trusted{{end}} {{if eq .Status 3}}trusted{{end}}
@ -38,6 +39,7 @@
</td> </td>
</tr> </tr>
{{end}} {{end}}
{{end}}
</table> </table>
<nav class="torrentNav" aria-label="Page navigation"> <nav class="torrentNav" aria-label="Page navigation">
<ul class="pagination"> <ul class="pagination">