Add back limit of torrents in profile to 20 and also fix issue with number of torrent uploaded maxed to 50
Cette révision appartient à :
Parent
73390e1d30
révision
9fdb749e61
4 fichiers modifiés avec 9 ajouts et 7 suppressions
|
@ -51,20 +51,21 @@ func UserProfileHandler(c *gin.Context) {
|
|||
userProfile.ParseSettings()
|
||||
query := c.Request.URL.Query()
|
||||
query.Set("userID", strconv.Itoa(int(id)))
|
||||
query.Set("max", "16")
|
||||
query.Set("limit", "20")
|
||||
c.Request.URL.RawQuery = query.Encode()
|
||||
var torrents []models.Torrent
|
||||
var err error
|
||||
nbTorrents := 0
|
||||
if currentUser.CurrentOrAdmin(userProfile.ID) {
|
||||
_, torrents, _, err = search.ByQuery(c, 1)
|
||||
_, torrents, nbTorrents, err = search.ByQuery(c, 1)
|
||||
} else {
|
||||
_, torrents, _, err = search.ByQueryNoHidden(c, 1)
|
||||
_, torrents, nbTorrents, err = search.ByQueryNoHidden(c, 1)
|
||||
}
|
||||
if err != nil {
|
||||
messages.AddErrorT("errors", "retrieve_torrents_error")
|
||||
}
|
||||
userProfile.Torrents = torrents
|
||||
templates.UserProfile(c, userProfile)
|
||||
templates.UserProfile(c, userProfile, nbTorrents)
|
||||
}
|
||||
} else {
|
||||
c.Status(http.StatusNotFound)
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<p class="profile-usertitle-job">
|
||||
{{UserProfile.GetRole()}}
|
||||
</p>
|
||||
<p class="profile-usertitle-uploadcount">{{ T("torrents_uploaded") }}:<span>{{ len(UserProfile.Torrents) }}</span></p>
|
||||
<p class="profile-usertitle-uploadcount">{{ T("torrents_uploaded") }}:<span>{{ NbTorrents }}</span></p>
|
||||
</div>
|
||||
<!-- END SIDEBAR USER TITLE -->
|
||||
<!-- SIDEBAR BUTTONS -->
|
||||
|
|
|
@ -164,9 +164,10 @@ func UserProfileEdit(c *gin.Context, userProfile *models.User, userForm userVali
|
|||
}
|
||||
|
||||
// UserProfile render a user profile
|
||||
func UserProfile(c *gin.Context, userProfile *models.User) {
|
||||
func UserProfile(c *gin.Context, userProfile *models.User, nbTorrents int) {
|
||||
variables := Commonvariables(c)
|
||||
variables.Set("UserProfile", userProfile)
|
||||
variables.Set("NbTorrents", nbTorrents)
|
||||
Render(c, path.Join(SiteDir, "user/torrents.jet.html"), variables)
|
||||
}
|
||||
|
||||
|
|
|
@ -205,13 +205,13 @@ func mockupCommonvariables(t *testing.T) jet.VarMap {
|
|||
variables.Set("Mascot", "test")
|
||||
variables.Set("MascotURL", "test")
|
||||
variables.Set("User", &models.User{})
|
||||
variables.Set("UserProfile", &models.User{})
|
||||
variables.Set("URL", &url.URL{})
|
||||
variables.Set("CsrfToken", "xxxxxx")
|
||||
variables.Set("Config", config.Get())
|
||||
variables.Set("Infos", make(map[string][]string))
|
||||
variables.Set("Errors", make(map[string][]string))
|
||||
variables.Set("UserProfile", &models.User{})
|
||||
variables.Set("NbTorrents", 0)
|
||||
variables = templateFunctions(variables)
|
||||
return variables
|
||||
}
|
||||
|
|
Référencer dans un nouveau ticket