refinerycms-stores 0.0.16 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/Gemfile +2 -0
  2. data/VERSION +1 -1
  3. data/app/assets/images/Excel.png +0 -0
  4. data/app/assets/images/PowerPoint.png +0 -0
  5. data/app/assets/images/Word.png +0 -0
  6. data/app/assets/images/audio-icon.png +0 -0
  7. data/app/assets/images/camera-icon.png +0 -0
  8. data/app/assets/images/html-icon.png +0 -0
  9. data/app/assets/images/muku-doc-font-128.png +0 -0
  10. data/app/assets/images/pdf-icon.png +0 -0
  11. data/app/assets/images/print-icon.png +0 -0
  12. data/app/assets/images/video-icon.png +0 -0
  13. data/app/assets/images/warning-icon.png +0 -0
  14. data/app/assets/images/zip_thumb.png +0 -0
  15. data/app/assets/stylesheets/refinery/refinerycms-stores.sass +66 -0
  16. data/app/controllers/refinery/customers/customers_controller.rb +35 -17
  17. data/app/controllers/refinery/orders/admin/orders_controller.rb +2 -1
  18. data/app/controllers/refinery/orders/orders_controller.rb +14 -9
  19. data/app/controllers/refinery/products/admin/digidownloads_controller.rb +39 -0
  20. data/app/controllers/refinery/products/admin/products_controller.rb +54 -4
  21. data/app/controllers/refinery/products/digidownloads_controller.rb +32 -0
  22. data/app/controllers/refinery/products/products_controller.rb +3 -0
  23. data/app/controllers/refinery/stores/stores_controller.rb +3 -2
  24. data/app/controllers/refinery/stores_application_controller.rb +6 -1
  25. data/app/helpers/refinery/stores/stores_helper.rb +4 -3
  26. data/app/models/refinery/addresses/address.rb +42 -0
  27. data/app/models/refinery/customers/customer.rb +7 -1
  28. data/app/models/refinery/orders/line_item.rb +10 -0
  29. data/app/models/refinery/orders/order.rb +59 -47
  30. data/app/models/refinery/products/digidownload.rb +181 -0
  31. data/app/models/refinery/products/product.rb +21 -1
  32. data/app/views/refinery/customers/customers/edit.html.haml +54 -0
  33. data/app/views/refinery/customers/{new.html.haml → customers/new.html.haml} +10 -3
  34. data/app/views/refinery/orders/admin/orders/_actions.html.haml +4 -0
  35. data/app/views/refinery/orders/admin/orders/_order.html.haml +13 -0
  36. data/app/views/refinery/orders/admin/orders/_orders.html.haml +2 -0
  37. data/app/views/refinery/orders/admin/orders/_records.html.haml +12 -0
  38. data/app/views/refinery/orders/admin/orders/_sortable_list.html.haml +4 -0
  39. data/app/views/refinery/orders/admin/orders/index.html.haml +5 -0
  40. data/app/views/refinery/orders/admin/orders/show.html.haml +80 -0
  41. data/app/views/refinery/orders/orders/edit.html.haml +2 -2
  42. data/app/views/refinery/orders/orders/index.html.haml +19 -4
  43. data/app/views/refinery/orders/orders/show.html.haml +68 -25
  44. data/app/views/refinery/products/admin/digidownloads/_actions.html.haml +19 -0
  45. data/app/views/refinery/products/admin/digidownloads/_digidownload.html.haml +13 -0
  46. data/app/views/refinery/products/admin/digidownloads/_digidownloads.html.haml +2 -0
  47. data/app/views/refinery/products/admin/digidownloads/_form.html.haml +41 -0
  48. data/app/views/refinery/products/admin/digidownloads/_records.html.haml +12 -0
  49. data/app/views/refinery/products/admin/digidownloads/_sortable_list.html.haml +4 -0
  50. data/app/views/refinery/products/admin/digidownloads/edit.html.haml +2 -0
  51. data/app/views/refinery/products/admin/digidownloads/index.html.haml +6 -0
  52. data/app/views/refinery/products/admin/digidownloads/new.html.haml +2 -0
  53. data/app/views/refinery/products/admin/products/_form.html.haml +98 -0
  54. data/app/views/refinery/products/digidownloads/index.html.haml +28 -0
  55. data/app/views/refinery/products/digidownloads/show.html.haml +39 -0
  56. data/app/views/refinery/products/products/show.html.haml +10 -9
  57. data/app/views/refinery/shared/_address.html.haml +18 -0
  58. data/app/views/refinery/{orders/orders → shared}/_address_form.html.haml +0 -0
  59. data/app/views/refinery/{stores/stores → shared}/_cart.html.haml +2 -2
  60. data/app/views/refinery/{stores/stores → shared}/_cart_item.html.haml +0 -0
  61. data/app/views/refinery/shared/_customer_head.html.haml +20 -0
  62. data/app/views/refinery/stores/admin/stores/_actions.html.haml +46 -0
  63. data/app/views/refinery/stores/stores/show.html.haml +1 -1
  64. data/config/locales/en.yml +17 -0
  65. data/config/routes.rb +24 -9
  66. data/db/migrate/3_create_orders_orders.rb +2 -0
  67. data/db/migrate/7_create_products_digidownloads.rb +33 -0
  68. data/lib/refinery/addresses.rb +11 -11
  69. data/lib/refinery/addresses/engine.rb +3 -3
  70. data/lib/refinery/auth_key.rb +44 -0
  71. data/lib/refinery/customers.rb +11 -11
  72. data/lib/refinery/customers/engine.rb +3 -3
  73. data/lib/refinery/orders.rb +1 -1
  74. data/lib/refinery/products.rb +2 -2
  75. data/lib/refinery/products/engine.rb +2 -2
  76. data/lib/refinery/stores.rb +1 -0
  77. data/lib/refinery/stores/authenticated_system.rb +25 -0
  78. data/lib/refinery/stores/engine.rb +19 -0
  79. data/lib/refinerycms-stores.rb +5 -2
  80. data/readme.md +32 -1
  81. data/refinerycms-stores.gemspec +54 -20
  82. metadata +87 -37
  83. data/app/views/refinery/customers/edit.html.haml +0 -17
  84. data/app/views/refinery/orders/admin/orders/_actions.html.erb +0 -25
  85. data/app/views/refinery/orders/admin/orders/_form.html.erb +0 -122
  86. data/app/views/refinery/orders/admin/orders/_order.html.erb +0 -20
  87. data/app/views/refinery/orders/admin/orders/_orders.html.erb +0 -2
  88. data/app/views/refinery/orders/admin/orders/_records.html.erb +0 -18
  89. data/app/views/refinery/orders/admin/orders/_sortable_list.html.erb +0 -5
  90. data/app/views/refinery/orders/admin/orders/edit.html.erb +0 -1
  91. data/app/views/refinery/orders/admin/orders/index.html.erb +0 -7
  92. data/app/views/refinery/orders/admin/orders/new.html.erb +0 -1
  93. data/app/views/refinery/products/admin/products/_form.html.erb +0 -127
  94. data/app/views/refinery/stores/admin/stores/_actions.html.erb +0 -57
  95. data/app/views/refinery/stores/stores/_customer_head.html.haml +0 -12
