From d98d91830101193d55bc8892b18ee2255e7289a3 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Wed, 10 May 2017 22:03:14 +0200 Subject: [PATCH] Allow marking uploads as remake --- router/upload.go | 13 ++++--------- router/uploadHandler.go | 4 +++- templates/upload.html | 5 ++++- translations/de-de.all.json | 6 +++++- translations/en-us.all.json | 4 ++++ 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/router/upload.go b/router/upload.go index 2e7f89a5..9557ab8e 100644 --- a/router/upload.go +++ b/router/upload.go @@ -28,6 +28,7 @@ type UploadForm struct { Name string Magnet string Category string + Remake bool Description string captcha.Captcha @@ -40,19 +41,12 @@ type UploadForm struct { // TODO: these should be in another package (?) -// form value for torrent name +// form names const UploadFormName = "name" - -// form value for torrent file const UploadFormTorrent = "torrent" - -// form value for magnet uri (?) const UploadFormMagnet = "magnet" - -// form value for category const UploadFormCategory = "c" - -// form value for description +const UploadFormRemake = "remake" const UploadFormDescription = "desc" // error indicating that you can't send both a magnet link and torrent @@ -84,6 +78,7 @@ func (f *UploadForm) ExtractInfo(r *http.Request) error { f.Category = r.FormValue(UploadFormCategory) f.Description = r.FormValue(UploadFormDescription) f.Magnet = r.FormValue(UploadFormMagnet) + f.Remake = r.FormValue(UploadFormRemake) == "on" f.Captcha = captcha.Extract(r) if !captcha.Authenticate(f.Captcha) { diff --git a/router/uploadHandler.go b/router/uploadHandler.go index 8cb87e7c..5d964dd7 100644 --- a/router/uploadHandler.go +++ b/router/uploadHandler.go @@ -34,7 +34,9 @@ func UploadHandler(w http.ResponseWriter, r *http.Request) { fmt.Printf("error %+v\n", err) } status := 1 // normal - if user.Status == 1 { + if uploadForm.Remake { // overrides trusted + status = 2 + } else if user.Status == 1 { status = 3 // mark as trusted if user is trusted } //add to db and redirect depending on result diff --git a/templates/upload.html b/templates/upload.html index 17ddf7e2..1054c38f 100644 --- a/templates/upload.html +++ b/templates/upload.html @@ -40,7 +40,10 @@ - + +
+ +
diff --git a/translations/de-de.all.json b/translations/de-de.all.json index 7eb46263..81b0fcf8 100644 --- a/translations/de-de.all.json +++ b/translations/de-de.all.json @@ -45,7 +45,7 @@ }, { "id":"confirm_password", - "translation": "Bestätige dein Passwort" + "translation": "Passwort-Bestätigung" }, { "id":"i_agree", @@ -566,5 +566,9 @@ { "id": "moderation", "translation": "Moderation" + }, + { + "id": "mark_as_remake", + "translation": "Als Remake markieren" } ] diff --git a/translations/en-us.all.json b/translations/en-us.all.json index 5a80cf59..85048181 100644 --- a/translations/en-us.all.json +++ b/translations/en-us.all.json @@ -574,5 +574,9 @@ { "id": "renchon_anon_explanation", "translation": "れんちょん is the username assigned to uploads and comments made anonymously. It is also used for torrent imported from the original nyaa, though the original uploader may be displayed alongside." + }, + { + "id": "mark_as_remake", + "translation": "Mark as remake" } ]