Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

status search and typo fixes

Cette révision appartient à :
ayame-git 2017-05-04 15:01:07 +03:00
Parent 764455d7e2
révision 76b8fe9ccb
3 fichiers modifiés avec 15 ajouts et 6 suppressions

Voir le fichier

@ -60,6 +60,12 @@
<option value="5_10" {{if eq .Category "5_10"}}selected{{end}}>Live Action - Idol/Promotional Video</option>
<option value="5_11" {{if eq .Category "5_11"}}selected{{end}}>Live Action - Raw</option>
</select>
<select name="s" class="form-control">
<option value="">Search all</option>
<option value="2" {{if eq .Status "2"}}selected{{end}}>Remakes</option>
<option value="3" {{if eq .Status "3"}}selected{{end}}>Trusted</option>
<option value="4" {{if eq .Status "4"}}selected{{end}}>A+</option>
</select>
<input name="q" class="form-control" placeholder="Search" type="text">
<select name="max" class="form-control" value>
<option value="">No Items per Page</option>

Voir le fichier

@ -96,6 +96,7 @@ func searchHandler(w http.ResponseWriter, r *http.Request) {
pagenum, _ := strconv.Atoi(html.EscapeString(page))
searchQuery := r.URL.Query().Get("q")
cat := r.URL.Query().Get("c")
stat := r.URL.Query().Get("s")
catsSplit := strings.Split(cat, "_")
// need this to prevent out of index panics
var searchCatId, searchSubCatId string
@ -109,7 +110,8 @@ func searchHandler(w http.ResponseWriter, r *http.Request) {
b := []TorrentsJson{}
torrents := getTorrents(createWhereParams("torrent_name LIKE ? AND category_id LIKE ? AND sub_category_id LIKE ?", "%"+searchQuery+"%", searchCatId+"%", searchSubCatId+"%"), maxPerPage, maxPerPage*(pagenum-1))
torrents := getTorrents(createWhereParams("torrent_name LIKE ? AND status_id LIKE ? AND category_id LIKE ? AND sub_category_id LIKE ?",
"%"+searchQuery+"%", stat+"%", searchCatId+"%", searchSubCatId+"%"), maxPerPage, maxPerPage*(pagenum-1))
for i, _ := range torrents {
nbTorrents++
@ -119,7 +121,7 @@ func searchHandler(w http.ResponseWriter, r *http.Request) {
}
htv := HomeTemplateVariables{b, getAllCategories(false), searchQuery, cat, maxPerPage, nbTorrents}
htv := HomeTemplateVariables{b, getAllCategories(false), searchQuery, stat, cat, maxPerPage, nbTorrents}
err := templates.ExecuteTemplate(w, "index.html", htv)
if err != nil {

Voir le fichier

@ -25,10 +25,10 @@ type Sub_Categories struct {
type Torrents struct {
gorm.Model
Id int `gorm:"column:torrent_id"`
Name string `gorm:"column:torrent_name"`
Category_id int `gorm:"column:category_id"`
Sub_category_id int
Id int `gorm:"column:torrent_id"`
Name string `gorm:"column:torrent_name"`
Category_id int `gorm:"column:category_id"`
Sub_category_id int `gorm:"column:sub_category_id"`
Status int `gorm:"column:status_id"`
Hash string `gorm:"column:torrent_hash"`
Categories Categories `gorm:"ForeignKey:category_id;AssociationForeignKey:category_id"`
@ -67,6 +67,7 @@ type HomeTemplateVariables struct {
ListTorrents []TorrentsJson
ListCategories []Categories
Query string
Status string
Category string
QueryRecordCount int
TotalRecordCount int