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,25 +39,32 @@ func UploadHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
} else if user.Status == 1 {
|
} else if user.Status == 1 {
|
||||||
status = 3 // mark as trusted if user is trusted
|
status = 3 // mark as trusted if user is trusted
|
||||||
}
|
}
|
||||||
//add to db and redirect depending on result
|
var sameTorrents int
|
||||||
torrent := model.Torrent{
|
db.ORM.Model(&model.Torrent{}).Where("torrent_hash = ?", uploadForm.Infohash).Count(&sameTorrents)
|
||||||
Name: uploadForm.Name,
|
if (sameTorrents == 0) {
|
||||||
Category: uploadForm.CategoryID,
|
//add to db and redirect depending on result
|
||||||
SubCategory: uploadForm.SubCategoryID,
|
torrent := model.Torrent{
|
||||||
Status: status,
|
Name: uploadForm.Name,
|
||||||
Hash: uploadForm.Infohash,
|
Category: uploadForm.CategoryID,
|
||||||
Date: time.Now(),
|
SubCategory: uploadForm.SubCategoryID,
|
||||||
Filesize: uploadForm.Filesize,
|
Status: status,
|
||||||
Description: uploadForm.Description,
|
Hash: uploadForm.Infohash,
|
||||||
UploaderID: user.ID}
|
Date: time.Now(),
|
||||||
db.ORM.Create(&torrent)
|
Filesize: uploadForm.Filesize,
|
||||||
fmt.Printf("%+v\n", torrent)
|
Description: uploadForm.Description,
|
||||||
url, err := Router.Get("view_torrent").URL("id", strconv.FormatUint(uint64(torrent.ID), 10))
|
UploaderID: user.ID}
|
||||||
if err != nil {
|
db.ORM.Create(&torrent)
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
fmt.Printf("%+v\n", torrent)
|
||||||
|
url, err := Router.Get("view_torrent").URL("id", strconv.FormatUint(uint64(torrent.ID), 10))
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
http.Redirect(w, r, url.String(), 302)
|
||||||
|
} else {
|
||||||
|
http.Error(w, fmt.Errorf("Torrent already in database!").Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
http.Redirect(w, r, url.String(), 302)
|
|
||||||
} else if r.Method == "GET" {
|
} else if r.Method == "GET" {
|
||||||
uploadForm.CaptchaID = captcha.GetID()
|
uploadForm.CaptchaID = captcha.GetID()
|
||||||
htv := UploadTemplateVariables{uploadForm, NewSearchForm(), Navigation{}, GetUser(r), r.URL, mux.CurrentRoute(r)}
|
htv := UploadTemplateVariables{uploadForm, NewSearchForm(), Navigation{}, GetUser(r), r.URL, mux.CurrentRoute(r)}
|
||||||
|
|
|
@ -94,7 +94,7 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
{{.CreatedAt.Year}}/{{.CreatedAt.Month}}/{{.CreatedAt.Day}}
|
{{.Date.Year}}/{{.Date.Month}}/{{.Date.Day}}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
{{.Content}}
|
{{.Content}}
|
||||||
|
|
Référencer dans un nouveau ticket