From 8bd7ad5a1e327e451009c7640405767271c2012b Mon Sep 17 00:00:00 2001 From: Matchu Date: Wed, 16 Oct 2013 15:50:48 -0500 Subject: [PATCH] support manually uploaded swf asset images - not the actual uploading, but block them from being reconverted --- .../stylesheets/broken_image_reports/_new.sass | 2 ++ app/controllers/broken_image_reports_controller.rb | 9 ++++++--- app/views/broken_image_reports/new.html.haml | 13 ++++++++----- config/locales/en.yml | 10 +++++++--- ...20131016203607_add_image_manual_to_swf_assets.rb | 5 +++++ db/schema.rb | 3 ++- 6 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 db/migrate/20131016203607_add_image_manual_to_swf_assets.rb diff --git a/app/assets/stylesheets/broken_image_reports/_new.sass b/app/assets/stylesheets/broken_image_reports/_new.sass index f725497a..a79b0eb1 100644 --- a/app/assets/stylesheets/broken_image_reports/_new.sass +++ b/app/assets/stylesheets/broken_image_reports/_new.sass @@ -22,3 +22,5 @@ body.broken_image_reports-new span font-size: 85% + .manual a + display: block diff --git a/app/controllers/broken_image_reports_controller.rb b/app/controllers/broken_image_reports_controller.rb index 088e6141..364d608c 100644 --- a/app/controllers/broken_image_reports_controller.rb +++ b/app/controllers/broken_image_reports_controller.rb @@ -13,10 +13,13 @@ class BrokenImageReportsController < ApplicationController swf_asset = SwfAsset.where(:type => params[:swf_asset_type]). find_by_remote_id(params[:swf_asset_remote_id]) - if swf_asset.report_broken - flash[:success] = t('broken_image_reports.create.success') + if swf_asset.image_manual? + flash[:warning] = t('broken_image_reports.create.manual') else - flash[:alert] = t('broken_image_reports.create.already_reported') + # If the asset is already reported as broken, no need to shout about it. + # Just don't enqueue it, thank the user, and move on. + swf_asset.report_broken + flash[:success] = t('broken_image_reports.create.success') end redirect_to :back diff --git a/app/views/broken_image_reports/new.html.haml b/app/views/broken_image_reports/new.html.haml index 39378815..d27ad34a 100644 --- a/app/views/broken_image_reports/new.html.haml +++ b/app/views/broken_image_reports/new.html.haml @@ -8,14 +8,17 @@ - @swf_assets.each do |swf_asset| %li = link_to image_tag(swf_asset.image_url([150, 150])), swf_asset.url - - unless swf_asset.image_pending_repair? - = form_tag(:action => :create) do + - if swf_asset.image_manual? + %span.manual + = t '.image_manual.description' + = mail_to contact_email, t('.image_manual.contact') + - elsif swf_asset.image_pending_repair? + %span.reported-broken-at= format_reported_at(swf_asset.reported_broken_at) + - else + = form_tag(action: :create) do = hidden_field_tag 'swf_asset_remote_id', swf_asset.remote_id = hidden_field_tag 'swf_asset_type', swf_asset.type = submit_tag t('.submit') - if swf_asset.converted_at? %span.converted-at= format_converted_at(swf_asset.converted_at) - - else - %span.reported-broken-at= format_reported_at(swf_asset.reported_broken_at) - diff --git a/config/locales/en.yml b/config/locales/en.yml index 8c52b9ae..cbe86b1b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -50,9 +50,10 @@ en: success: Thanks! This image will be reconverted soon. If it looks the same after conversion, please consider sending a bug report. - already_reported: - This image is already in line for reconversion. We'll get to it soon, - don't worry. + manual: + This image was uploaded manually, so we don't want to run the + automatic converters on it. If this manual version is broken, let us + know at webmaster@openneo.net. Thanks! new: title: Report broken image @@ -67,6 +68,9 @@ en: submit: Report as broken converted_at_html: Converted %{converted_at_ago} ago reported_at_html: Reported %{reported_at_ago} ago + image_manual: + description: Uploaded manually. + contact: Send a bug report? closet_hangers: closet_hanger: diff --git a/db/migrate/20131016203607_add_image_manual_to_swf_assets.rb b/db/migrate/20131016203607_add_image_manual_to_swf_assets.rb new file mode 100644 index 00000000..01531e7e --- /dev/null +++ b/db/migrate/20131016203607_add_image_manual_to_swf_assets.rb @@ -0,0 +1,5 @@ +class AddImageManualToSwfAssets < ActiveRecord::Migration + def change + add_column :swf_assets, :image_manual, :boolean, null: false, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 0c8b4ec8..d0ef553e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130427151327) do +ActiveRecord::Schema.define(:version => 20131016203607) do create_table "auth_servers", :force => true do |t| t.string "short_name", :limit => 10, :null => false @@ -291,6 +291,7 @@ ActiveRecord::Schema.define(:version => 20130427151327) do t.boolean "image_requested", :default => false, :null => false t.datetime "reported_broken_at" t.datetime "converted_at" + t.boolean "image_manual", :default => false, :null => false end add_index "swf_assets", ["body_id"], :name => "swf_assets_body_id_and_object_id"