@@ -1,7 +1,8 @@
1
1
  module Refinery
2
2
  class StoresApplicationController < ::ApplicationController
3
-
4
3
 
4
+ after_filter :set_return_location
5
+
5
6
  private
6
7
 
7
8
  def find_cart
@@ -13,6 +14,10 @@ private
13
14
  @store = ::Refinery::Stores::Store.where(:is_active => true).order('position ASC').first
14
15
  end
15
16
 
17
+ def set_return_location
18
+ session[:return_to] = refinery.stores_stores_url()
19
+ end
20
+
16
21
 
17
22
  end # class
18
23
  end # mod
@@ -3,15 +3,16 @@ module Refinery
3
3
  module StoresHelper
4
4
 
5
5
  def pretty_customer_name( )
6
- user = refinery_current_user # might raise exception
6
+ user = current_refinery_user # might raise exception
7
+ return "please&hellip;".html_safe if user.nil?
7
8
 
8
9
  name = ( user.billing_address.nil? ?
9
10
  user.username :
10
11
  user.billing_address.first_name )
11
12
  return "Hi #{name}!"
12
13
 
13
- rescue NameError
14
- return "please signin"
14
+ rescue NameError
15
+ return "please&hellip;".html_safe
15
16
  end
16
17
 
17
18
  def is_user_signed_in?()
