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%;
|
width: 70%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input[type=checkbox] {
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
textarea {
|
textarea {
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
class ArtistCommentary < ActiveRecord::Base
|
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
|
validates_uniqueness_of :post_id
|
||||||
belongs_to :post
|
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
|
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_save :create_version
|
||||||
|
after_commit :tag_post
|
||||||
|
|
||||||
module SearchMethods
|
module SearchMethods
|
||||||
def text_matches(query)
|
def text_matches(query)
|
||||||
@@ -83,4 +86,24 @@ class ArtistCommentary < ActiveRecord::Base
|
|||||||
revert_to(version)
|
revert_to(version)
|
||||||
save!
|
save!
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
@@ -754,6 +754,14 @@ class Post < ActiveRecord::Base
|
|||||||
!!(tag_string =~ /(?:^| )(?:#{tag})(?:$| )/)
|
!!(tag_string =~ /(?:^| )(?:#{tag})(?:$| )/)
|
||||||
end
|
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?
|
def has_dup_tag?
|
||||||
has_tag?("duplicate")
|
has_tag?("duplicate")
|
||||||
end
|
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>
|
<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 %>
|
<%= 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>
|
<label for="artist_commentary_original_title">Original title</label>
|
||||||
<%= text_field :artist_commentary, :original_title, :value => artist_commentary.try(:original_title) %>
|
<%= 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>
|
<label for="artist_commentary_original_description">Original description</label>
|
||||||
<%= text_area :artist_commentary, :original_description, :size => "40x6", :value => artist_commentary.try(:original_description) %>
|
<%= 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>
|
<label for="artist_commentary_translated_title">Translated title</label>
|
||||||
<%= text_field :artist_commentary, :translated_title, :value => artist_commentary.try(:translated_title) %>
|
<%= 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>
|
<label for="artist_commentary_translated_description">Translated description</label>
|
||||||
<%= text_area :artist_commentary, :translated_description, :size => "40x6", :value => artist_commentary.try(:translated_description) %>
|
<%= text_area :artist_commentary, :translated_description, :size => "40x6", :value => artist_commentary.try(:translated_description) %>
|
||||||
</div>
|
</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 %>
|
<% end %>
|
||||||
|
|||||||
Reference in New Issue
Block a user