Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Fixing torrent edit for user&admin

Cette révision appartient à :
akuma06 2017-07-04 02:40:54 +02:00
Parent 330ab06597
révision d4c245e256
4 fichiers modifiés avec 7 ajouts et 6 suppressions

Voir le fichier

@ -182,7 +182,7 @@ func ReportViewTorrentHandler(c *gin.Context) {
// TorrentEditUserPanel : Controller for editing a user torrent by a user, after GET request
func TorrentEditUserPanel(c *gin.Context) {
id, _ := strconv.ParseInt(c.Param("id"), 10, 32)
id, _ := strconv.ParseInt(c.Query("id"), 10, 32)
torrent, _ := torrents.FindByID(uint(id))
currentUser := getUser(c)
if currentUser.CurrentOrAdmin(torrent.UploaderID) {
@ -203,7 +203,7 @@ func TorrentEditUserPanel(c *gin.Context) {
// TorrentPostEditUserPanel : Controller for editing a user torrent by a user, after post request
func TorrentPostEditUserPanel(c *gin.Context) {
var uploadForm torrentValidator.UpdateRequest
id, _ := strconv.ParseInt(c.Param("id"), 10, 32)
id, _ := strconv.ParseInt(c.Query("id"), 10, 32)
uploadForm.ID = uint(id)
messages := msg.GetMessages(c)
torrent, _ := torrents.FindByID(uint(id))
@ -217,7 +217,7 @@ func TorrentPostEditUserPanel(c *gin.Context) {
upload.UpdateTorrent(&uploadForm, &torrent, currentUser).Update(currentUser.HasAdmin())
messages.AddInfoT("infos", "torrent_updated")
}
formTemplate(c, "site/torrents/edit.jet.html", uploadForm)
formTemplate(c, "site/torrents/edit.jet.html", uploadForm.Update)
} else {
NotFoundHandler(c)
}
@ -225,7 +225,7 @@ func TorrentPostEditUserPanel(c *gin.Context) {
// TorrentDeleteUserPanel : Controller for deleting a user torrent by a user
func TorrentDeleteUserPanel(c *gin.Context) {
id, _ := strconv.ParseInt(c.Param("id"), 10, 32)
id, _ := strconv.ParseInt(c.Query("id"), 10, 32)
currentUser := getUser(c)
torrent, _ := torrents.FindByID(uint(id))
if currentUser.CurrentOrAdmin(torrent.UploaderID) {

Voir le fichier

@ -24,7 +24,7 @@
<label for="language">{{ T("torrent_language") }}</label>
<div name="language" class="form-input language">
{{ range _, language := GetTorrentLanguages() }}
<input type="checkbox" name="languages" id="lang-{{ language }}" value="{{language}}"{{if contains(.Languages, language) }} checked{{end}}>
<input type="checkbox" name="languages" id="lang-{{ language }}" value="{{language}}"{{if contains(Form.Languages, language) }} checked{{end}}>
<label for="lang-{{ language }}" class="flag flag-{{ FlagCode(language) }}" title="{{LanguageName(language, T)}}"></label>
{{ end }}
</div>

Voir le fichier

@ -29,7 +29,7 @@
<label class="input-label" for="language">{{ T("torrent_language") }}</label>
<div name="language" class="form-input language">
{{ range _, language := GetTorrentLanguages() }}
<input type="checkbox" name="languages" id="lang-{{ language }}" value="{{language}}"{{if contains(.Languages, language) }} checked{{end}}>
<input type="checkbox" name="languages" id="lang-{{ language }}" value="{{language}}"{{if contains(Form.Languages, language) }} checked{{end}}>
<label for="lang-{{ language }}" class="flag flag-{{ FlagCode(language) }}" title="{{LanguageName(language, T)}}"></label>
{{ end }}
</div>

Voir le fichier

@ -169,6 +169,7 @@ func UpdateTorrent(r *torrentValidator.UpdateRequest, t *models.Torrent, current
if r.Update.WebsiteLink != "" {
t.WebsiteLink = r.Update.WebsiteLink
}
t.Languages = r.Update.Languages
status := models.TorrentStatusNormal
if r.Update.Remake { // overrides trusted
status = models.TorrentStatusRemake