@@ -9,6 +9,48 @@ module Refinery
9
9
 
10
10
  belongs_to :order, :class_name => ::Refinery::Orders::Order
11
11
  belongs_to :customer, :class_name => ::Refinery::Customers::Customer
12
+
13
+ # ---------------------------------------------------------------------------
14
+ # update_addresses -- complex logic for dealing with 2 order addresses
15
+ # return bill_address, ship_address objects
16
+ # args:
17
+ # parent_obj is the object to which the addresses belong
18
+ # (either customer or order)
19
+ # params -- user input parameters
20
+ # ---------------------------------------------------------------------------
21
+ def self.update_addresses(parent_obj, params )
22
+ # if bill exists; update with parameters
23
+ # else create bill
24
+ if (bill_address = parent_obj.billing_address)
25
+ bill_address.update_attributes( params[:billing_address] )
26
+ else
27
+ bill_address = parent_obj.addresses.create(
28
+ params[:billing_address].merge( { :is_billing => true } )
29
+ )
30
+ end # if..then..else billing address setup
31
+
32
+ # continue if error free
33
+ if bill_address.errors.empty?
34
+
35
+ # does customer wants same address for both ?
36
+ ship_params = ( params[:use_billing] ?
37
+ params[:billing_address] :
38
+ params[:shipping_address]
39
+ ).merge( { :is_billing => false } )
40
+
41
+ if (ship_address = parent_obj.shipping_address)
42
+ ship_address.update_attributes( ship_params )
43
+ else
44
+ ship_address = parent_obj.addresses.create( ship_params )
45
+ end # if..then..else shiping address setup
46
+
47
+ else # need placeholder for re-editing the order
48
+ ship_address = parent_obj.addresses.build( params[:shipping_address] )
49
+ end # if no bill address errors
50
+
51
+ return bill_address, ship_address
52
+ end
53
+
12
54
 
13
55
  end
14
56
  end
@@ -4,6 +4,7 @@ module Refinery
4
4
 
5
5
  has_many :addresses, :class_name => ::Refinery::Addresses::Address
6
6
  has_many :orders, :class_name => ::Refinery::Orders::Order, :foreign_key => :order_customer_id
7
+ has_many :digidownloads, :through => :orders, :class_name => ::Refinery::Products::Digidownload
7
8
 
8
9
  has_one :billing_address, :class_name => ::Refinery::Addresses::Address,
9
10
  :conditions => { :is_billing => true, :order_id => nil }
@@ -11,7 +12,12 @@ module Refinery
11
12
  has_one :shipping_address, :class_name => ::Refinery::Addresses::Address,
12
13
  :conditions => { :is_billing => false, :order_id => nil }
13
14
 
14
-
15
+ Refinery::User.class_eval do
16
+ def self.find_by_parameterized_username( p_id )
17
+ Refinery::User.all.detect{|u| u.to_param == p_id }
18
+ end
19
+ end # class_eval do
20
+
15
21
  end
16
22
  end
17
23
  end
