From 7e99a1b38b69309dd84a2b18b25f26c99017e072 Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 29 Apr 2018 22:05:59 -0500 Subject: [PATCH] artist commentary form: add partial_commentary checkbox. Add a checkbox for adding/removing the partial_commentary tag in the artist commentary form. ref: https://danbooru.donmai.us/forum_topics/15101. --- .../artist_commentaries_controller.rb | 4 ++-- app/models/artist_commentary.rb | 12 ++++++++++-- app/views/artist_commentaries/_form.html.erb | 16 ++++++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/app/controllers/artist_commentaries_controller.rb b/app/controllers/artist_commentaries_controller.rb index ddcfd912d..e532653a8 100644 --- a/app/controllers/artist_commentaries_controller.rb +++ b/app/controllers/artist_commentaries_controller.rb @@ -40,8 +40,8 @@ private def commentary_params params.fetch(:artist_commentary, {}).except(:post_id).permit(%i[ original_description original_title translated_description translated_title - remove_commentary_tag remove_commentary_request_tag remove_commentary_check_tag - add_commentary_tag add_commentary_request_tag add_commentary_check_tag + remove_commentary_tag remove_commentary_request_tag remove_commentary_check_tag remove_partial_commentary_tag + add_commentary_tag add_commentary_request_tag add_commentary_check_tag add_partial_commentary_tag ]) end end diff --git a/app/models/artist_commentary.rb b/app/models/artist_commentary.rb index 5d8a59885..39fd8f607 100644 --- a/app/models/artist_commentary.rb +++ b/app/models/artist_commentary.rb @@ -1,8 +1,8 @@ class ArtistCommentary < ApplicationRecord class RevertError < Exception ; end - attr_accessor :remove_commentary_tag, :remove_commentary_request_tag, :remove_commentary_check_tag - attr_accessor :add_commentary_tag, :add_commentary_request_tag, :add_commentary_check_tag + attr_accessor :remove_commentary_tag, :remove_commentary_request_tag, :remove_commentary_check_tag, :remove_partial_commentary_tag + attr_accessor :add_commentary_tag, :add_commentary_request_tag, :add_commentary_check_tag, :add_partial_commentary_tag before_validation :trim_whitespace validates_uniqueness_of :post_id belongs_to :post, required: true @@ -108,6 +108,14 @@ class ArtistCommentary < ApplicationRecord post.add_tag("check_commentary") end + if remove_partial_commentary_tag == "1" + post.remove_tag("partial_commentary") + end + + if add_partial_commentary_tag == "1" + post.add_tag("partial_commentary") + end + post.save if post.tag_string_changed? end diff --git a/app/views/artist_commentaries/_form.html.erb b/app/views/artist_commentaries/_form.html.erb index 01967ca01..537e42b1a 100644 --- a/app/views/artist_commentaries/_form.html.erb +++ b/app/views/artist_commentaries/_form.html.erb @@ -80,4 +80,20 @@ <% end %> + + <% if post.has_tag?("partial_commentary") %> +
+ +
+ <% else %> +
+ +
+ <% end %> <% end %>