radiant-shop-extension 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. data/.gitignore +6 -0
  2. data/Gemfile +26 -0
  3. data/Gemfile.lock +75 -0
  4. data/HISTORY.md +77 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.md +26 -0
  7. data/Rakefile +141 -0
  8. data/VERSION +1 -0
  9. data/app/.DS_Store +0 -0
  10. data/app/controllers/admin/shop/categories_controller.rb +206 -0
  11. data/app/controllers/admin/shop/customers_controller.rb +137 -0
  12. data/app/controllers/admin/shop/orders_controller.rb +171 -0
  13. data/app/controllers/admin/shop/products/images_controller.rb +144 -0
  14. data/app/controllers/admin/shop/products_controller.rb +217 -0
  15. data/app/controllers/admin/shops_controller.rb +9 -0
  16. data/app/controllers/shop/categories_controller.rb +49 -0
  17. data/app/controllers/shop/line_items_controller.rb +165 -0
  18. data/app/controllers/shop/orders_controller.rb +16 -0
  19. data/app/controllers/shop/products_controller.rb +48 -0
  20. data/app/models/form_checkout.rb +245 -0
  21. data/app/models/shop_address.rb +13 -0
  22. data/app/models/shop_addressable.rb +11 -0
  23. data/app/models/shop_category.rb +85 -0
  24. data/app/models/shop_category_page.rb +7 -0
  25. data/app/models/shop_customer.rb +27 -0
  26. data/app/models/shop_line_item.rb +32 -0
  27. data/app/models/shop_order.rb +108 -0
  28. data/app/models/shop_payment.rb +6 -0
  29. data/app/models/shop_payment_method.rb +5 -0
  30. data/app/models/shop_product.rb +87 -0
  31. data/app/models/shop_product_attachment.rb +30 -0
  32. data/app/models/shop_product_page.rb +7 -0
  33. data/app/views/.DS_Store +0 -0
  34. data/app/views/admin/.DS_Store +0 -0
  35. data/app/views/admin/pages/_shop_category.html.haml +4 -0
  36. data/app/views/admin/pages/_shop_product.html.haml +4 -0
  37. data/app/views/admin/shop/categories/edit.html.haml +12 -0
  38. data/app/views/admin/shop/categories/edit/_fields.html.haml +28 -0
  39. data/app/views/admin/shop/categories/edit/_head.html.haml +2 -0
  40. data/app/views/admin/shop/categories/edit/_meta.html.haml +7 -0
  41. data/app/views/admin/shop/categories/edit/_part.html.haml +3 -0
  42. data/app/views/admin/shop/categories/edit/_popup.html.haml +3 -0
  43. data/app/views/admin/shop/categories/edit/meta/_handle.html.haml +5 -0
  44. data/app/views/admin/shop/categories/edit/meta/_layouts.html.haml +10 -0
  45. data/app/views/admin/shop/categories/edit/parts/_description.html.haml +1 -0
  46. data/app/views/admin/shop/categories/index/_category.html.haml +16 -0
  47. data/app/views/admin/shop/categories/new.html.haml +10 -0
  48. data/app/views/admin/shop/categories/remove.html.haml +12 -0
  49. data/app/views/admin/shop/customers/index.html.haml +36 -0
  50. data/app/views/admin/shop/orders/index.html.haml +33 -0
  51. data/app/views/admin/shop/products/edit.html.haml +14 -0
  52. data/app/views/admin/shop/products/edit/_fields.html.haml +38 -0
  53. data/app/views/admin/shop/products/edit/_head.html.haml +2 -0
  54. data/app/views/admin/shop/products/edit/_image.html.haml +12 -0
  55. data/app/views/admin/shop/products/edit/_meta.html.haml +8 -0
  56. data/app/views/admin/shop/products/edit/_part.html.haml +3 -0
  57. data/app/views/admin/shop/products/edit/_popup.html.haml +3 -0
  58. data/app/views/admin/shop/products/edit/buttons/_browse_images.html.haml +1 -0
  59. data/app/views/admin/shop/products/edit/buttons/_new_image.html.haml +1 -0
  60. data/app/views/admin/shop/products/edit/meta/_category.html.haml +5 -0
  61. data/app/views/admin/shop/products/edit/meta/_sku.html.haml +5 -0
  62. data/app/views/admin/shop/products/edit/parts/_description.html.haml +1 -0
  63. data/app/views/admin/shop/products/edit/parts/_images.html.haml +5 -0
  64. data/app/views/admin/shop/products/edit/popups/_browse_images.html.haml +6 -0
  65. data/app/views/admin/shop/products/edit/popups/_new_image.html.haml +18 -0
  66. data/app/views/admin/shop/products/index.html.haml +10 -0
  67. data/app/views/admin/shop/products/index/_bottom.html.haml +5 -0
  68. data/app/views/admin/shop/products/index/_product.html.haml +13 -0
  69. data/app/views/admin/shop/products/new.html.haml +10 -0
  70. data/app/views/admin/shop/products/remove.html.haml +12 -0
  71. data/app/views/shop/categories/show.html.haml +1 -0
  72. data/app/views/shop/orders/show.html.haml +1 -0
  73. data/app/views/shop/products/index.html.haml +1 -0
  74. data/app/views/shop/products/show.html.haml +1 -0
  75. data/config/locales/en.yml +50 -0
  76. data/config/routes.rb +38 -0
  77. data/config/shop_cart.yml +16 -0
  78. data/cucumber.yml +1 -0
  79. data/db/migrate/20100311053701_initial.rb +153 -0
  80. data/db/migrate/20100520033059_create_layouts.rb +119 -0
  81. data/db/migrate/20100903122123_create_forms.rb +44 -0
  82. data/db/migrate/20100908063639_create_snippets.rb +22 -0
  83. data/features/support/env.rb +16 -0
  84. data/features/support/paths.rb +14 -0
  85. data/lib/shop/controllers/application_controller.rb +39 -0
  86. data/lib/shop/controllers/site_controller.rb +12 -0
  87. data/lib/shop/interface/products.rb +49 -0
  88. data/lib/shop/models/image.rb +14 -0
  89. data/lib/shop/models/page.rb +14 -0
  90. data/lib/shop/tags/address.rb +40 -0
  91. data/lib/shop/tags/cart.rb +49 -0
  92. data/lib/shop/tags/category.rb +83 -0
  93. data/lib/shop/tags/core.rb +12 -0
  94. data/lib/shop/tags/helpers.rb +142 -0
  95. data/lib/shop/tags/item.rb +109 -0
  96. data/lib/shop/tags/product.rb +109 -0
  97. data/lib/shop/tags/responses.rb +34 -0
  98. data/lib/tasks/shop_extension_tasks.rake +54 -0
  99. data/mockups/balsamiq/products-retro_fun_tshirt-more.bmml +0 -0
  100. data/mockups/balsamiq/products-retro_fun_tshirt.bmml +0 -0
  101. data/public/images/admin/extensions/shop/products/sort.png +0 -0
  102. data/public/javascripts/admin/extensions/shop/products/edit.js +115 -0
  103. data/public/javascripts/admin/extensions/shop/products/index.js +65 -0
  104. data/public/stylesheets/sass/admin/extensions/shop/edit.sass +86 -0
  105. data/public/stylesheets/sass/admin/extensions/shop/products/edit.sass +158 -0
  106. data/public/stylesheets/sass/admin/extensions/shop/products/index.sass +129 -0
  107. data/radiant-shop-extension.gemspec +245 -0
  108. data/shop_extension.rb +62 -0
  109. data/spec/controllers/admin/shop/categories_controller_spec.rb +443 -0
  110. data/spec/controllers/admin/shop/products/images_controller_spec.rb +477 -0
  111. data/spec/controllers/admin/shop/products_controller_spec.rb +394 -0
  112. data/spec/controllers/admin/shops_controller_spec.rb +19 -0
  113. data/spec/controllers/shop/categories_controller_spec.rb +42 -0
  114. data/spec/controllers/shop/line_items_controller_spec.rb +256 -0
  115. data/spec/controllers/shop/orders_controller_specs.rb +37 -0
  116. data/spec/controllers/shop/products_controller_spec.rb +51 -0
  117. data/spec/datasets/forms.rb +153 -0
  118. data/spec/datasets/images.rb +13 -0
  119. data/spec/datasets/shop_addresses.rb +27 -0
  120. data/spec/datasets/shop_categories.rb +13 -0
  121. data/spec/datasets/shop_line_items.rb +9 -0
  122. data/spec/datasets/shop_orders.rb +21 -0
  123. data/spec/datasets/shop_products.rb +34 -0
  124. data/spec/helpers/nested_tag_helper.rb +33 -0
  125. data/spec/lib/shop/models/image_spec.rb +28 -0
  126. data/spec/lib/shop/models/page_spec.rb +38 -0
  127. data/spec/lib/shop/tags/address_spec.rb +196 -0
  128. data/spec/lib/shop/tags/cart_spec.rb +169 -0
  129. data/spec/lib/shop/tags/category_spec.rb +201 -0
  130. data/spec/lib/shop/tags/core_spec.rb +16 -0
  131. data/spec/lib/shop/tags/helpers_spec.rb +381 -0
  132. data/spec/lib/shop/tags/item_spec.rb +313 -0
  133. data/spec/lib/shop/tags/product_spec.rb +334 -0
  134. data/spec/matchers/comparison.rb +72 -0
  135. data/spec/matchers/render_matcher.rb +33 -0
  136. data/spec/models/form_checkout_spec.rb +376 -0
  137. data/spec/models/shop_category_page_spec.rb +10 -0
  138. data/spec/models/shop_category_spec.rb +58 -0
  139. data/spec/models/shop_line_item_spec.rb +42 -0
  140. data/spec/models/shop_order_spec.rb +228 -0
  141. data/spec/models/shop_product_attachment_spec.rb +72 -0
  142. data/spec/models/shop_product_page_spec.rb +10 -0
  143. data/spec/models/shop_product_spec.rb +135 -0
  144. data/spec/spec.opts +6 -0
  145. data/spec/spec_helper.rb +22 -0
  146. data/vendor/plugins/acts_as_list/README +23 -0
  147. data/vendor/plugins/acts_as_list/init.rb +3 -0
  148. data/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb +256 -0
  149. data/vendor/plugins/acts_as_list/test/list_test.rb +332 -0
  150. data/vendor/plugins/json_fields/.gitignore +3 -0
  151. data/vendor/plugins/json_fields/MIT-LICENSE +20 -0
  152. data/vendor/plugins/json_fields/README.rdoc +65 -0
  153. data/vendor/plugins/json_fields/Rakefile +55 -0
  154. data/vendor/plugins/json_fields/init.rb +2 -0
  155. data/vendor/plugins/json_fields/lib/json_fields.rb +99 -0
  156. data/vendor/plugins/json_fields/spec/lib/json_fields_spec.rb +124 -0
  157. data/vendor/plugins/json_fields/spec/spec.opts +6 -0
  158. data/vendor/plugins/json_fields/spec/spec_helper.rb +29 -0
  159. data/vendor/plugins/json_fields/spec/test_models.rb +12 -0
  160. metadata +324 -0
