diff --git a/app/assets/stylesheets/specific/posts.css.scss b/app/assets/stylesheets/specific/posts.css.scss index 025adb0a3..6bbdc33ae 100644 --- a/app/assets/stylesheets/specific/posts.css.scss +++ b/app/assets/stylesheets/specific/posts.css.scss @@ -567,6 +567,10 @@ div#unapprove-dialog { width: 70%; } + input[type=checkbox] { + width: auto; + } + textarea { font-size: 1em; width: 100%; diff --git a/app/models/artist_commentary.rb b/app/models/artist_commentary.rb index 76e1cc949..26d9f1ff7 100644 --- a/app/models/artist_commentary.rb +++ b/app/models/artist_commentary.rb @@ -1,9 +1,12 @@ class ArtistCommentary < ActiveRecord::Base - attr_accessible :post_id, :original_description, :original_title, :translated_description, :translated_title + attr_accessor :remove_commentary_tag, :remove_commentary_request_tag + attr_accessor :add_commentary_tag, :add_commentary_request_tag + attr_accessible :post_id, :original_description, :original_title, :translated_description, :translated_title, :remove_commentary_tag, :remove_commentary_request_tag, :add_commentary_tag, :add_commentary_request_tag validates_uniqueness_of :post_id belongs_to :post has_many :versions, lambda {order("artist_commentary_versions.id ASC")}, :class_name => "ArtistCommentaryVersion", :dependent => :destroy, :foreign_key => :post_id, :primary_key => :post_id after_save :create_version + after_commit :tag_post module SearchMethods def text_matches(query) @@ -83,4 +86,24 @@ class ArtistCommentary < ActiveRecord::Base revert_to(version) save! end + + def tag_post + if remove_commentary_tag == "1" + post.remove_tag("commentary") + end + + if add_commentary_tag == "1" + post.add_tag("commentary") + end + + if remove_commentary_request_tag == "1" + post.remove_tag("commentary_request") + end + + if add_commentary_request_tag == "1" + post.add_tag("commentary_request") + end + + post.save if post.tag_string_changed? + end end diff --git a/app/models/post.rb b/app/models/post.rb index 8edb8099e..bca459b71 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -754,6 +754,14 @@ class Post < ActiveRecord::Base !!(tag_string =~ /(?:^| )(?:#{tag})(?:$| )/) end + def add_tag(tag) + set_tag_string("#{tag_string} #{tag}") + end + + def remove_tag(tag) + set_tag_string((tag_array - tag).join(" ")) + end + def has_dup_tag? has_tag?("duplicate") end diff --git a/app/views/artist_commentaries/_form.html.erb b/app/views/artist_commentaries/_form.html.erb index 835011730..738d822b8 100644 --- a/app/views/artist_commentaries/_form.html.erb +++ b/app/views/artist_commentaries/_form.html.erb @@ -1,19 +1,49 @@

If the artist of this image posted some interesting additional information about this work, you can copy it here. <%= link_to "View help.", wiki_pages_path(:search => {:title => "help:artist_commentary"}) %>

<%= form_tag(create_or_update_artist_commentaries_path(:format => :js), :remote => true, :class => "simple_form", :method => :put) do %> -
- <%= hidden_field :artist_commentary, :post_id, :value => @post.id %> + <%= hidden_field :artist_commentary, :post_id, :value => @post.id %> +
<%= text_field :artist_commentary, :original_title, :value => artist_commentary.try(:original_title) %> +
+
<%= text_area :artist_commentary, :original_description, :size => "40x6", :value => artist_commentary.try(:original_description) %> +
+
<%= text_field :artist_commentary, :translated_title, :value => artist_commentary.try(:translated_title) %> +
+
<%= text_area :artist_commentary, :translated_description, :size => "40x6", :value => artist_commentary.try(:translated_description) %>
+ + <% if @post.has_tag?("commentary") %> +
+ + <%= check_box :artist_commentary, :remove_commentary_tag %> +
+ <% else %> +
+ + <%= check_box :artist_commentary, :add_commentary_tag %> +
+ <% end %> + + <% if @post.has_tag?("commentary_request") %> +
+ + <%= check_box :artist_commentary, :remove_commentary_request_tag %> +
+ <% else %> +
+ + <%= check_box :artist_commentary, :add_commentary_request_tag %> +
+ <% end %> <% end %>