Merge branch 'dev' into tags
Cette révision appartient à :
révision
6ff033b0d9
3 fichiers modifiés avec 17 ajouts et 14 suppressions
|
@ -6,6 +6,7 @@ import (
|
|||
"strconv"
|
||||
|
||||
"github.com/NyaaPantsu/nyaa/controllers/router"
|
||||
"github.com/NyaaPantsu/nyaa/models"
|
||||
"github.com/NyaaPantsu/nyaa/models/torrents"
|
||||
"github.com/NyaaPantsu/nyaa/templates"
|
||||
"github.com/NyaaPantsu/nyaa/utils/captcha"
|
||||
|
@ -14,6 +15,7 @@ import (
|
|||
"github.com/NyaaPantsu/nyaa/utils/upload"
|
||||
"github.com/NyaaPantsu/nyaa/utils/validator/torrent"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/NyaaPantsu/nyaa/utils/log"
|
||||
)
|
||||
|
||||
// UploadHandler : Main Controller for uploading a torrent
|
||||
|
@ -51,6 +53,13 @@ func UploadPostHandler(c *gin.Context) {
|
|||
messages.AddError("errors", err.Error())
|
||||
}
|
||||
|
||||
uploadForm.Status = models.TorrentStatusNormal
|
||||
if uploadForm.Remake { // overrides trusted
|
||||
uploadForm.Status = models.TorrentStatusRemake
|
||||
} else if user.IsTrusted() {
|
||||
uploadForm.Status = models.TorrentStatusTrusted
|
||||
}
|
||||
|
||||
err = torrents.ExistOrDelete(uploadForm.Infohash, user)
|
||||
if err != nil {
|
||||
messages.AddError("errors", err.Error())
|
||||
|
@ -58,8 +67,8 @@ func UploadPostHandler(c *gin.Context) {
|
|||
|
||||
if !messages.HasErrors() {
|
||||
// add to db and redirect
|
||||
torrent, _ := torrents.Create(user, &uploadForm)
|
||||
|
||||
torrent, err := torrents.Create(user, &uploadForm)
|
||||
log.CheckErrorWithMessage(err, "ERROR_TORRENT_CREATED: Error while creating entry in db")
|
||||
url := "/view/" + strconv.FormatUint(uint64(torrent.ID), 10)
|
||||
c.Redirect(302, url+"?success")
|
||||
}
|
||||
|
|
|
@ -25,7 +25,11 @@ func Create(user *models.User, uploadForm *torrentValidator.TorrentRequest) (*mo
|
|||
UploaderID: user.ID}
|
||||
torrent.EncodeLanguages() // Convert languages array in language string
|
||||
torrent.ParseTrackers(uploadForm.Trackers)
|
||||
models.ORM.Create(&torrent)
|
||||
err := models.ORM.Create(&torrent).Error
|
||||
log.Infof("Torrent ID %d created!\n", torrent.ID)
|
||||
if err != nil {
|
||||
log.CheckErrorWithMessage(err, "ERROR_TORRENT_CREATE: Cannot create a torrent")
|
||||
}
|
||||
if config.Get().Search.EnableElasticSearch && models.ElasticSearchClient != nil {
|
||||
err := torrent.AddToESIndex(models.ElasticSearchClient)
|
||||
if err == nil {
|
||||
|
@ -39,7 +43,7 @@ func Create(user *models.User, uploadForm *torrentValidator.TorrentRequest) (*mo
|
|||
NewTorrentEvent(user, &torrent)
|
||||
if len(uploadForm.FileList) > 0 {
|
||||
for _, uploadedFile := range uploadForm.FileList {
|
||||
file := models.File{TorrentID: torrent.ID, Filesize: uploadForm.Filesize}
|
||||
file := models.File{TorrentID: torrent.ID, Filesize: uploadedFile.Filesize}
|
||||
err := file.SetPath(uploadedFile.Path)
|
||||
if err != nil {
|
||||
return &torrent, err
|
||||
|
|
|
@ -125,16 +125,6 @@ function startupCode() {
|
|||
|
||||
if (document.cookie.includes("newVersion"))
|
||||
document.getElementById("commit").className = "new";
|
||||
|
||||
document.getElementsByClassName("search-box")[0].addEventListener("focus", function (e) {
|
||||
var w = document.getElementsByClassName("h-user")[0].offsetWidth
|
||||
document.getElementsByClassName("h-user")[0].style.display = "none"
|
||||
document.getElementsByClassName("search-box")[0].style.width = document.getElementsByClassName("search-box")[0].offsetWidth + w + "px"
|
||||
})
|
||||
document.getElementsByClassName("search-box")[0].addEventListener("blur", function (e) {
|
||||
document.getElementsByClassName("search-box")[0].style.width = ""
|
||||
document.getElementsByClassName("h-user")[0].style.display = "inline-block"
|
||||
})
|
||||
}
|
||||
|
||||
function playVoice() {
|
||||
|
|
Référencer dans un nouveau ticket