@@ -0,0 +1,108 @@
1
+ class ShopOrder < ActiveRecord::Base
2
+
3
+ has_many :payments, :class_name => 'ShopPayment', :dependent => :destroy
4
+ has_many :line_items, :class_name => 'ShopLineItem', :dependent => :destroy
5
+
6
+ belongs_to :billing, :class_name => 'ShopAddress'
7
+ belongs_to :shipping, :class_name => 'ShopAddress'
8
+ belongs_to :created_by, :class_name => 'User'
9
+ belongs_to :updated_by, :class_name => 'User'
10
+ belongs_to :customer, :class_name => 'ShopCustomer', :foreign_key => :shop_customer_id
11
+
12
+ accepts_nested_attributes_for :line_items, :reject_if => :all_blank
13
+ accepts_nested_attributes_for :payments, :reject_if => :all_blank
14
+ accepts_nested_attributes_for :billing, :reject_if => :all_blank
15
+ accepts_nested_attributes_for :shipping, :reject_if => :all_blank
16
+
17
+ def add!(id, quantity = nil, type = nil)
18
+ quantity ||= 1
19
+ type ||= 'ShopProduct'
20
+
21
+ if self.line_items.exists?({:item_id => id, :item_type => type})
22
+ line_item = self.line_items.first(:conditions => {:item_id => id, :item_type => type})
23
+ quantity = line_item.quantity + quantity.to_i
24
+
25
+ self.update!(line_item.id, quantity)
26
+ else
27
+ self.line_items.create!({:item_id => id, :item_type => type, :quantity => quantity})
28
+ end
29
+
30
+ true
31
+ end
32
+
33
+ def update!(id, quantity = 1)
34
+ quantity = quantity.to_i
35
+ if quantity <= 0
36
+ remove!(id)
37
+ else
38
+ line_item = self.line_items.find(id)
39
+ line_item.update_attribute(:quantity, quantity)
40
+ end
41
+
42
+ true
43
+ end
44
+
45
+ def remove!(id)
46
+ line_item = line_items.find(id)
47
+ line_item.destroy
48
+
49
+ true
50
+ end
51
+
52
+ def clear!
53
+ line_items.destroy_all
54
+ end
55
+
56
+ def quantity
57
+ self.line_items.sum(:quantity)
58
+ end
59
+
60
+ def price
61
+ price = 0
62
+ self.line_items.map { |l| price += l.price }
63
+ price
64
+ end
65
+
66
+ def weight
67
+ weight = 0
68
+ self.line_items.map { |l| weight += l.weight }
69
+ weight
70
+ end
71
+
72
+ def new?
73
+ self.status === 'new'
74
+ end
75
+
76
+ def paid?
77
+ self.status === 'paid'
78
+ end
79
+
80
+ def shipped?
81
+ self.status === 'shipped'
82
+ end
83
+
84
+ class << self
85
+ def search(search = nil)
86
+ unless search.blank?
87
+ search = search.downcase
88
+
89
+ queries = []
90
+ queries << 'LOWER(status) LIKE (:term)'
91
+
92
+ sql = queries.join(' OR ')
93
+
94
+ # This looks tricky, but not subject to sql injection :-)
95
+ conditions = [sql, {:term => "%#{search}%" }]
96
+ else
97
+ conditions = []
98
+ end
99
+
100
+ all(:conditions => conditions)
101
+ end
102
+
103
+ def params
104
+ [ :id, :notes, :status ]
105
+ end
106
+ end
107
+
108
+ end
@@ -0,0 +1,6 @@
1
+ class ShopPayment < ActiveRecord::Base
2
+
3
+ belongs_to :order, :class_name => 'ShopOrder', :foreign_key => :shop_order_id
4
+ belongs_to :method, :class_name => 'ShopPaymentMethod', :foreign_key => :shop_payment_method_id
5
+
6
+ end
@@ -0,0 +1,5 @@
1
+ class ShopPaymentMethod < ActiveRecord::Base
2
+
3
+ has_many :payments, :class_name => 'ShopPayment'
4
+
5
+ end
@@ -0,0 +1,87 @@
1
+ class ShopProduct < ActiveRecord::Base
2
+
3
+ belongs_to :created_by, :class_name => 'User'
4
+ belongs_to :updated_by, :class_name => 'User'
5
+ belongs_to :category, :class_name => 'ShopCategory', :foreign_key => :shop_category_id
6
+
7
+ has_many :line_items, :class_name => 'ShopLineItem', :as => :item, :dependent => :destroy
8
+ has_many :orders, :class_name => 'ShopOrder', :through => :line_items
9
+ has_many :attachments, :class_name => 'ShopProductAttachment'
10
+ has_many :images, :through => :attachments, :uniq => true
11
+
12
+ default_scope :joins => :category, :order => 'shop_categories.position, shop_products.position ASC'
13
+
14
+ before_validation :set_sku, :filter_sku
15
+
16
+ validates_presence_of :name, :sku, :category
17
+
18
+ validates_uniqueness_of :name, :scope => 'shop_category_id'
19
+
20
+ validates_uniqueness_of :sku
21
+
22
+ validates_numericality_of :price, :greater_than => 0.00, :allow_nil => true, :precisions => 2
23
+
24
+ acts_as_list :scope => :shop_category
25
+
26
+ def slug
27
+ "/#{self.slug_prefix}/#{self.category.handle}/#{self.sku}"
28
+ end
29
+
30
+ def layout
31
+ self.category.product_layout
32
+ end
33
+
34
+ def available_images
35
+ Image.all - self.images
36
+ end
37
+
38
+ def slug_prefix
39
+ Radiant::Config['shop.url_prefix']
40
+ end
41
+
42
+ class << self
43
+
44
+ def search(search)
45
+ unless search.blank?
46
+ queries = []
47
+ queries << 'LOWER(title) LIKE (:term)'
48
+ queries << 'LOWER(sku) LIKE (:term)'
49
+ queries << 'LOWER(description) LIKE (:term)'
50
+
51
+ sql = queries.join(" OR ")
52
+ conditions = [sql, {:term => "%#{search.downcase}%" }]
53
+ else
54
+ conditions = []
55
+ end
56
+
57
+ self.all({ :conditions => conditions })
58
+ end
59
+
60
+ def attrs
61
+ [ :id, :name, :price, :sku, :description, :created_at, :updated_at ]
62
+ end
63
+
64
+ def params
65
+ {
66
+ :include => { :category => { :only => ShopCategory.attrs } },
67
+ :only => ShopProduct.attrs
68
+ }
69
+ end
70
+
71
+ end
72
+
73
+ private
74
+
75
+ def set_sku
76
+ unless self.name.nil?
77
+ self.sku = self.name if self.sku.nil? or self.sku.empty?
78
+ end
79
+ end
80
+
81
+ def filter_sku
82
+ unless self.name.nil?
83
+ self.sku = self.sku.downcase.gsub(/[^-a-z0-9~\s\.:;+=_]/, '').strip.gsub(/[\s\.:;=+~]+/, '_')
84
+ end
85
+ end
86
+
87
+ end
@@ -0,0 +1,30 @@
1
+ class ShopProductAttachment < ActiveRecord::Base
2
+
3
+ default_scope :order => 'shop_product_attachments.position ASC'
4
+
5
+ belongs_to :product, :class_name => 'ShopProduct', :foreign_key => :shop_product_id
6
+ belongs_to :image
7
+
8
+ acts_as_list :scope => :shop_product
9
+
10
+ def url(*params)
11
+ image.url(*params) rescue nil
12
+ end
13
+
14
+ def title(*params)
15
+ image.title(*params) rescue nil
16
+ end
17
+
18
+ def caption(*params)
19
+ image.caption(*params) rescue nil
20
+ end
21
+
22
+ class << self
23
+
24
+ def params
25
+ [ :id, :title, :caption, :image_file_name, :image_content_type, :image_file_size ]
26
+ end
27
+
28
+ end
29
+
30
+ end
@@ -0,0 +1,7 @@
1
+ class ShopProductPage < Page
2
+
3
+ def cache?
4
+ return false
5
+ end
6
+
7
+ end
Binary file
Binary file
@@ -0,0 +1,4 @@
1
+ - if @page.class_name == "ShopCategoryPage"
2
+ %p
3
+ %label{:for => 'page_shop_category_id'} Category
4
+ = collection_select :page, :shop_category_id, ShopCategory.all, :id, :name
@@ -0,0 +1,4 @@
1
+ - if @page.class_name == "ShopProductPage"
2
+ %p
3
+ %label{:for => 'page_shop_product_id'} Product
4
+ = collection_select :page, :shop_product_id, ShopProduct.all, :id, :name
@@ -0,0 +1,12 @@
1
+ - @page_title = @shop_category.name + ' - ' + default_page_title
2
+
3
+ - render_region :main do |main|
4
+ - main.edit_header do
5
+ %h1
6
+ = @shop_category.name
7
+ = render :partial => 'admin/shop/categories/edit/head'
8
+ - main.edit_form do
9
+ - form_for :shop_category, @shop_category, :url => admin_shop_category_path(@shop_category), :html => {:method => :put, :multipart => true, :id => 'edit_shop_category', 'data-onsubmit_status'=>"Saving Changes&#8230;"} do |f|
10
+ = render :partial => 'admin/shop/categories/edit/fields', :object => f
11
+ - main.edit_popups do
12
+ = render :partial => 'admin/shop/categories/edit/popup'
@@ -0,0 +1,28 @@
1
+ = render_region :form_top
2
+
3
+ - render_region :form do |form|
4
+ - form.edit_name do
5
+ %p.title
6
+ %label{:for => 'shop_category_name'}= t('name')
7
+ = fields.text_field :name, :class => 'textbox', :maxlenth => 255
8
+
9
+ - form.edit_extended_metadata do
10
+ = render :partial => 'admin/shop/categories/edit/meta', :locals => { :fields => fields }
11
+
12
+ - form.edit_content do
13
+ #tab_control
14
+ #tabs.tabs
15
+ #tab_toolbar
16
+ #pages.pages
17
+ = hidden_field_tag 'page_part_index_field' #important
18
+ = render :partial => 'admin/shop/categories/edit/part', :collection => @parts
19
+
20
+ - render_region :form_bottom do |form_bottom|
21
+ - form_bottom.edit_buttons do
22
+ %p.buttons{:style=>"clear: left"}
23
+ = save_model_button(@shop_category)
24
+ = save_model_and_continue_editing_button(@shop_category)
25
+ = t('or')
26
+ = link_to t('cancel'), admin_shop_products_url
27
+ - form_bottom.edit_timestamp do
28
+ = updated_stamp @shop_category
@@ -0,0 +1,2 @@
1
+ - @buttons.each do |button|
2
+ = render :partial => 'admin/shop/categories/edit/buttons/' + button
@@ -0,0 +1,7 @@
1
+ .drawer
2
+ .drawer_contents#attributes
3
+ %table.fieldset
4
+ - @meta.each do |meta|
5
+ = render :partial => 'admin/shop/categories/edit/meta/' + meta, :locals => { :f => fields }
6
+ .drawer_handle
7
+ %a.toggle{:href=>'#attributes', :rel=>"toggle[attributes]", :class=>"#{(meta_errors? ? 'less' : 'more')}"}= meta_label
@@ -0,0 +1,3 @@
1
+ .page{:id => "shop_category_#{part.to_slug}", 'data-caption'=>h(part)}
2
+ .part{:id => "shop_category-part-#{part.to_slug}"}
3
+ = render :partial => "admin/shop/categories/edit/parts/#{part}", :locals => { :part => part }
@@ -0,0 +1,3 @@
1
+ - @popups.each do |popup|
2
+ .popup{ :id => "#{popup}_popup"}
3
+ = render :partial => "admin/shop/categories/edit/popups/#{popup}"
@@ -0,0 +1,5 @@
1
+ %tr
2
+ %th.label
3
+ %label{:for=>"shop_category[handle]"}= t('handle')
4
+ %td.field
5
+ = f.text_field :handle, :class =>'textbox'
@@ -0,0 +1,10 @@
1
+ %tr
2
+ %th.label
3
+ %label{:for=>"shop_category[layout]"}= t('custom_layout')
4
+ %td.field
5
+ = f.collection_select :layout_id, Layout.all, :id, :name
6
+ %tr
7
+ %th.label
8
+ %label{:for=>"shop_category[product_layout]"}= t('custom_product_layout')
9
+ %td.field
10
+ = f.collection_select :product_layout_id, Layout.all, :id, :name
@@ -0,0 +1 @@
1
+ ~ text_area_tag 'shop_category[description]', @shop_category.description, :class => "textarea large", :style => "width: 100%", :id => "shop_category_#{part.to_slug}_content"
@@ -0,0 +1,16 @@
1
+ %li.category{:id => "shop_category_#{category.id}", :'data-id' => category.id }
2
+ .attributes
3
+ %span.handle
4
+ - render_region :category_attributes do |region|
5
+ - region.category_name do
6
+ %span.name.attribute= link_to category.name, edit_admin_shop_category_path(category)
7
+ - region.category_description do
8
+ %span.sku.attribute= category.handle
9
+ - region.category_modify do
10
+ .modify
11
+ %span.add_child= link_to t('add_product'), new_admin_shop_category_product_path(category)
12
+ %span.remove= link_to t('remove'), remove_admin_shop_category_path(category)
13
+ - render_region :category_products do |region|
14
+ - region.category_products do
15
+ %ul.products{ :id => "shop_category_#{category.id}_products", :'data-id' => category.id }
16
+ = render :partial => '/admin/shop/products/index/product', :collection => category.products
@@ -0,0 +1,10 @@
1
+ - render_region :main do |main|
2
+ - main.edit_header do
3
+ %h1
4
+ = t('new_category')
5
+ = render :partial => 'admin/shop/categories/edit/head'
6
+ - main.edit_form do
7
+ - form_for :shop_category, @shop_category, :url => admin_shop_categories_path, :html => {:id => 'new_shop_category', :multipart => true, 'data-onsubmit_status'=>"Creating Category&#8230;"} do |f|
8
+ = render :partial => 'admin/shop/categories/edit/fields', :object => f
9
+ - main.edit_popups do
10
+ = render :partial => 'admin/shop/categories/edit/popup'
@@ -0,0 +1,12 @@
1
+ %h1
2
+ = t('remove_category')
3
+
4
+ %p
5
+ = t('text.remove_category.warning')
6
+
7
+ - form_for [:admin, @shop_category.becomes(ShopCategory)], :html => {:method => :delete, 'data-onsubmit_status'=>"Removing Category&#8230;"} do
8
+
9
+ %p.buttons
10
+ %input.button{:type=>"submit", :value => t('delete_category') }/
11
+ = t('or')
12
+ = link_to t('cancel'), admin_shop_categories_path
@@ -0,0 +1,36 @@
1
+ Add Customer
2
+ - form_for [:admin, @shop_customer] do |f|
3
+ %p
4
+ = f.label :name, 'Name:'
5
+ = f.text_field :name
6
+ %p
7
+ = f.label :email, 'Email:'
8
+ = f.text_field :email
9
+ %p
10
+ = f.label :login, 'Login:'
11
+ = f.text_field :login
12
+ %p
13
+ = f.label :password, "Password"
14
+ = f.password_field "password", :value => "", :size => 15, :maxlength => 40
15
+ %p
16
+ = f.label :password_confirmation, "Confirm Password"
17
+ = f.password_field "password_confirmation", :value => "", :size => 15, :maxlength => 40
18
+ %p
19
+ = f.label :reference, 'Reference:'
20
+ = f.text_field :reference
21
+ %p
22
+ = f.label :Organization, 'Organization:'
23
+ = f.text_field :organization
24
+ %p
25
+ = f.submit "Save"
26
+
27
+
28
+ - if @shop_customers.empty?
29
+ %p There are no customers.
30
+ - else
31
+ %form
32
+ - @shop_customers.each do |customer|
33
+ %p
34
+ = customer.name
35
+ = link_to "Add Order", "", :style => "color: blue;"
36
+ = link_to "Delete Customer", "/admin/shop/customers/#{customer.id}", :confirm => "Are you sure?", :method => :delete, :style => "color: blue;"
@@ -0,0 +1,33 @@
1
+ Add Order
2
+ - form_for [:admin, @shop_order] do |f|
3
+ %p
4
+ = f.label :customer, 'Customer:'
5
+ = f.select :customer_id, ShopCustomer.scoped_by_access('front').all.collect {|c| [c.name, c.id]}
6
+ %p
7
+ = f.label :email, 'Status:'
8
+ = f.text_field :status
9
+
10
+ %p
11
+ - f.fields_for :line_items do |li_f|
12
+ = li_f.label :product
13
+ = li_f.select :shop_product_id, ShopProduct.all.collect {|p| [p.title, p.id]}
14
+ = li_f.label :quantity
15
+ = li_f.text_field :quantity
16
+
17
+ - unless li_f.object.new_record?
18
+ <%= li_f.check_box '_delete'
19
+ <%= li_f.label '_delete', 'Remove'
20
+
21
+ %p
22
+ = f.submit "Save"
23
+
24
+
25
+ - if @shop_orders.empty?
26
+ %p There are no customers.
27
+ - else
28
+ %form
29
+ - @shop_orders.each do |order|
30
+ %p
31
+ = order.balance
32
+ = order.customer.name if order.customer
33
+ = link_to "Delete Order", "/admin/shop/orders/#{order.id}", :confirm => "Are you sure?", :method => :delete, :style => "color: blue;"