Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Username search for admin comment list, inputs for userid & username search in said comment list (#1713)

* Update comments.go

* Update commentlist.jet.html

* Update comments.go

When you search a username and you have a userid in the url, the conditions string doesn't have "AND" in it. I made the username search a priority and if there is not username provided, it falls back to userid in url.
Cette révision appartient à :
kilo 2017-11-06 09:17:14 +01:00 révisé par GitHub
Parent 98af64a4e2
révision ca271e2ac6
Aucune clé n'a été trouvée pour cette signature dans la base de données
ID de la clé GPG: 4AEE18F83AFDEB23
2 fichiers modifiés avec 33 ajouts et 5 suppressions

Voir le fichier

@ -21,6 +21,7 @@ func CommentsListPanel(c *gin.Context) {
pagenum := 1
offset := 100
userid := c.Query("userid")
username := c.Query("user")
var err error
messages := msg.GetMessages(c)
deleted := c.Request.URL.Query()["deleted"]
@ -36,14 +37,26 @@ func CommentsListPanel(c *gin.Context) {
}
var conditions string
var values []interface{}
if userid != "" {
conditions = "user_id = ?"
values = append(values, userid)
searchForm := templates.NewSearchForm(c)
// if there is a username in url
if username != "" {
conditions = "user = ?"
values = append(values, username)
searchForm.UserName = username
// else we look if there is a userid
} else if userid != "" {
id, err := strconv.Atoi(userid)
if err == nil {
conditions = "user_id = ?"
values = append(values, id)
searchForm.UserID = uint32(id)
}
}
comments, nbComments := comments.FindAll(offset, (pagenum-1)*offset, conditions, values...)
nav := templates.Navigation{nbComments, offset, pagenum, "mod/comments/p"}
templates.ModelList(c, "admin/commentlist.jet.html", comments, nav, templates.NewSearchForm(c))
templates.ModelList(c, "admin/commentlist.jet.html", comments, nav, searchForm)
}
// CommentDeleteModPanel : Controller for deleting a comment

Voir le fichier

@ -2,7 +2,22 @@
{{block title()}}{{ T("comments_list") }}{{end}}
{{block content_body()}}
<div class="results box">
<h1>{{ T("comments_list") }}</h1>
<h1 style="margin-bottom: 0;">{{ T("comments_list") }}</h1>
<form action="/mod/comments">
<table style="margin-left: 5px; max-width: 30%; min-width: 100px;text-align:left;">
<tbody>
<tr>
<td>{{T("user_id")}}</td><td><input type="text" name="userid" class="form-input" placeholder="{{T("user_id")}}" value="{{if Search.UserID > 0}}{{Search.UserID}}{{end}}"><td/>
</tr>
<tr>
<td>{{T("username")}}</td><td><input type="text" name="username" class="form-input" placeholder="{{T("username")}}" value="{{Search.UserName}}"><td/>
</tr>
</tbody>
</table>
<button style="display: none;"></button>
</form>
<table class="table">
<thead class="torrent-info">
<tr>