Merge branch 'master' of github.com:ewhal/nyaa into api
Cette révision appartient à :
révision
7e3d116808
2 fichiers modifiés avec 25 ajouts et 18 suppressions
|
@ -39,6 +39,9 @@ func UploadHandler(w http.ResponseWriter, r *http.Request) {
|
|||
} else if user.Status == 1 {
|
||||
status = 3 // mark as trusted if user is trusted
|
||||
}
|
||||
var sameTorrents int
|
||||
db.ORM.Model(&model.Torrent{}).Where("torrent_hash = ?", uploadForm.Infohash).Count(&sameTorrents)
|
||||
if (sameTorrents == 0) {
|
||||
//add to db and redirect depending on result
|
||||
torrent := model.Torrent{
|
||||
Name: uploadForm.Name,
|
||||
|
@ -58,6 +61,10 @@ func UploadHandler(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
http.Redirect(w, r, url.String(), 302)
|
||||
} else {
|
||||
http.Error(w, fmt.Errorf("Torrent already in database!").Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
} else if r.Method == "GET" {
|
||||
uploadForm.CaptchaID = captcha.GetID()
|
||||
htv := UploadTemplateVariables{uploadForm, NewSearchForm(), Navigation{}, GetUser(r), r.URL, mux.CurrentRoute(r)}
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
{{end}}
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
{{.CreatedAt.Year}}/{{.CreatedAt.Month}}/{{.CreatedAt.Day}}
|
||||
{{.Date.Year}}/{{.Date.Month}}/{{.Date.Day}}
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
{{.Content}}
|
||||
|
|
Référencer dans un nouveau ticket