Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Preload User on find. Should fix the edit not showing up for anonymous.

Fix issue with hidden checkbox and remake one on chrome.
Refactor flag list on edit/upload form. Now a helper function in flags helper.
Cette révision appartient à :
akuma06 2017-07-14 17:53:37 +02:00
Parent 65a2cc2d1c
révision 6bbb2e9801
7 fichiers modifiés avec 25 ajouts et 24 suppressions

Voir le fichier

@ -17,6 +17,7 @@ import (
"net/url"
"github.com/NyaaPantsu/nyaa/config"
"github.com/NyaaPantsu/nyaa/utils/cache"
"github.com/NyaaPantsu/nyaa/utils/format"
"github.com/NyaaPantsu/nyaa/utils/log"
"github.com/NyaaPantsu/nyaa/utils/sanitize"
@ -362,6 +363,7 @@ func TorrentsToJSON(t []Torrent) []TorrentJSON {
// Update : Update a torrent based on model
func (t *Torrent) Update(unscope bool) (int, error) {
cache.C.Delete(t.Identifier())
db := ORM
if unscope {
db = ORM.Unscoped()
@ -391,6 +393,7 @@ func (t *Torrent) UpdateUnscope() (int, error) {
// DeleteTorrent : delete a torrent based on id
func (t *Torrent) Delete(definitely bool) (*Torrent, int, error) {
cache.C.Delete(t.Identifier())
db := ORM
if definitely {
db = ORM.Unscoped()

Voir le fichier

@ -29,7 +29,7 @@ func FindByID(id uint) (*models.Torrent, error) {
}
tmp := models.ORM.Where("torrent_id = ?", id).Preload("Scrape").Preload("Comments")
tmp := models.ORM.Where("torrent_id = ?", id).Preload("Scrape").Preload("Uploader").Preload("Comments")
if id > config.Get().Models.LastOldTorrentID {
tmp = tmp.Preload("FileList")
}

Voir le fichier

@ -1,4 +1,5 @@
{{ extends "layouts/index_admin" }}
{{ import "layouts/partials/helpers/flags" }}
{{block title()}}{{ T("torrent_edit_panel") }}{{end}}
{{ block content_body()}}
<div class="results box">
@ -20,12 +21,7 @@
<div class="form-group">
<label for="language">{{ T("torrent_language") }}</label>
<div name="language" class="form-input language">
{{ range _, language := GetTorrentLanguages() }}
<span class="input-group">
<input type="checkbox" name="languages" id="lang-{{ language.Code }}" value="{{language.Code}}"{{if contains(Form.Languages, language.Code) }} checked{{end}}>
<label for="lang-{{ language.Code }}" class="flag flag-{{ language.Flag(false) }}" title="{{LanguageName(language, T)}}"></label>
</span>
{{ end }}
{{ yield flagList(languages=GetTorrentLanguages(), selected=Form.Languages) }}
</div>
</div>
<div class="form-group">
@ -39,7 +35,7 @@
</select>
</div>
<p>
<input type="checkbox" name="hidden" id="hidden" {{ if Form.Hidden }}checked{{end}}>
<input type="checkbox" value="true" name="hidden" id="hidden" {{ if Form.Hidden }}checked{{end}}>
<label for="hidden">{{ T("upload_as_anon")}}</label>
</p>
<div class="form-group">

Voir le fichier

@ -0,0 +1,8 @@
{{ block flagList(languages=nil, selected="")}}
{{ range _, language := languages }}
<span class="input-group">
<input type="checkbox" name="languages" id="lang-{{ language.Code }}" value="{{language.Code}}"{{if contains(selected, language.Code) }} checked{{end}}>
<label for="lang-{{ language.Code }}" class="flag flag-{{ language.Flag(false) }}" title="{{LanguageName(language, T)}}"></label>
</span>
{{ end }}
{{ end }}

Voir le fichier

@ -1,6 +1,7 @@
{{ extends "layouts/index_site" }}
{{ import "layouts/partials/helpers/csrf" }}
{{ import "layouts/partials/helpers/errors" }}
{{ import "layouts/partials/helpers/flags" }}
{{block title()}}{{T("torrent_edit_panel")}}{{end}}
{{block content_body()}}
<div class="box results">
@ -25,23 +26,18 @@
<div class="form-group">
<label class="input-label" for="language">{{ T("torrent_language") }}</label>
<div name="language" class="form-input language">
{{ range _, language := GetTorrentLanguages() }}
<span class="input-group">
<input type="checkbox" name="languages" id="lang-{{ language.Code }}" value="{{language.Code}}"{{if contains(Form.Languages, language.Code) }} checked{{end}}>
- <label for="lang-{{ language.Code }}" class="flag flag-{{ language.Flag(false) }}" title="{{LanguageName(language, T)}}"></label>
</span>
{{ end }}
{{ yield flagList(languages=GetTorrentLanguages(), selected=Form.Languages) }}
</div>
{{ yield errors(name="language")}}
</div>
<div class="form-group">
<input type="checkbox" name="remake" id="remake" {{ if Form.Remake }}checked{{end}}>
<input type="checkbox" value="true" name="remake" id="remake" {{ if Form.Remake }}checked{{end}}>
<label for="remake">{{ T("mark_as_remake")}}</label>
{{ yield errors(name="remake")}}
</div>
{{ if User.ID > 0 }}
<p>
<input type="checkbox" name="hidden" id="hidden" {{ if Form.Hidden }}checked{{end}}>
<input type="checkbox" name="hidden" id="hidden" value="true" {{ if Form.Hidden }}checked{{end}}>
<label for="hidden">{{ T("upload_as_anon")}}</label>
{{ yield errors(name="hidden")}}
</p>

Voir le fichier

@ -1,6 +1,7 @@
{{ extends "layouts/index_site" }}
{{ import "layouts/partials/helpers/csrf" }}
{{ import "layouts/partials/helpers/captcha" }}
{{ import "layouts/partials/helpers/flags" }}
{{block title()}}{{ T("upload")}}{{end}}
{{block content_body()}}
<div style="text-align: left;" class="box">
@ -31,25 +32,20 @@
<h3>{{ T("torrent_language") }}</h3>
<div name="language" class="form-input language">
{{ range _, language := GetTorrentLanguages() }}
<span class="input-group">
<input type="checkbox" name="languages" id="lang-{{ language.Code }}" value="{{language.Code}}">
<label for="lang-{{ language.Code }}" class="flag flag-{{ language.Flag(false) }}" title="{{LanguageName(language, T)}}"></label>
</span>
{{ end }}
{{ yield flagList(languages=GetTorrentLanguages(), selected=Form.Languages) }}
</div>
<p class="not-important">{{ T("language_not_mandatory") }}</p>
{{ yield errors(name="language")}}
<p>
<input type="checkbox" name="remake" id="remake" >
<input type="checkbox" value="true" name="remake" id="remake" >
<label for="remake">{{ T("mark_as_remake")}}</label>
</p>
{{ yield errors(name="remake")}}
{{ if User.ID > 0 }}
<p>
<input type="checkbox" name="hidden" id="hidden" >
<input type="checkbox" value="true" name="hidden" id="hidden" >
<label for="hidden">{{ T("upload_as_anon")}}</label>
</p>
{{ yield errors(name="hidden")}}

Voir le fichier

@ -177,6 +177,8 @@ func UpdateTorrent(r *torrentValidator.UpdateRequest, t *models.Torrent, current
}
t.Status = status
t.Hidden = r.Update.Hidden
return t
}