add options for modifying commentary/commentary_request tags on form #2623
This commit is contained in:
@@ -567,6 +567,10 @@ div#unapprove-dialog {
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
input[type=checkbox] {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
textarea {
|
||||
font-size: 1em;
|
||||
width: 100%;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,19 +1,49 @@
|
||||
<p>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"}) %></p>
|
||||
|
||||
<%= form_tag(create_or_update_artist_commentaries_path(:format => :js), :remote => true, :class => "simple_form", :method => :put) do %>
|
||||
<div class="input">
|
||||
<%= hidden_field :artist_commentary, :post_id, :value => @post.id %>
|
||||
<%= hidden_field :artist_commentary, :post_id, :value => @post.id %>
|
||||
|
||||
<div class="input">
|
||||
<label for="artist_commentary_original_title">Original title</label>
|
||||
<%= text_field :artist_commentary, :original_title, :value => artist_commentary.try(:original_title) %>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
<label for="artist_commentary_original_description">Original description</label>
|
||||
<%= text_area :artist_commentary, :original_description, :size => "40x6", :value => artist_commentary.try(:original_description) %>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
<label for="artist_commentary_translated_title">Translated title</label>
|
||||
<%= text_field :artist_commentary, :translated_title, :value => artist_commentary.try(:translated_title) %>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
<label for="artist_commentary_translated_description">Translated description</label>
|
||||
<%= text_area :artist_commentary, :translated_description, :size => "40x6", :value => artist_commentary.try(:translated_description) %>
|
||||
</div>
|
||||
|
||||
<% if @post.has_tag?("commentary") %>
|
||||
<div class="input">
|
||||
<label for="artist_commentary_remove_commentary_tag">Remove <em>commentary</em> tag</label>
|
||||
<%= check_box :artist_commentary, :remove_commentary_tag %>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="input">
|
||||
<label for="artist_commentary_add_commentary_tag">Add <em>commentary</em> tag</label>
|
||||
<%= check_box :artist_commentary, :add_commentary_tag %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if @post.has_tag?("commentary_request") %>
|
||||
<div class="input">
|
||||
<label for="artist_commentary_remove_commentary_request_tag">Remove <em>commentary_request</em> tag</label>
|
||||
<%= check_box :artist_commentary, :remove_commentary_request_tag %>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="input">
|
||||
<label for="artist_commentary_add_commentary_request_tag">Add <em>commentary_request</em> tag</label>
|
||||
<%= check_box :artist_commentary, :add_commentary_request_tag %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user