Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Tested and works!

Changes:
* Updates only the colomns of torrent table
* Moved categories config in config/torrents.go
Cette révision appartient à :
akuma06 2017-05-24 22:15:38 +02:00
Parent 1cccaf99e0
révision 041473bfac
2 fichiers modifiés avec 49 ajouts et 8 suppressions

Voir le fichier

@ -1,5 +1,6 @@
package config
/* Config of different status id for torrents */
var TorrentStatus = map[int]bool{
0: true,
1: true,
@ -7,3 +8,43 @@ var TorrentStatus = map[int]bool{
3: true,
4: true,
}
/* Config for Sukebei categories */
var TorrentSukebeiCategories = map[string]string{
"1_": "art",
"1_1": "art_anime",
"1_2": "art_doujinshi",
"1_3": "art_games",
"1_4": "art_manga",
"1_5": "art_pictures",
"2_": "real_life",
"2_1": "real_life_photobooks_and_pictures",
"2_2": "real_life_videos",
}
/* Config for Site categories */
var TorrentCleanCategories = map[string]string{
"3_": "anime",
"3_12": "anime_amv",
"3_5": "anime_english_translated",
"3_13": "anime_non_english_translated",
"3_6": "anime_raw",
"2_": "audio",
"2_3": "audio_lossless",
"2_4": "audio_lossy",
"4_": "literature",
"4_7": "literature_english_translated",
"4_8": "literature_raw",
"4_14": "literature_non_english_translated",
"5_": "live_action",
"5_9": "live_action_english_translated",
"5_10": "live_action_idol_pv",
"5_18": "live_action_non_english_translated",
"5_11": "live_action_raw",
"6_": "pictures",
"6_15": "pictures_graphics",
"6_16": "pictures_photos",
"1_": "software",
"1_1": "software_applications",
"1_2": "software_games",
}

Voir le fichier

@ -365,10 +365,10 @@ func ApiMassMod(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
if !messages.HasErrors() {
mapOk := map[string]bool{"ok": true, "errors": false}
mapOk := map[string]interface{}{"ok": true, "infos": messages.GetAllInfos()["infos"]}
apiJson, _ = json.Marshal(mapOk)
} else { // We need to show error messages
mapNotOk := map[string]interface{}{"ok": false, "errors": messages.GetAllErrors()}
mapNotOk := map[string]interface{}{"ok": false, "errors": messages.GetAllErrors()["errors"]}
apiJson, _ = json.Marshal(mapNotOk)
}
@ -411,15 +411,15 @@ func torrentManyAction(r *http.Request) {
if r.FormValue("withreport") == "" { // Default behavior for withreport
withReport = false
}
if !config.TorrentStatus[status] { // Check if the status exist
messages.AddErrorTf("errors", "no_status_exist", status)
status = -1
}
if !userPermission.HasAdmin(currentUser) {
if r.FormValue("status") != "" { // Condition to check if a user try to change torrent status without having the right permission
if (status == model.TorrentStatusTrusted && !currentUser.IsTrusted()) || status == model.TorrentStatusAPlus || status == 0 {
status = model.TorrentStatusNormal
}
if !config.TorrentStatus[status] {
messages.AddErrorTf("errors", "no_status_exist", status)
status = -1
}
}
if r.FormValue("owner") != "" { // Only admins can change owner of torrents
owner = -1
@ -429,8 +429,8 @@ func torrentManyAction(r *http.Request) {
if r.FormValue("owner") != "" && userPermission.HasAdmin(currentUser) { // We check that the user given exist and if not we return an error
_, _, errorUser := userService.RetrieveUserForAdmin(strconv.Itoa(owner))
if errorUser != nil {
owner = -1
messages.AddErrorTf("errors", "no_user_found_id", owner)
owner = -1
}
}
if category != "" {
@ -474,7 +474,7 @@ func torrentManyAction(r *http.Request) {
}
/* Changes are done, we save */
db.ORM.Save(&torrent)
db.ORM.Model(&torrent).UpdateColumn(&torrent)
} else if action == "delete" {
_, err = torrentService.DeleteTorrent(torrent_id)
if err != nil {