From efb07409e94be1d0771f5e3c3e66e18861bd56cd Mon Sep 17 00:00:00 2001 From: Dinis Lage Date: Sun, 26 May 2013 12:57:21 +0100 Subject: [PATCH] Fix some translations. Improve style for menu, fix layout in digitals page. Working version. --- .ruby-version | 1 + app/models/spree/digital.rb | 6 +-- .../add_digital_downloads_to_invoice.rb | 4 +- ..._digital_versions_to_admin_product_tabs.rb | 2 +- .../add_reset_digitals_to_admin_orders.rb | 2 +- app/views/spree/admin/digitals/_form.html.erb | 3 +- app/views/spree/admin/digitals/index.html.erb | 4 +- config/locales/en.yml | 48 ++++++++++--------- config/locales/it.yml | 41 ++++++++-------- config/locales/ja.yml | 25 +++++----- spec/models/order_spec.rb | 8 ++-- 11 files changed, 75 insertions(+), 69 deletions(-) create mode 100644 .ruby-version diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..d672950 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +1.9.3@digital2 diff --git a/app/models/spree/digital.rb b/app/models/spree/digital.rb index 30282a4..6187622 100644 --- a/app/models/spree/digital.rb +++ b/app/models/spree/digital.rb @@ -2,12 +2,12 @@ module Spree class Digital < ActiveRecord::Base belongs_to :variant has_many :digital_links, :dependent => :destroy - + has_attached_file :attachment, :path => ":rails_root/private/digitals/:id/:basename.:extension" - + # TODO: Limit the attachment to one single file. Paperclip supports many by default :/ attr_accessible :variant_id, :attachment - + end end \ No newline at end of file diff --git a/app/overrides/add_digital_downloads_to_invoice.rb b/app/overrides/add_digital_downloads_to_invoice.rb index 4ae7fae..0dbb996 100644 --- a/app/overrides/add_digital_downloads_to_invoice.rb +++ b/app/overrides/add_digital_downloads_to_invoice.rb @@ -2,11 +2,11 @@ Deface::Override.new(:virtual_path => "spree/shared/_order_details", :name => "add_digital_downloads_to_invoice", :insert_bottom => "td[data-hook='order_item_description']", :text => %q{ -<% if order.state == 'complete' and item.variant.digital? %> +<% if order.payment_state == 'paid' and item.variant.digital? %> <%= content_tag(:p, :class => 'download_links') do %> <% item.digital_links.each do |digital_link| %> <% format = File.extname(digital_link.digital.attachment.path).downcase %> - <%= link_to t(:digital_download, :type => t("digital_format#{format}")), digital_url(:host => Spree::Config.get(:site_url), :secret => digital_link.secret), :class => "btn #{format}" %> + <%= link_to Spree.t(:digital_download, :type => Spree.t("digital_format#{format}")), digital_url(:host => Spree::Config.get(:site_url), :secret => digital_link.secret), :class => "btn #{format}" %> <% end %> <% end %> <% end %> diff --git a/app/overrides/add_digital_versions_to_admin_product_tabs.rb b/app/overrides/add_digital_versions_to_admin_product_tabs.rb index 08ac92b..978f58b 100644 --- a/app/overrides/add_digital_versions_to_admin_product_tabs.rb +++ b/app/overrides/add_digital_versions_to_admin_product_tabs.rb @@ -2,7 +2,7 @@ Deface::Override.new(:virtual_path => "spree/admin/shared/_product_tabs", :name => "add_digital_versions_to_admin_product_tabs", :insert_bottom => "[data-hook='admin_product_tabs'], #admin_product_tabs[data-hook]", :text => " > - <%= link_to t(\"digital_versions\"), admin_product_digitals_path(@product) %> + <%= link_to_with_icon 'icon-tasks', Spree.t(:digital_versions), admin_product_digitals_path(@product) %> ", :disabled => false) diff --git a/app/overrides/add_reset_digitals_to_admin_orders.rb b/app/overrides/add_reset_digitals_to_admin_orders.rb index e4b3688..b0aa1b9 100644 --- a/app/overrides/add_reset_digitals_to_admin_orders.rb +++ b/app/overrides/add_reset_digitals_to_admin_orders.rb @@ -2,6 +2,6 @@ Deface::Override.new(:virtual_path => "spree/admin/shared/_order_tabs", :name => "add_reset_digitals_to_admin_orders", :insert_after => ".sidebar", :text => %q{ -<%= content_tag(:p, button_link_to(t(:reset_downloads), reset_digitals_admin_order_url(@order)), class: 'clear') if @order.digital? or true %> +<%= content_tag(:p, button_link_to(Spree.t(:reset_downloads), reset_digitals_admin_order_url(@order)), class: 'clear') if @order.digital? or true %> }, :disabled => false) diff --git a/app/views/spree/admin/digitals/_form.html.erb b/app/views/spree/admin/digitals/_form.html.erb index 8fcd139..b66fa43 100644 --- a/app/views/spree/admin/digitals/_form.html.erb +++ b/app/views/spree/admin/digitals/_form.html.erb @@ -1,5 +1,4 @@
-
<%= form_for(:digital, :url => admin_product_digitals_path(@product), :method => :create, :multipart => true ) do |f| %>
<%= Spree::Variant.model_name.human %> "<%= variant.options_text %>" @@ -11,7 +10,7 @@ <% variant.digitals.each do |digital| %>
  • <%= render digital %>   - <%= link_to Spree.t("delete_file"), admin_product_digital_url(@product, digital), :confirm => Spree.t('delete_file_cofirmation', :filename => digital.attachment_file_name), :method => :delete %> + <%= link_to Spree.t(:delete_file), admin_product_digital_url(@product, digital), :confirm => Spree.t(:delete_file_cofirmation, :filename => digital.attachment_file_name), :method => :delete %>
  • <% end %> diff --git a/app/views/spree/admin/digitals/index.html.erb b/app/views/spree/admin/digitals/index.html.erb index a746a58..136547e 100644 --- a/app/views/spree/admin/digitals/index.html.erb +++ b/app/views/spree/admin/digitals/index.html.erb @@ -8,10 +8,10 @@ <% end %> <% else %> - This product has no variants. + <%= Spree.t :product_without_variants %> <% if @product.master.digital? %> - A digital version of this product currently exists: + <%= Spree.t :digital_exists %> <%= render @product.master.digitals %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 440bb39..604c932 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,24 +1,28 @@ en: - broken_file: Warning! this file is broken - current_file: Current File - delete_file: Delete this file - delete_file_cofirmation: Are you sure you want to delete the file %{filename}? - digital_delivery: Digital Delivery - digital_download: Download %{type} ↓ - digital_download_links: Digital Download Links - digital_format: - mp3: Audio MP3 - mobi: Kindle eBook - epub: ePub eBook - pdf: pdf eBook - digital_versions: Digital Versions - downloads_reset: Digital Downloads Reset - new_file: New File - reset_downloads: Reset Digital Downloads spree: - digitals: - unauthorized: - explained: This download link has expired. - unauthorized: Unauthorized - spree_digital: - upload: Upload + broken_file: Warning! this file is broken + current_file: Current File + delete_file: Delete this file + delete_file_cofirmation: Are you sure you want to delete the file %{filename}? + digital_delivery: Digital Delivery + digital_download: Download %{type} ↓ + digital_download_links: Digital Download Links + digital_format: + mp3: Audio MP3 + mobi: Kindle eBook + epub: ePub eBook + pdf: pdf eBook + gz: Archive + digital_versions: Digital Versions + downloads_reset: Digital Downloads Reset + new_file: New File + reset_downloads: Reset Digital Downloads + spree: + digitals: + unauthorized: + explained: This download link has expired. + unauthorized: Unauthorized + spree_digital: + upload: Upload + product_without_variants: This product has no variants. + digital_exists: 'A digital version of this product currently exists:' diff --git a/config/locales/it.yml b/config/locales/it.yml index 46a44c8..a67c91f 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -1,22 +1,23 @@ it: - broken_file: Attenzione! questo file sembra essere rotto - current_file: File Corrente - delete_file: Elimina questo file - delete_file_cofirmation: Sei sicuro di voler eliminare il file %{filename}? - digital_delivery: Consegna Digitale - digital_download: Download %{type} ↓ - digital_download_links: Link al Download Digitale - digital_format: - mp3: Audio MP3 - mobi: Kindle eBook - epub: ePub eBook - pdf: pdf eBook - digital_versions: Versioni Digitali - new_file: Nuovo File spree: - digitals: - unauthorized: - explained: This download link has expired. - unauthorized: Unauthorized - spree_digital: - upload: Upload \ No newline at end of file + broken_file: Attenzione! questo file sembra essere rotto + current_file: File Corrente + delete_file: Elimina questo file + delete_file_cofirmation: Sei sicuro di voler eliminare il file %{filename}? + digital_delivery: Consegna Digitale + digital_download: Download %{type} ↓ + digital_download_links: Link al Download Digitale + digital_format: + mp3: Audio MP3 + mobi: Kindle eBook + epub: ePub eBook + pdf: pdf eBook + digital_versions: Versioni Digitali + new_file: Nuovo File + spree: + digitals: + unauthorized: + explained: This download link has expired. + unauthorized: Unauthorized + spree_digital: + upload: Upload \ No newline at end of file diff --git a/config/locales/ja.yml b/config/locales/ja.yml index cb3ff2c..fd66ab8 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -1,14 +1,15 @@ ja: - broken_file: 注意! このファイルが壊れている! - current_file: 現在のバージョン - delete_file: このファイルを削除 - delete_file_cofirmation: 本当に「%{filename}」を削除しても宜しいですか? - digital_shipping: ダウンロードリンクを%{email}に送ります - digital_versions: デジタル版 - new_file: 新しいファイル spree: - digitals: - unauthorized: - explained: This download link has expired. - unauthorized: Unauthorized - upload: アップロード + broken_file: 注意! このファイルが壊れている! + current_file: 現在のバージョン + delete_file: このファイルを削除 + delete_file_cofirmation: 本当に「%{filename}」を削除しても宜しいですか? + digital_shipping: ダウンロードリンクを%{email}に送ります + digital_versions: デジタル版 + new_file: 新しいファイル + spree: + digitals: + unauthorized: + explained: This download link has expired. + unauthorized: Unauthorized + upload: アップロード diff --git a/spec/models/order_spec.rb b/spec/models/order_spec.rb index 3fa1fdf..00f1fca 100644 --- a/spec/models/order_spec.rb +++ b/spec/models/order_spec.rb @@ -64,10 +64,10 @@ describe Spree::Order do it "should only offer digital shipping if all items are digital" do order.digital?.should be_true - order.create_proposed_shipments - order.shipping_rates.count.should == 1 - order.shipping_rates.first.shipping_method.calculator.class.should == Spree::Calculator::DigitalDelivery - order.shipping_rates.first.cost.should == 0.0 + shipments = order.create_proposed_shipments + shipments.count.should == 1 + shipments.first.shipping_method.calculator.class.should == Spree::Calculator::DigitalDelivery + shipments.first.cost.should == 0.0 end it "should not offer digital shipping if only some items are digital" do