Fix rating: metatag on upload
This commit is contained in:
@@ -38,5 +38,9 @@ div#c-uploads {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
div.field_with_errors {
|
||||
display: inline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class Upload < ActiveRecord::Base
|
||||
after_destroy :delete_temp_file
|
||||
validate :uploader_is_not_limited, :on => :create
|
||||
validate :file_or_source_is_present, :on => :create
|
||||
validates :rating, :presence => true
|
||||
validate :rating_given
|
||||
attr_accessible :file, :image_width, :image_height, :file_ext, :md5, :file_size, :as_pending, :source, :file_path, :content_type, :rating, :tag_string, :status, :backtrace, :post_id, :md5_confirmation, :parent_id
|
||||
|
||||
module ValidationMethods
|
||||
@@ -60,6 +60,18 @@ class Upload < ActiveRecord::Base
|
||||
raise "md5 mismatch"
|
||||
end
|
||||
end
|
||||
|
||||
def rating_given
|
||||
if rating.present?
|
||||
return true
|
||||
elsif tag_string =~ /(?:\s|^)rating:[qse](?:\s|$)/i
|
||||
self.rating = "q" # Dummy just so the upload can be created. The metatag will set the correct rating on the post after upload.
|
||||
return true
|
||||
else
|
||||
self.errors.add(:base, "Must specify a rating")
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module ConversionMethods
|
||||
|
||||
@@ -35,7 +35,11 @@
|
||||
|
||||
<div class="input">
|
||||
<%= f.label :source %>
|
||||
<%= f.text_field :source, :size => 50, :value => params[:url] %>
|
||||
<% if params[:url].present? %>
|
||||
<%= f.text_field :source, :size => 50, :value => params[:url] %>
|
||||
<% else %>
|
||||
<%= f.text_field :source, :size => 50 %>
|
||||
<% end %>
|
||||
<%= button_tag "Similar", :id => "similar-button", :type => "button" %>
|
||||
<%= button_tag "Artist", :id => "find-artist-button", :type => "button" %>
|
||||
<span class="hint">You can enter a URL to have <%= Danbooru.config.app_name %> automatically download and process it</span>
|
||||
@@ -45,13 +49,13 @@
|
||||
<%= f.label :rating %>
|
||||
|
||||
<fieldset class="ratings">
|
||||
<%= f.radio_button :rating, :e, :required => true %>
|
||||
<%= f.radio_button :rating, :e %>
|
||||
<%= f.label :rating_e, "Explicit", :title => "Hardcore porn, visible genitals" %>
|
||||
|
||||
<%= f.radio_button :rating, :q, :required => true %>
|
||||
<%= f.radio_button :rating, :q %>
|
||||
<%= f.label :rating_q, "Questionable", :title => "Nudity, anything erotic" %>
|
||||
|
||||
<%= f.radio_button :rating, :s, :required => true %>
|
||||
<%= f.radio_button :rating, :s %>
|
||||
<%= f.label :rating_s, "Safe", :title => "Everything else" %>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user