14 Commits
Author SHA1 Message Date
Jeff DutilandMichael Bianco 7dabf1a520 Support Spree 1.3.x, add default unauthorized page, and organize locales. 2013-03-10 09:46:06 -04:00
Michael Bianco 52e7009c17 Running tests, and fixing breaking changes, for 1.2.3 2013-03-10 09:35:48 -04:00
Michael Bianco 8d44a25199 Note about improvement to create_digital_links 2013-03-10 09:35:48 -04:00
Michael Bianco e6f8d6b4cc Merge pull request #35 from nitsujri/master
Fix for digital_controller throwing an error with unavailable.html.erb
2013-03-10 06:29:03 -07:00
Justin Louie 1d9fab3942 Fixing controller for current_order bug
unavailable.html.erb throws an error missing current_order

https://groups.google.com/forum/?fromgroups=#!topic/spree-user/mbEVVManQY8
2013-03-10 14:08:04 +08:00
Michael Bianco f6d5812379 Merge pull request #32 from jdutil/patch-1
Fix README link.
2013-02-12 13:06:25 -08:00
Jeff Dutil e2f33cd006 Fix README link.
Also add shell syntax highlighting.
2013-02-09 14:01:39 -05:00
Michael Bianco 9360c63503 Fixing deface name typo 2013-01-28 10:01:39 -05:00
Dave MitchellandMichael Bianco b381ede8e1 Convert 1.9 to 1.8 syntax. Fixes #23 2013-01-08 13:41:07 -05:00
Michael Bianco 37fe465dd9 Updating documentation. Adding nginx send_file info 2012-11-06 11:34:28 -05:00
Michael Bianco 23317eb0fb Adding button to order admin to reset digital downloads
* Resets expire time
* Resets download count
2012-11-01 17:36:47 -04:00
Michael Bianco 4dc2d9d54f Minor improvement to digital factory 2012-10-29 13:05:35 -04:00
Michael Bianco 446a23ce3a Adding Spree::Order#reset_digital_links! to ease in handling customer support
Hope to add this as a button to the admin soon.
2012-10-29 13:04:39 -04:00
Michael Bianco fdd8536b5b Tests passing on 1.2 2012-10-29 12:55:37 -04:00
17 changed files with 94 additions and 45 deletions
+1 -1
View File
@@ -9,4 +9,4 @@ group :test do
end end
end end
gem 'spree', '~> 1.1.3' gem 'spree', '~> 1.3.2'
+2 -1
View File
@@ -1,4 +1,5 @@
"0.7.x" => { :ref => "eddaea63959586d123007cbca3be5bf9c5edb1a7" } "0.7.x" => { :ref => "eddaea63959586d123007cbca3be5bf9c5edb1a7" }
"1.0.x" => { :ref => "a8c27750ef1cf9d0ad1a2a6ebe33307da900a5c1" } "1.0.x" => { :ref => "a8c27750ef1cf9d0ad1a2a6ebe33307da900a5c1" }
"1.1.x" => { :branch => "1-1-stable" } "1.1.x" => { :branch => "1-1-stable" }
"1.2.x" => { :branch => "master" } "1.2.x" => { :ref => "9360c635039aaeeee18026b830aa96cc7587cd0d" }
"1.3.x" => { :branch => "master" }
@@ -1,6 +1,6 @@
module Spree module Spree
class Admin::DigitalsController < Spree::Admin::ResourceController class Admin::DigitalsController < Spree::Admin::ResourceController
belongs_to "spree/product", find_by: :permalink belongs_to "spree/product", :find_by => :permalink
protected protected
def location_after_save def location_after_save
@@ -0,0 +1,7 @@
Spree::Admin::OrdersController.class_eval do
def reset_digitals
@order.reset_digital_links!
flash[:notice] = t(:downloads_reset)
redirect_to admin_order_url(@order)
end
end
+4 -4
View File
@@ -1,7 +1,7 @@
module Spree module Spree
class DigitalsController < Spree::BaseController class DigitalsController < Spree::StoreController
ssl_required :show ssl_required :show
def show def show
link = DigitalLink.find_by_secret(params[:secret]) link = DigitalLink.find_by_secret(params[:secret])
@@ -19,9 +19,9 @@ module Spree
Rails.logger.error "Missing Digital Item: #{attachment.path}" Rails.logger.error "Missing Digital Item: #{attachment.path}"
end end
end end
render :unauthorized render :unauthorized
end end
end end
end end
+1 -1
View File
@@ -9,7 +9,7 @@ Spree::LineItem.class_eval do
private private
# Create the download link for this item if it is digital. # TODO there is no reason to create the digital links until the order is complete
def create_digital_links def create_digital_links
digital_links.delete_all digital_links.delete_all
+7 -1
View File
@@ -10,8 +10,14 @@ Spree::Order.class_eval do
false false
end end
# UPGRADE_CHECK this works as of spree 1.1.1; make sure to check the original function on upgrade def reset_digital_links!
line_items.select(&:digital?).map(&:digital_links).flatten.each do |digital_link|
digital_link.update_column :access_counter, 0
digital_link.update_column :created_at, Time.now
end
end
# UPGRADE_CHECK this works as of spree 1.2.0. check function for changes on upgrade
def available_shipping_methods(display_on = nil) def available_shipping_methods(display_on = nil)
return [] unless ship_address return [] unless ship_address
all_methods = Spree::ShippingMethod.all_available(self, display_on) all_methods = Spree::ShippingMethod.all_available(self, display_on)
@@ -0,0 +1,7 @@
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 %>
},
:disabled => false)
@@ -0,0 +1,9 @@
<% if defined?(SpreeFancy) %>
<% content_for :subheader do %>
<h1><%= t('.unauthorized') %></h1>
<% end %>
<% else %>
<h1><%= t('.unauthorized') %></h1>
<% end %>
<%= t('.explained') %>
+12 -5
View File
@@ -1,9 +1,7 @@
en: en:
digital_versions: Digital Versions
current_file: Current File
new_file: New File
delete_file: Delete this file
broken_file: Warning! this file is broken 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}? delete_file_cofirmation: Are you sure you want to delete the file %{filename}?
digital_delivery: Digital Delivery digital_delivery: Digital Delivery
digital_download: Download %{type} ↓ digital_download: Download %{type} ↓
@@ -13,5 +11,14 @@ en:
mobi: Kindle eBook mobi: Kindle eBook
epub: ePub eBook epub: ePub eBook
pdf: pdf 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: spree_digital:
upload: Upload upload: Upload
+10 -6
View File
@@ -1,9 +1,7 @@
it: it:
digital_versions: Versioni Digitali
current_file: File Corrente
new_file: Nuovo File
delete_file: Elimina questo file
broken_file: Attenzione! questo file sembra essere rotto 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}? delete_file_cofirmation: Sei sicuro di voler eliminare il file %{filename}?
digital_delivery: Consegna Digitale digital_delivery: Consegna Digitale
digital_download: Download %{type} ↓ digital_download: Download %{type} ↓
@@ -13,6 +11,12 @@ it:
mobi: Kindle eBook mobi: Kindle eBook
epub: ePub eBook epub: ePub eBook
pdf: pdf 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: spree_digital:
upload: Upload upload: Upload
+10 -8
View File
@@ -1,12 +1,14 @@
ja: ja:
digital_versions: デジタル版
current_file: 現在のバージョン
new_file: 新しいファイル
upload: アップロード
delete_file: このファイルを削除
broken_file: 注意! このファイルが壊れている! broken_file: 注意! このファイルが壊れている!
current_file: 現在のバージョン
delete_file: このファイルを削除
delete_file_cofirmation: 本当に「%{filename}」を削除しても宜しいですか? delete_file_cofirmation: 本当に「%{filename}」を削除しても宜しいですか?
digital_shipping: ダウンロードリンクを<strong>%{email}</strong>に送ります digital_shipping: ダウンロードリンクを<strong>%{email}</strong>に送ります
digital_versions: デジタル版
new_file: 新しいファイル
spree:
digitals:
unauthorized:
explained: This download link has expired.
unauthorized: Unauthorized
upload: アップロード
+7 -2
View File
@@ -3,8 +3,13 @@ Spree::Core::Engine.routes.draw do
resources :products do resources :products do
resources :digitals resources :digitals
end end
resources :orders do
member do
get :reset_digitals
end
end
end end
get '/digital/:secret', :to => 'digitals#show', :via => :get, :as => 'digital', :constraints => { :secret => /[a-zA-Z0-9]{30}/ } get '/digital/:secret', :to => 'digitals#show', :via => :get, :as => 'digital', :constraints => { :secret => /[a-zA-Z0-9]{30}/ }
end
end
+9 -9
View File
@@ -17,20 +17,20 @@ The idea is simple. You attach a file to a Product (or a Variant of this Product
* The file `views/order_mailer/confirm_email.text.erb` is the only thing that should need customization. If you are looking for HTML emails, [this branch of spree-html-email](http://github.com/iloveitaly/spree-html-email) supports spree_digital * The file `views/order_mailer/confirm_email.text.erb` is the only thing that should need customization. If you are looking for HTML emails, [this branch of spree-html-email](http://github.com/iloveitaly/spree-html-email) supports spree_digital
* A purchased product can be downloaded even if you disable the product immediately. You would have to remove the attached file in your admin section to prevent people from downloading purchased products. * A purchased product can be downloaded even if you disable the product immediately. You would have to remove the attached file in your admin section to prevent people from downloading purchased products.
* File are uploaded to `rails_root/private`. Make sure it's symlinked in case you're using Capistrano. If you want to change the upload path, [check out this gist](https://gist.github.com/3187793#file_spree_digital_path_change_decorator.rb) * File are uploaded to `rails_root/private`. Make sure it's symlinked in case you're using Capistrano. If you want to change the upload path, [check out this gist](https://gist.github.com/3187793#file_spree_digital_path_change_decorator.rb)
* You must add a `views/spree/digitals/unauthorized.html.erb` file to present an error message to the user if they exceed the download / days limit * You must add a `views/spree/digitals/unauthorized.html.erb` file to customize an error message to the user if they exceed the download / days limit
* We use send_file to send the files on download. See below for instructions on how to push file downloading off to nginx. * We use send_file to send the files on download. See below for instructions on how to push file downloading off to nginx.
## Installation ## Installation
Add this line to your gemfile: Add this line to your gemfile:
``` ```shell
gem 'spree_digital', :git => 'git://github.com/halo/spree_digital.git', :branch => 'master' gem 'spree_digital', :git => 'git://github.com/halo/spree_digital.git', :branch => 'master'
``` ```
The following terminal commands will copy the migration files to the corresponding directory in your Rails application and apply the migrations to your database. The following terminal commands will copy the migration files to the corresponding directory in your Rails application and apply the migrations to your database.
``` ```shell
bundle exec rails g spree_digital:install bundle exec rails g spree_digital:install
bundle exec rake db:migrate bundle exec rake db:migrate
``` ```
@@ -104,14 +104,14 @@ References:
Get the spree framework and spree_digital extension for it: Get the spree framework and spree_digital extension for it:
``` ```shell
git clone git://github.com/spree/spree.git git clone git://github.com/spree/spree.git
git clone git://github.com/halo/spree_digital.git git clone git://github.com/halo/spree_digital.git
``` ```
Go into the spree directory and run the bundle command: Go into the spree directory and run the bundle command:
``` ```shell
cd spree cd spree
bundle install bundle install
``` ```
@@ -120,19 +120,19 @@ Go into the spree_digital directory and do the same:
NOTE: At this point you may need to uncomment the stuff in the `Gemfile` before you can start developing and testing! NOTE: At this point you may need to uncomment the stuff in the `Gemfile` before you can start developing and testing!
``` ```shell
cd spree_digital cd spree_digital
bundle install bundle install
``` ```
Bring up the test application (you only need to do this whenever you fiddle around with the migrations) and then you can run the tests as you please. Bring up the test application (you only need to do this whenever you fiddle around with the migrations) and then you can run the tests as you please.
``` ```shell
rake test_app rake test_app
rake spec rake spec
``` ```
This link may be very helpful to you: "http://github.com/spree/spree":http://github.com/spree/spree This link may be very helpful to you: [http://github.com/spree/spree](http://github.com/spree/spree)
### Authors ### Authors
@@ -143,4 +143,4 @@ This link may be very helpful to you: "http://github.com/spree/spree":http://git
Copyright (c) 2011 funkensturm. Copyright (c) 2011 funkensturm.
Released under the MIT License Released under the MIT License
See [LICENSE](http://github.com/funkensturm/spree_digital/blob/master/LICENSE) See [LICENSE](http://github.com/funkensturm/spree_digital/blob/master/LICENSE)
+3
View File
@@ -2,5 +2,8 @@ FactoryGirl.define do
factory :digital, :class => Spree::Digital do |f| factory :digital, :class => Spree::Digital do |f|
# TODO good to assign variant association if no association is manually defined # TODO good to assign variant association if no association is manually defined
# f.variant { |p| p.association(:variant) } # f.variant { |p| p.association(:variant) }
attachment_content_type 'application/octet-stream'
attachment_file_name 'a_great_book.epub'
end end
end end
+1 -4
View File
@@ -1,16 +1,14 @@
ENV["RAILS_ENV"] = "test" ENV["RAILS_ENV"] = "test"
require File.expand_path("../dummy/config/environment.rb", __FILE__) require File.expand_path("../dummy/config/environment.rb", __FILE__)
require 'rspec/rails' require 'rspec/rails'
require 'database_cleaner' require 'database_cleaner'
require 'ffaker' require 'ffaker'
require 'shoulda-matchers' require 'shoulda-matchers'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each {|f| require f } Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each {|f| require f }
require 'spree/core/testing_support/factories' require 'spree/core/testing_support/factories'
require 'spree/core/testing_support/env'
require 'spree/core/testing_support/controller_requests' require 'spree/core/testing_support/controller_requests'
require 'spree/core/url_helpers' require 'spree/core/url_helpers'
@@ -21,7 +19,6 @@ RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods config.include FactoryGirl::Syntax::Methods
config.include Spree::Core::UrlHelpers config.include Spree::Core::UrlHelpers
config.include Spree::Core::TestingSupport::ControllerRequests config.include Spree::Core::TestingSupport::ControllerRequests
config.include Devise::TestHelpers, :type => :controller
config.use_transactional_fixtures = false config.use_transactional_fixtures = false
config.before(:each) do config.before(:each) do
+3 -2
View File
@@ -3,7 +3,7 @@ Gem::Specification.new do |s|
s.name = 'spree_digital' s.name = 'spree_digital'
s.version = '1.1.1' s.version = '1.1.1'
s.summary = '' s.summary = ''
s.description = 'Add digital download functionality to spree' s.description = 'Digital download functionality for spree'
s.authors = ['funkensturm', 'Michael Bianco'] s.authors = ['funkensturm', 'Michael Bianco']
s.email = ['info@cliffsidedev.com'] s.email = ['info@cliffsidedev.com']
s.homepage = 'http://www.funkensturm.com' s.homepage = 'http://www.funkensturm.com'
@@ -12,7 +12,8 @@ Gem::Specification.new do |s|
s.require_path = 'lib' s.require_path = 'lib'
s.requirements << 'none' s.requirements << 'none'
s.required_ruby_version = '>= 1.8.7' s.required_ruby_version = '>= 1.8.7'
s.add_dependency 'spree_core', '>= 1.1.0'
s.add_dependency 'spree_core', '~> 1.3.0'
# test suite # test suite
s.add_development_dependency 'shoulda-matchers' s.add_development_dependency 'shoulda-matchers'