Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
* Fix #1479 and allows the removal of accepted tags for torrent's owner/moderator
* Fix #1478 moved /add to old api behavior
Cette révision appartient à :
akuma06 2017-09-04 00:40:08 +02:00 révisé par ewhal
Parent 0c241dfda5
révision 5633a37030
3 fichiers modifiés avec 9 ajouts et 11 suppressions

Voir le fichier

@ -109,14 +109,18 @@ func AddTag(c *gin.Context) {
c.Status(http.StatusNotFound)
return
}
tagForm := &tagsValidator.CreateForm{c.Query("tag"), c.Query("type")}
if c.Query("tag") != "" && user.ID > 0 {
validator.ValidateForm(tagForm, messages)
if !messages.HasErrors() {
// We load tags for user and torrents
user.LoadTags(torrent)
postTags(c, torrent, user)
newTag := models.Tag{Tag: tagForm.Tag, Type: tagForm.Type, UserID: user.ID, TorrentID: torrent.ID, Weight: user.Pantsu}
if !user.Tags.Contains(newTag) {
// We check if the user has already submitted this tag, if he has, we prevent him to vote twice for it
tags.FilterOrCreate(&newTag, torrent, user)
torrent.Update(false)
}
}
}
if _, ok := c.GetQuery("json"); ok {

Voir le fichier

@ -124,16 +124,10 @@ func callbackOnType(tag *models.Tag, torrent *models.Torrent) {
// We finally add the tag to the column
torrent.AcceptedTags += tag.Tag
case "anidbid", "vndbid", "vgmdbid", "dlsite":
u64, err := strconv.ParseUint(tag.Tag, 10, 32)
if err != nil {
log.CheckErrorWithMessage(err, "CONVERT_TYPE: Can't convert tag '%s' to uint", tag.Tag)
return
}
u64, _ := strconv.ParseUint(tag.Tag, 10, 32)
// TODO: Perform a check that anidbid is in anidb database
tagConf := config.Get().Torrents.Tags.Types.Get(tag.Type)
if u64 > 0 {
reflect.ValueOf(torrent).Elem().FieldByName(tagConf.Field).SetUint(u64)
}
reflect.ValueOf(torrent).Elem().FieldByName(tagConf.Field).SetUint(u64)
default:
// Some tag type can have default values that you have to choose from
// We, here, check that the tag is one of them

Voir le fichier

@ -348,7 +348,7 @@ function handleVotes(e) {
} else {
el.classList.remove("minus")
el.classList.add("plus")
el.href = "/torrent/tag/add?id={{Torrent.ID}}&tag_"+ tag.type +"="+tag.tag
el.href = "/torrent/tag/add?id={{Torrent.ID}}&tag="+tag.tag+"&type="+tag.type
el.parentElement.title = 'Tag: ' + tag.type + "(" + (weight-tag.weight) + ")"
}
}