@@ -5,6 +5,7 @@ module Refinery
5
5
 
6
6
  belongs_to :order
7
7
  belongs_to :product, :class_name => ::Refinery::Products::Product
8
+ has_one :digidownload, :through => :product, :class_name => ::Refinery::Products::Digidownload
8
9
 
9
10
  # validates :order_status, :presence => true, :uniqueness => true
10
11
 
@@ -17,6 +18,15 @@ module Refinery
17
18
 
18
19
  end
19
20
 
21
+ def self.has_digidownloads?( order_id )
22
+ self.joins( :product, :digidownload ).
23
+ where(
24
+ "\"refinery_line_items\".order_id = #{order_id}" +
25
+ " AND \"refinery_products\".id = \"refinery_line_items\".product_id" +
26
+ " AND \"refinery_digidownloads\".product_id = \"refinery_products\".id ").
27
+ count > 0
28
+ end
29
+
20
30
  end # class LineItem
21
31
 
22
32
  end # module Orders
@@ -13,8 +13,11 @@ module Refinery
13
13
 
14
14
  has_many :addresses, :class_name => ::Refinery::Addresses::Address
15
15
  has_many :line_items
16
+ has_many :products, :through => :line_items, :class_name => ::Refinery::Products::Product
17
+ has_many :digidownloads, :through => :products, :class_name => ::Refinery::Products::Digidownload
16
18
 
17
19
  belongs_to :customer, :class_name => ::Refinery::Customers::Customer, :foreign_key => :order_customer_id
20
+ belongs_to :user, :class_name => ::Refinery::User, :foreign_key => :order_customer_id
18
21
 
19
22
  # belongs_to :shipping_type
20
23
  # belongs_to :discount
@@ -37,12 +40,21 @@ module Refinery
37
40
  # t.references :order_customer
38
41
  # t.string :order_status, :default => '', :null => false
39
42
  # t.text :order_notes
40
- # t.references :shipping_type
41
- # t.datetime :shipped_on
42
- # t.float :product_cost, :default => 0.0, :limit => 10
43
- # t.float :shipping_cost, :default => 0.0, :limit => 10
44
- # t.float :tax_cost, :default => 0.0, :limit => 5
45
-
43
+ # t.references :shipping_type
44
+ # t.datetime :shipped_on
45
+ # t.float :product_total, :default => 0.0, :limit => 10
46
+ # t.float :shipping_charges, :default => 0.0, :limit => 10
47
+ # t.float :tax_charges, :default => 0.0, :limit => 5
48
+ # t.string :cc_token
49
+ # t.string :cc_last4, :limit => 8
50
+ # t.string :cc_card_type, :limit => 32
51
+ # t.integer :cc_expiry_month
52
+ # t.integer :cc_expiry_year
53
+ # t.datetime :cc_purchased_on
54
+ # t.string :cc_confirmation_id
55
+ # t.boolean :has_digidownloads, :default => false
56
+ # t.boolean :has_registrations, :default => false
57
+ #
46
58
  # #########################################################################
47
59
  # AASM STATE MACHINE AREA ... try to keep generic!
48
60
  # #########################################################################
@@ -158,7 +170,8 @@ module Refinery
158
170
  # ---------------------------------------------------------------------------
159
171
  def handle_update( params )
160
172
  if checkout_started?
161
- bill_address, ship_address = update_addresses( params )
173
+ bill_address, ship_address =
174
+ ::Refinery::Addresses::Address.update_addresses( self, params )
162
175
  next_in_process! if bill_address.errors.empty? && ship_address.errors.empty?
163
176
  end
164
177
 
@@ -176,8 +189,9 @@ module Refinery
176
189
  # ---------------------------------------------------------------------------
177
190
  # checkout! -- checkout converts the cart into a fledgling order
178
191
  # ---------------------------------------------------------------------------
179
- def self.checkout!( cart )
192
+ def self.checkout!( cart, user )
180
193
  order = Order.new
194
+ order.user = user
181
195
 
182
196
  # convert cart.items to order.line_items
183
197
  cart.items.each do | item |
@@ -196,12 +210,19 @@ module Refinery
196
210
  # TODO: convert customer's billing/shipping addresses to order addresses
197
211
 
198
212
  # ---------------------------------------------------------------------------
213
+ # get_billship_addresses -- returns a billing and a shipping address
214
+ # args: customer obj
215
+ # tries to addresses first from order itself, then customer, else new
199
216
  # ---------------------------------------------------------------------------
200
- def get_billship_addresses()
201
- bill_address = self.billing_address || ::Refinery::Addresses::Address.new( :is_billing => true )
217
+ def get_billship_addresses( customer )
218
+
219
+ bill_address = self.billing_address ||
220
+ customer.billing_address ||
221
+ ::Refinery::Addresses::Address.new( :is_billing => true )
202
222
 
203
223
  # ship needs to be populated from bill if no ship already present
204
224
  ship_address = self.shipping_address ||
225
+ customer.shipping_address ||
205
226
  ::Refinery::Addresses::Address.new(
206
227
  :first_name => bill_address.first_name ,
207
228
  :last_name => bill_address.last_name ,
@@ -220,43 +241,6 @@ module Refinery
220
241
  end
221
242
 
222
243
 
223
- # ---------------------------------------------------------------------------
224
- # update_addresses -- complex logic for dealing with 2 order addresses
225
- # return bill_address, ship_address objects
226
- # ---------------------------------------------------------------------------
227
- def update_addresses( params )
228
- # if bill exists; update with parameters
229
- # else create bill
230
- if (bill_address = self.billing_address)
231
- bill_address.update_attributes( params[:billing_address] )
232
- else
233
- bill_address = self.addresses.create(
234
- params[:billing_address].merge( { :is_billing => true } )
235
- )
236
- end # if..then..else billing address setup
237
-
238
- # continue if error free
239
- if bill_address.errors.empty?
240
-
241
- # does customer wants same address for both ?
242
- ship_params = ( params[:use_billing] ?
243
- params[:billing_address] :
244
- params[:shipping_address]
245
- ).merge( { :is_billing => false } )
246
-
247
- if (ship_address = self.shipping_address)
248
- ship_address.update_attributes( ship_params )
249
- else
250
- ship_address = self.addresses.create( ship_params )
251
- end # if..then..else shiping address setup
252
-
253
- else # need placeholder for re-editing the order
254
- ship_address = self.addresses.build( params[:shipping_address] )
255
- end # if no bill address errors
256
-
257
- return bill_address, ship_address
258
- end
259
-
260
244
  # ---------------------------------------------------------------------------
261
245
  # ---------------------------------------------------------------------------
262
246
 
@@ -296,7 +280,31 @@ module Refinery
296
280
  end
297
281
 
298
282
  # ---------------------------------------------------------------------------
283
+ # any_digidownloads? -- return T if an order has any digidownloads in it
299
284
  # ---------------------------------------------------------------------------
285
+ def any_digidownloads?()
286
+ LineItem.has_digidownloads?( self.id )
287
+ end
288
+
289
+ # ---------------------------------------------------------------------------
290
+ # ---------------------------------------------------------------------------
291
+ def self.any_digidownloads?( user_id )
292
+ where( :has_digidownloads => true, :order_customer_id => user_id ).count > 0
293
+ end
294
+
295
+ # ---------------------------------------------------------------------------
296
+ # display_date -- returns a date for displaying for order
297
+ # ---------------------------------------------------------------------------
298
+ def display_date
299
+ ( self.shipped_on || self.cc_purchased_on || self.updated_at ).to_date
300
+ end
301
+
302
+ # ---------------------------------------------------------------------------
303
+ # ---------------------------------------------------------------------------
304
+
305
+ # ---------------------------------------------------------------------------
306
+ # ---------------------------------------------------------------------------
307
+
300
308
 
301
309
  private
302
310
 
@@ -323,6 +331,10 @@ module Refinery
323
331
  def order_completed()
324
332
  # create a confirmation code
325
333
  # kick off shipping process
334
+
335
+ self.has_digidownloads = any_digidownloads?
336
+ save
337
+
326
338
  end
327
339
 
328
340
  # ---------------------------------------------------------------------------
@@ -0,0 +1,181 @@
1
+ # *******************************************************************
2
+ # t.references :product, :null => false
3
+ # t.string :download_token, :unique => true, :null => false
4
+ # t.integer :download_completed, :default => 0
5
+ # t.integer :download_remaining, :default => 0
6
+ # t.integer :download_count, :default => 0
7
+ # t.integer :restrict_count
8
+ # t.integer :restrict_days
9
+ # t.boolean :is_defunct, :default => false
10
+ # t.string :doc_file_name
11
+ # t.string :doc_content_type
12
+ # t.integer :doc_file_size
13
+ # t.datetime :doc_updated_at
14
+ # t.string :preview_file_name
15
+ # t.string :preview_content_type
16
+ # t.integer :preview_file_size
17
+ # t.datetime :preview_updated_at
18
+ # *******************************************************************
19
+ module Refinery
20
+ module Products
21
+ class Digidownload < Refinery::Core::BaseModel
22
+ self.table_name = :refinery_digidownloads
23
+
24
+ has_attached_file :doc,
25
+ :storage => :s3,
26
+ :s3_credentials => "#{Rails.root}/config/s3.yml",
27
+ :s3_protocol => "https",
28
+ # :s3_permissions => :private,
29
+ :path => "/:style/downloads/:filename"
30
+
31
+ has_attached_file :preview,
32
+ :storage => :s3,
33
+ :s3_credentials => "#{Rails.root}/config/s3.yml",
34
+ :s3_protocol => "https",
35
+ :path => "/:style/previews/:filename"
36
+
37
+
38
+ belongs_to :product, :class_name => ::Refinery::Products::Product
39
+ has_one :line_item, :through => :product, :source => :line_items, :class_name => ::Refinery::Orders::LineItem
40
+ has_one :order, :through => :line_item, :class_name => ::Refinery::Orders::Order
41
+ has_one :user, :through => :order, :class_name => ::Refinery::User
42
+
43
+ before_create :generate_download_token
44
+ before_save :clean_restrictions
45
+
46
+ # #########################################################################
47
+
48
+ @@icon_hash = nil
49
+
50
+ # ------------------------------------------------------------------------------
51
+ # ------------------------------------------------------------------------------
52
+ # need accessor functions which look at restrict_count and/or restrict_date
53
+ # to determine if it's okay to download
54
+ # also to verify the token
55
+ # ------------------------------------------------------------------------------
56
+ # icon_hash= -- resets the icon hash to another set of image files
57
+ # ------------------------------------------------------------------------------
58
+ def self.icon_hash=(icon_hash)
59
+ @@icon_hash = icon_hash
60
+ end
61
+
62
+ # ------------------------------------------------------------------------------
63
+ # icon_hash -- returns the icon hash; inits if first time
64
+ # ------------------------------------------------------------------------------
65
+ def self.icon_hash()
66
+ @@icon_hash ||= {
67
+ :powerpoint => "PowerPoint.png",
68
+ :excel => "Excel.png",
69
+ :word => "Word.png",
70
+ :pdf => "pdf-icon.png",
71
+ :zip => "zip_thumb.png",
72
+ :text => "muku-doc-font-128.png",
73
+ :audio => "audio-icon.png",
74
+ :video => "video-icon.png",
75
+ :image => "camera-icon.png",
76
+ :html => "html-icon.png",
77
+
78
+ :unknown => "warning-icon.png"
79
+ }
80
+ end
81
+
82
+ # ------------------------------------------------------------------------------
83
+ # category_to_icon -- returns an icon image name for a given category
84
+ # args:
85
+ # category -- symbol for category
86
+ # ------------------------------------------------------------------------------
87
+ def self.category_to_icon(category)
88
+ return icon_hash[category] || icon_hash[:unknown]
89
+ end
90
+
91
+ # ------------------------------------------------------------------------------
92
+ # to_category -- returns a category type (symbol) for the content-type
93
+ # args:
94
+ # content_type -- string in standard MIME type
95
+ # ------------------------------------------------------------------------------
96
+ def self.to_category(content_type)
97
+
98
+ return :unknown if content_type.blank?
99
+
100
+ tokens = content_type.split("/")
101
+ category = tokens[0].to_sym
102
+ if category == :application
103
+ case tokens[1]
104
+ when /ms-excel|spreadsheet/ then category = :excel
105
+ when /ms-?word|wordprocessing/ then category = :word
106
+ when /ms-powerpoint|presentation/ then category = :powerpoint
107
+ when /wordperfect/ then category = :word
108
+ when /pdf/ then category = :pdf
109
+ when /zip/ then category = :zip
110
+ else
111
+ category = :unknown
112
+ end # case
113
+ elsif category == :text
114
+ case tokens[1]
115
+ when /html/ then category = :html
116
+ end # case
117
+ end # application or text handling
118
+
119
+ return category
120
+ end
121
+
122
+ # ------------------------------------------------------------------------------
123
+ # ------------------------------------------------------------------------------
124
+ def digi_select_list
125
+ return ::Refinery::Products::Product.digi_select_list if self.product.nil?
126
+ return [ ["no product selected",nil], [self.product.name, self.product_id] ]
127
+ end
128
+
129
+ # ------------------------------------------------------------------------------
130
+ # ------------------------------------------------------------------------------
131
+ def to_category()
132
+ Digidownload.to_category(self.doc_content_type)
133
+ end
134
+
135
+ # ------------------------------------------------------------------------------
136
+ # to_player -- returns audio/video html if playable media
137
+ # ------------------------------------------------------------------------------
138
+ def to_player()
139
+ case to_category
140
+ when :audio then "<audio src='#{self.doc.url}' controls preload='auto' autobuffer></audio>"
141
+ when :video then "<video src='#{self.doc.url}' controls autobuffer></video>"
142
+ else
143
+ "" # returns nothing
144
+ end # case
145
+ end
146
+
147
+ # ------------------------------------------------------------------------------
148
+ # ------------------------------------------------------------------------------
149
+ def generate_download_token
150
+ self.download_token = ::Refinery::AuthKey.make_token
151
+ end
152
+
153
+ # ------------------------------------------------------------------------------
154
+ # clean_restrictions -- always ensure that restrictions are valid
155
+ # ------------------------------------------------------------------------------
156
+ def clean_restrictions
157
+ self.restrict_count = nil unless self.restrict_count.nil? || self.restrict_count > 0
158
+ self.restrict_days = nil unless self.restrict_days.nil? || self.restrict_days > 0
159
+ end
160
+
161
+ # ------------------------------------------------------------------------------
162
+ # ------------------------------------------------------------------------------
163
+
164
+ # ------------------------------------------------------------------------------
165
+ # ------------------------------------------------------------------------------
166
+
167
+ # ------------------------------------------------------------------------------
168
+ # ------------------------------------------------------------------------------
169
+
170
+ # ------------------------------------------------------------------------------
171
+ # ------------------------------------------------------------------------------
172
+
173
+ # ------------------------------------------------------------------------------
174
+ # ------------------------------------------------------------------------------
175
+
176
+
177
+ # #########################################################################
178
+
179
+ end # class
180
+ end # mod
181
+ end # mod