opensteam 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (265) hide show
  1. data/CHANGELOG +78 -0
  2. data/LICENSE +345 -0
  3. data/{README.txt → README.rdoc} +20 -17
  4. data/Rakefile +40 -0
  5. data/generators/opensteam/opensteam_generator.rb +95 -194
  6. data/generators/opensteam/templates/{controllers/administration → app/controllers/admin}/inventories_controller.rb +4 -4
  7. data/generators/opensteam/templates/app/controllers/admin/invoices_controller.rb +106 -0
  8. data/generators/opensteam/templates/app/controllers/admin/orders_controller.rb +113 -0
  9. data/generators/opensteam/templates/app/controllers/admin/search_controller.rb +17 -0
  10. data/generators/opensteam/templates/app/controllers/admin/shipments_controller.rb +106 -0
  11. data/generators/opensteam/templates/app/controllers/admin/users_controller.rb +99 -0
  12. data/generators/opensteam/templates/app/controllers/admin_controller.rb +40 -0
  13. data/generators/opensteam/templates/app/controllers/cart_controller.rb +94 -0
  14. data/generators/opensteam/templates/app/controllers/checkout_controller.rb +139 -0
  15. data/generators/opensteam/templates/app/controllers/profile/infos_controller.rb +52 -0
  16. data/generators/opensteam/templates/app/controllers/profile/orders_controller.rb +105 -0
  17. data/generators/opensteam/templates/app/controllers/profile_controller.rb +37 -0
  18. data/generators/opensteam/templates/app/controllers/searches_controller.rb +23 -0
  19. data/generators/opensteam/templates/app/controllers/user_sessions_controller.rb +38 -0
  20. data/generators/opensteam/templates/app/controllers/users_controller.rb +40 -0
  21. data/generators/opensteam/templates/{controllers → app/controllers}/webshop_controller.rb +35 -13
  22. data/generators/opensteam/templates/app/helpers/admin_helper.rb +40 -0
  23. data/generators/opensteam/templates/app/helpers/users_helper.rb +53 -0
  24. data/generators/opensteam/templates/app/helpers/webshop_helper.rb +91 -0
  25. data/generators/opensteam/templates/app/models/search.rb +36 -0
  26. data/generators/opensteam/templates/{views/administration → app/views/admin}/_address.html.erb +0 -0
  27. data/generators/opensteam/templates/app/views/admin/_nav.html.erb +5 -0
  28. data/generators/opensteam/templates/app/views/admin/catalog.html.erb +5 -0
  29. data/generators/opensteam/templates/app/views/admin/index.html.erb +21 -0
  30. data/generators/opensteam/templates/{views/administration → app/views/admin}/inventories/edit.html.erb +10 -9
  31. data/generators/opensteam/templates/{views/administration → app/views/admin}/inventories/index.html.erb +3 -3
  32. data/generators/opensteam/templates/{views/administration → app/views/admin}/inventories/new.html.erb +3 -3
  33. data/generators/opensteam/templates/app/views/admin/inventories/show.html.erb +46 -0
  34. data/generators/opensteam/templates/app/views/admin/invoices/_invoice.html.erb +12 -0
  35. data/generators/opensteam/templates/app/views/admin/invoices/_invoices.html.erb +11 -0
  36. data/generators/opensteam/templates/app/views/admin/invoices/index.html.erb +6 -0
  37. data/generators/opensteam/templates/app/views/admin/invoices/new.html.erb +54 -0
  38. data/generators/opensteam/templates/app/views/admin/invoices/show.html.erb +55 -0
  39. data/generators/opensteam/templates/app/views/admin/orders/_event.html.erb +5 -0
  40. data/generators/opensteam/templates/app/views/admin/orders/_order.html.erb +11 -0
  41. data/generators/opensteam/templates/app/views/admin/orders/_order_item.html.erb +10 -0
  42. data/generators/opensteam/templates/app/views/admin/orders/_orders.html.erb +19 -0
  43. data/generators/opensteam/templates/app/views/admin/orders/index.html.erb +14 -0
  44. data/generators/opensteam/templates/app/views/admin/orders/livesearch.rjs +6 -0
  45. data/generators/opensteam/templates/app/views/admin/orders/show.html.erb +58 -0
  46. data/generators/opensteam/templates/app/views/admin/products.html.erb +8 -0
  47. data/generators/opensteam/templates/app/views/admin/properties.html.erb +7 -0
  48. data/generators/opensteam/templates/app/views/admin/sales.html.erb +5 -0
  49. data/generators/opensteam/templates/app/views/admin/shipments/_shipment.erb +11 -0
  50. data/generators/opensteam/templates/app/views/admin/shipments/_shipments.html.erb +11 -0
  51. data/generators/opensteam/templates/app/views/admin/shipments/index.html.erb +6 -0
  52. data/generators/opensteam/templates/app/views/admin/shipments/new.html.erb +51 -0
  53. data/generators/opensteam/templates/app/views/admin/shipments/show.html.erb +55 -0
  54. data/generators/opensteam/templates/app/views/admin/users/_admins.html.erb +26 -0
  55. data/generators/opensteam/templates/app/views/admin/users/_admins_header.html.erb +10 -0
  56. data/generators/opensteam/templates/app/views/admin/users/_customer.html.erb +32 -0
  57. data/generators/opensteam/templates/app/views/admin/users/_customers.html.erb +29 -0
  58. data/generators/opensteam/templates/app/views/admin/users/_customers_header.html.erb +11 -0
  59. data/generators/opensteam/templates/app/views/admin/users/_user_fields.html.erb +9 -0
  60. data/generators/opensteam/templates/app/views/admin/users/_users.html.erb +29 -0
  61. data/generators/opensteam/templates/app/views/admin/users/_users_header.html.erb +11 -0
  62. data/generators/opensteam/templates/app/views/admin/users/edit.html.erb +6 -0
  63. data/generators/opensteam/templates/app/views/admin/users/index.html.erb +7 -0
  64. data/generators/opensteam/templates/app/views/admin/users/new.html.erb +6 -0
  65. data/generators/opensteam/templates/app/views/admin/users/show.html.erb +34 -0
  66. data/generators/opensteam/templates/app/views/admin/users.html.erb +4 -0
  67. data/generators/opensteam/templates/{views → app/views}/administration_mailer/order_admin.erb +0 -0
  68. data/generators/opensteam/templates/{views → app/views}/administration_mailer/order_customer.erb +0 -0
  69. data/generators/opensteam/templates/app/views/cart/_cart.html.erb +8 -0
  70. data/generators/opensteam/templates/{views/webshop → app/views/cart}/_cart_content.html.erb +7 -10
  71. data/generators/opensteam/templates/app/views/cart/index.html.erb +5 -0
  72. data/generators/opensteam/templates/app/views/cart/update.rjs +1 -0
  73. data/generators/opensteam/templates/app/views/checkout/intro.html.erb +18 -0
  74. data/generators/opensteam/templates/{views → app/views}/checkout/outro.html.erb +0 -1
  75. data/generators/opensteam/templates/{views → app/views}/checkout/payment.html.erb +0 -0
  76. data/generators/opensteam/templates/app/views/checkout/shipping.html.erb +45 -0
  77. data/generators/opensteam/templates/app/views/checkout/show_cart.html.erb +13 -0
  78. data/generators/opensteam/templates/{views → app/views}/checkout/update_cart_content.rjs +0 -0
  79. data/generators/opensteam/templates/{views → app/views}/common/_cart.html.erb +2 -2
  80. data/generators/opensteam/templates/{views → app/views}/common/_cart_content.html.erb +1 -1
  81. data/generators/opensteam/templates/app/views/common/_footer.html.erb +1 -0
  82. data/generators/opensteam/templates/app/views/common/_header.html.erb +4 -0
  83. data/generators/opensteam/templates/app/views/common/_header_flash.html.erb +3 -0
  84. data/generators/opensteam/templates/app/views/common/_signup_fields.html.erb +16 -0
  85. data/generators/opensteam/templates/app/views/common/_top_links.html.erb +10 -0
  86. data/generators/opensteam/templates/app/views/layouts/admin.html.erb +45 -0
  87. data/generators/opensteam/templates/app/views/layouts/profile.html.erb +45 -0
  88. data/generators/opensteam/templates/app/views/layouts/webshop.html.erb +51 -0
  89. data/generators/opensteam/templates/app/views/profile/_customer_sidebar.html.erb +12 -0
  90. data/generators/opensteam/templates/app/views/profile/index.html.erb +11 -0
  91. data/generators/opensteam/templates/app/views/profile/infos/_customer.html.erb +5 -0
  92. data/generators/opensteam/templates/app/views/profile/infos/edit.html.erb +25 -0
  93. data/generators/opensteam/templates/app/views/profile/infos/edit_password.html.erb +26 -0
  94. data/generators/opensteam/templates/app/views/profile/orders/_order.html.erb +11 -0
  95. data/generators/opensteam/templates/app/views/profile/orders/_order_item.html.erb +10 -0
  96. data/generators/opensteam/templates/app/views/profile/orders/_orders.html.erb +19 -0
  97. data/generators/opensteam/templates/app/views/profile/orders/index.html.erb +14 -0
  98. data/generators/opensteam/templates/app/views/profile/orders/show.html.erb +48 -0
  99. data/generators/opensteam/templates/app/views/searches/_search_bar.html.erb +5 -0
  100. data/generators/opensteam/templates/app/views/searches/new.html.erb +23 -0
  101. data/generators/opensteam/templates/app/views/searches/show.html.erb +1 -0
  102. data/generators/opensteam/templates/app/views/user_sessions/new.html.erb +14 -0
  103. data/generators/opensteam/templates/app/views/users/_user_bar.html.erb +5 -0
  104. data/generators/opensteam/templates/app/views/users/index.html.erb +27 -0
  105. data/generators/opensteam/templates/app/views/users/new.html.erb +7 -0
  106. data/generators/opensteam/templates/app/views/users/show.html.erb +5 -0
  107. data/generators/opensteam/templates/{views → app/views}/webshop/_inventory_content.html.erb +0 -0
  108. data/generators/opensteam/templates/app/views/webshop/_nav.html.erb +6 -0
  109. data/generators/opensteam/templates/{views → app/views}/webshop/add_inventory_to_cart.rjs +0 -0
  110. data/generators/opensteam/templates/{views → app/views}/webshop/add_to_cart_with_parameters.rjs +0 -0
  111. data/generators/opensteam/templates/{views → app/views}/webshop/del_item.rjs +0 -0
  112. data/generators/opensteam/templates/app/views/webshop/index.html.erb +11 -0
  113. data/generators/opensteam/templates/{views → app/views}/webshop/inventory.rjs +0 -0
  114. data/generators/opensteam/templates/{views → app/views}/webshop/show.html.erb +15 -15
  115. data/generators/opensteam/templates/config/initializers/init_states.rb +68 -0
  116. data/generators/opensteam/templates/{init → config/initializers}/opensteam.rb +6 -0
  117. data/generators/opensteam/templates/config/initializers/opensteam_model_tables.rb +57 -0
  118. data/generators/opensteam/templates/db/migrate/20080609095714_create_profiles.rb +14 -0
  119. data/generators/opensteam/templates/{migrations/create_sessions.rb → db/migrate/20080609095720_create_sessions.rb} +0 -0
  120. data/generators/opensteam/templates/db/migrate/20080609095721_create_users.rb +29 -0
  121. data/generators/opensteam/templates/{migrations/create_addresses.rb → db/migrate/20080609095723_create_addresses.rb} +0 -0
  122. data/generators/opensteam/templates/{migrations/create_customers.rb → db/migrate/20080609095724_create_customers.rb} +0 -0
  123. data/generators/opensteam/templates/db/migrate/20080609095725_create_dummy_users.rb +21 -0
  124. data/generators/opensteam/templates/{migrations/create_inventories.rb → db/migrate/20080609095726_create_inventories.rb} +0 -0
  125. data/generators/opensteam/templates/{migrations/create_inventories_properties.rb → db/migrate/20080609095727_create_inventories_properties.rb} +0 -0
  126. data/generators/opensteam/templates/{migrations/create_order_items.rb → db/migrate/20080609095728_create_order_items.rb} +5 -0
  127. data/generators/opensteam/templates/db/migrate/20080609095729_create_orders.rb +32 -0
  128. data/generators/opensteam/templates/{migrations/create_payment_types.rb → db/migrate/20080609095730_create_payment_types.rb} +0 -0
  129. data/generators/opensteam/templates/{migrations/create_properties.rb → db/migrate/20080609095731_create_properties.rb} +0 -0
  130. data/generators/opensteam/templates/db/migrate/20080623075613_create_states.rb +13 -0
  131. data/generators/opensteam/templates/db/migrate/20080624132807_create_searches.rb +20 -0
  132. data/generators/opensteam/templates/db/migrate/20080630114155_create_state_histories.rb +14 -0
  133. data/generators/opensteam/templates/db/migrate/20080714131513_create_invoices.rb +20 -0
  134. data/generators/opensteam/templates/db/migrate/20080714131650_create_shipments.rb +19 -0
  135. data/generators/opensteam/templates/lib/authenticated_system.rb +201 -0
  136. data/generators/opensteam/templates/lib/authentication/by_cookie_token.rb +90 -0
  137. data/generators/opensteam/templates/lib/authentication/by_password.rb +68 -0
  138. data/generators/opensteam/templates/lib/authentication.rb +46 -0
  139. data/generators/opensteam/templates/lib/states/invoice/finished.rb +6 -0
  140. data/generators/opensteam/templates/lib/states/invoice/payment_received.rb +8 -0
  141. data/generators/opensteam/templates/lib/states/invoice/pending.rb +6 -0
  142. data/generators/opensteam/templates/lib/states/invoice/waiting_for_payment.rb +5 -0
  143. data/generators/opensteam/templates/lib/states/order/finished.rb +6 -0
  144. data/generators/opensteam/templates/lib/states/order/pending.rb +19 -0
  145. data/generators/opensteam/templates/lib/states/order/processing.rb +11 -0
  146. data/generators/opensteam/templates/lib/states/shipment/finished.rb +6 -0
  147. data/generators/opensteam/templates/lib/states/shipment/pending.rb +5 -0
  148. data/generators/opensteam/templates/lib/tasks/opensteam.rake +114 -0
  149. data/generators/opensteam/templates/public/images/athmo_background.jpg +0 -0
  150. data/generators/opensteam/templates/public/images/bg.jpg +0 -0
  151. data/generators/opensteam/templates/public/images/cart_big.gif +0 -0
  152. data/generators/opensteam/templates/public/images/cross.png +0 -0
  153. data/generators/opensteam/templates/public/images/enter.gif +0 -0
  154. data/generators/opensteam/templates/public/images/menu_background.jpg +0 -0
  155. data/generators/opensteam/templates/public/images/opensteam_background.jpg +0 -0
  156. data/generators/opensteam/templates/public/images/opensteam_logo1.jpg +0 -0
  157. data/generators/opensteam/templates/public/images/opensteam_petstore_logo1.jpg +0 -0
  158. data/generators/opensteam/templates/public/images/opensteam_store_logo.jpg +0 -0
  159. data/generators/opensteam/templates/public/images/os_logo.gif +0 -0
  160. data/generators/opensteam/templates/public/images/slogan.png +0 -0
  161. data/generators/opensteam/templates/public/images/tick.png +0 -0
  162. data/generators/opensteam/templates/public/images/zoom.png +0 -0
  163. data/generators/opensteam/templates/public/index.html +19 -36
  164. data/generators/opensteam/templates/public/javascripts/opensteam.js +30 -0
  165. data/generators/opensteam/templates/public/stylesheets/opensteam_newdesign.css +188 -0
  166. data/generators/opensteam/templates/public/stylesheets/opensteam_white.css +168 -0
  167. data/generators/opensteam/templates/public/stylesheets/webshop.css +0 -1
  168. data/generators/opensteam/templates/tasks/opensteam.rake +1 -1
  169. data/generators/opensteam/templates/{fixtures → test/fixtures}/inventories.yml +0 -0
  170. data/generators/opensteam/templates/{fixtures → test/fixtures}/inventories_properties.yml +0 -0
  171. data/generators/opensteam/templates/{fixtures → test/fixtures}/product_animals.yml +0 -0
  172. data/generators/opensteam/templates/{fixtures → test/fixtures}/product_dog_foods.yml +0 -0
  173. data/generators/opensteam/templates/{fixtures → test/fixtures}/properties.yml +0 -0
  174. data/generators/opensteam_product/opensteam_product_generator.rb +25 -9
  175. data/generators/opensteam_product/templates/controllers/product_controller.rb +5 -4
  176. data/generators/opensteam_product/templates/migration.rb +2 -1
  177. data/generators/opensteam_product/templates/models/product.rb +1 -0
  178. data/generators/opensteam_product/templates/views/{administration → admin}/_attributes.html.erb +1 -1
  179. data/generators/opensteam_product/templates/views/{administration → admin}/_get_products.html.erb +0 -0
  180. data/generators/opensteam_product/templates/views/{administration → admin}/_inventories.html.erb +2 -2
  181. data/generators/opensteam_product/templates/views/admin/edit.html.erb +13 -0
  182. data/generators/opensteam_product/templates/views/{administration → admin}/index.html.erb +5 -5
  183. data/generators/opensteam_product/templates/views/admin/new.html.erb +16 -0
  184. data/generators/opensteam_product/templates/views/{administration → admin}/show.html.erb +2 -2
  185. data/generators/opensteam_property/opensteam_property_generator.rb +8 -8
  186. data/generators/opensteam_property/templates/controllers/property_controller.rb +6 -4
  187. data/generators/opensteam_property/templates/migration.rb +2 -1
  188. data/generators/opensteam_property/templates/models/property.rb +1 -0
  189. data/generators/opensteam_property/templates/views/{administration → admin}/edit.html.erb +3 -3
  190. data/generators/opensteam_property/templates/views/admin/index.html.erb +24 -0
  191. data/generators/opensteam_property/templates/views/{administration → admin}/new.html.erb +2 -2
  192. data/generators/opensteam_property/templates/views/admin/show.html.erb +10 -0
  193. data/lib/opensteam/base.rb +16 -0
  194. data/lib/opensteam/cart_base.rb +227 -0
  195. data/lib/opensteam/checkout.rb +30 -3
  196. data/lib/opensteam/config.rb +37 -0
  197. data/lib/opensteam/extension_base.rb +76 -0
  198. data/lib/opensteam/finder.rb +36 -5
  199. data/lib/opensteam/helper/configurable_table.rb +228 -0
  200. data/lib/opensteam/history.rb +56 -0
  201. data/lib/opensteam/initializer.rb +127 -0
  202. data/lib/opensteam/inventory_base.rb +24 -1
  203. data/lib/opensteam/invoice_base.rb +61 -0
  204. data/lib/opensteam/order_base.rb +105 -14
  205. data/lib/opensteam/product_base.rb +31 -3
  206. data/lib/opensteam/property_base.rb +16 -0
  207. data/lib/opensteam/shipment_base.rb +60 -0
  208. data/lib/opensteam/shopping_cart.rb +32 -14
  209. data/lib/opensteam/state_logic.rb +218 -0
  210. data/lib/opensteam/state_machine.rb +216 -0
  211. data/lib/opensteam/user_base.rb +115 -131
  212. data/lib/opensteam/version.rb +17 -1
  213. data/lib/opensteam.rb +30 -35
  214. metadata +245 -146
  215. data/History.txt +0 -0
  216. data/License.txt +0 -4
  217. data/Manifest.txt +0 -131
  218. data/Manifest.txt.bak +0 -132
  219. data/generators/opensteam/templates/controllers/administration/customers_controller.rb +0 -23
  220. data/generators/opensteam/templates/controllers/administration/orders_controller.rb +0 -61
  221. data/generators/opensteam/templates/controllers/administration_controller.rb +0 -80
  222. data/generators/opensteam/templates/controllers/checkout_controller.rb +0 -142
  223. data/generators/opensteam/templates/helpers/webshop_helper.rb +0 -29
  224. data/generators/opensteam/templates/migrations/create_dummy_users.rb +0 -16
  225. data/generators/opensteam/templates/migrations/create_orders.rb +0 -18
  226. data/generators/opensteam/templates/migrations/create_users.rb +0 -19
  227. data/generators/opensteam/templates/models/administration_mailer.rb +0 -18
  228. data/generators/opensteam/templates/models/inventories_property.rb +0 -10
  229. data/generators/opensteam/templates/models/inventory.rb +0 -57
  230. data/generators/opensteam/templates/public/images/rails.png +0 -0
  231. data/generators/opensteam/templates/views/administration/_nav.html.erb +0 -11
  232. data/generators/opensteam/templates/views/administration/_update_tree.html.erb +0 -18
  233. data/generators/opensteam/templates/views/administration/admin_info.html.erb +0 -12
  234. data/generators/opensteam/templates/views/administration/customers/index.html.erb +0 -27
  235. data/generators/opensteam/templates/views/administration/customers/show.html.erb +0 -27
  236. data/generators/opensteam/templates/views/administration/customers.html.erb +0 -44
  237. data/generators/opensteam/templates/views/administration/index.html.erb +0 -9
  238. data/generators/opensteam/templates/views/administration/inventories/show.html.erb +0 -45
  239. data/generators/opensteam/templates/views/administration/login.html.erb +0 -16
  240. data/generators/opensteam/templates/views/administration/order.html.erb +0 -22
  241. data/generators/opensteam/templates/views/administration/orders/_order_item.html.erb +0 -22
  242. data/generators/opensteam/templates/views/administration/orders/index.html.erb +0 -32
  243. data/generators/opensteam/templates/views/administration/orders/show.html.erb +0 -25
  244. data/generators/opensteam/templates/views/administration/orders.html.erb +0 -32
  245. data/generators/opensteam/templates/views/administration/products.html.erb +0 -7
  246. data/generators/opensteam/templates/views/administration/properties.html.erb +0 -7
  247. data/generators/opensteam/templates/views/administration/show_order_item.html.erb +0 -5
  248. data/generators/opensteam/templates/views/administration/signup.html.erb +0 -65
  249. data/generators/opensteam/templates/views/administration/tree.html.erb +0 -15
  250. data/generators/opensteam/templates/views/administration/update_products.html.erb +0 -5
  251. data/generators/opensteam/templates/views/administration/update_properties.html.erb +0 -5
  252. data/generators/opensteam/templates/views/administration/update_tree.rjs +0 -3
  253. data/generators/opensteam/templates/views/checkout/intro.html.erb +0 -5
  254. data/generators/opensteam/templates/views/checkout/shipping.html.erb +0 -39
  255. data/generators/opensteam/templates/views/checkout/show_cart.html.erb +0 -13
  256. data/generators/opensteam/templates/views/common/_header.html.erb +0 -15
  257. data/generators/opensteam/templates/views/layouts/administration.html.erb +0 -29
  258. data/generators/opensteam/templates/views/layouts/webshop.html.erb +0 -36
  259. data/generators/opensteam/templates/views/webshop/_cart.html.erb +0 -11
  260. data/generators/opensteam/templates/views/webshop/_header.html.erb +0 -15
  261. data/generators/opensteam/templates/views/webshop/index.html.erb +0 -12
  262. data/generators/opensteam_product/templates/views/administration/edit.html.erb +0 -13
  263. data/generators/opensteam_product/templates/views/administration/new.html.erb +0 -16
  264. data/generators/opensteam_property/templates/views/administration/index.html.erb +0 -24
  265. data/generators/opensteam_property/templates/views/administration/show.html.erb +0 -10
@@ -0,0 +1,38 @@
1
+ # This controller handles the login/logout function of the site.
2
+ class UserSessionsController < ApplicationController
3
+ include Opensteam::ShoppingCart
4
+
5
+ # render new.rhtml
6
+ def new
7
+ end
8
+
9
+ def create
10
+ logout_keeping_session!
11
+ user = User.authenticate(params[:email], params[:password])
12
+ if user
13
+ self.current_user = user
14
+ new_cookie_flag = (params[:remember_me] == "1")
15
+ handle_remember_cookie! new_cookie_flag
16
+ redirect_back_or_default shop_index_path
17
+ flash[:notice] = "Logged in successfully"
18
+ else
19
+ note_failed_signin
20
+ @email = params[:email]
21
+ @remember_me = params[:remember_me]
22
+ render :action => 'new'
23
+ end
24
+ end
25
+
26
+ def destroy
27
+ logout_killing_session!
28
+ flash[:notice] = "You have been logged out."
29
+ redirect_back_or_default shop_index_path
30
+ end
31
+
32
+ protected
33
+ # Track failed login attempts
34
+ def note_failed_signin
35
+ flash[:error] = "Couldn't log you in as '#{params[:email]}'"
36
+ logger.warn "Failed login for '#{params[:email]}' from #{request.remote_ip} at #{Time.now.utc}"
37
+ end
38
+ end
@@ -0,0 +1,40 @@
1
+ class UsersController < ApplicationController
2
+
3
+ # render new.rhtml
4
+ def new
5
+ @user = Opensteam::UserBase::User.new
6
+ end
7
+
8
+
9
+ def create
10
+ logout_keeping_session!
11
+
12
+ @customer = Opensteam::UserBase::User.new( params[:user] )
13
+ success = @customer && @customer.save
14
+
15
+ if success && @customer.errors.empty?
16
+
17
+ self.current_user = @customer # !! now logged in
18
+
19
+ redirect_back_or_default('/')
20
+ else
21
+ @user = @customer
22
+ flash[:error] = "We couldn't set up that account, sorry. Please try again, or contact an admin (link is above)."
23
+ render :action => 'new'
24
+ end
25
+ end
26
+
27
+
28
+ def show
29
+ @customer = Opensteam::UserBase::Customer.find( params[:id] )
30
+
31
+ respond_to do |format|
32
+ format.html
33
+ format.xml { render :xml => @customer }
34
+ end
35
+
36
+ end
37
+
38
+
39
+
40
+ end
@@ -1,7 +1,18 @@
1
- class <%= class_name %>Controller < Opensteam::ShoppingCart::CartController
2
-
1
+ ## TEMPLATE ##
2
+ class <%= class_name %>Controller < ApplicationController
3
+
4
+ include Opensteam::ShoppingCart
5
+ include Authentication
6
+ include AuthenticatedSystem
3
7
  include Opensteam::Finder
4
8
 
9
+ helper :all
10
+
11
+ before_filter :delete_active_order
12
+
13
+
14
+
15
+
5
16
  # start the checkout-process
6
17
  #
7
18
  def start_checkout
@@ -13,8 +24,8 @@ class <%= class_name %>Controller < Opensteam::ShoppingCart::CartController
13
24
  # show shop index (all products)
14
25
  def index
15
26
  #todo: implement paginate for find_products
16
- @products = <%= class_name %>Controller.find_products
17
-
27
+ @products = Opensteam::Find.find_products
28
+
18
29
  respond_to do |format|
19
30
  format.html # index.html.erb
20
31
  format.xml { render :xml => @products }
@@ -22,6 +33,10 @@ class <%= class_name %>Controller < Opensteam::ShoppingCart::CartController
22
33
 
23
34
  end
24
35
 
36
+
37
+
38
+
39
+
25
40
 
26
41
  # get inventory object for selected product and properties
27
42
  def inventory
@@ -44,17 +59,19 @@ class <%= class_name %>Controller < Opensteam::ShoppingCart::CartController
44
59
 
45
60
  # show product-details
46
61
  def show
47
- unless params[:id]
48
- @products = <%= class_name %>Controller.find_product( params[:type] )
49
- respond_to do |format|
50
- format.html { render :action => :index }
51
- format.xml { render :xml => @products }
62
+ unless @cart_details
63
+ unless params[:id]
64
+ @products = Opensteam::Find.find_product( params[:type] )
65
+ respond_to do |format|
66
+ format.html { render :action => :index }
67
+ format.xml { render :xml => @products }
68
+ end
69
+ return
52
70
  end
53
- return
71
+ @product = Opensteam::Find.find_product_by_id( params[:type], params[:id] )
72
+ @properties = @product.properties.to_h2 { |x| x.class.to_s.tableize }
73
+ @inventory = @product.properties.empty? ? @product.inventories : []
54
74
  end
55
- @product = <%= class_name %>Controller.find_product_by_id( params[:type], params[:id] )
56
- @properties = @product.properties.to_h2 { |x| x.class.to_s.tableize }
57
- @inventory = @product.properties.empty? ? @product.inventories : []
58
75
 
59
76
  respond_to do |format|
60
77
  format.html # show.html.erb
@@ -63,6 +80,11 @@ class <%= class_name %>Controller < Opensteam::ShoppingCart::CartController
63
80
  end
64
81
 
65
82
 
83
+ private
84
+ def delete_active_order
85
+ session[:active_order] = nil
86
+ end
87
+
66
88
 
67
89
 
68
90
  end
@@ -0,0 +1,40 @@
1
+ # Methods added to this helper will be available to all templates in the application.
2
+ ## TEMPLATE ##
3
+ module AdminHelper
4
+
5
+
6
+ def button_to_with_image( image, args )
7
+ form_tag :action => args[:action], :id => args[:id] do
8
+ image_submit_tag( image )
9
+ end
10
+ end
11
+
12
+ def submit_tag_with_image( text, image, args = { :confirm => "Are Your Sure?" } )
13
+ args[:name] = text
14
+ args[:type] = 'image'
15
+ args[:src] = image_path( image )
16
+ submit_tag(text, args )
17
+ end
18
+
19
+
20
+ def admin_sidebar_links(opts = { :html => {} }, &block )
21
+ html_options = opts[:html]
22
+ content = capture( &block )
23
+ concat(
24
+ content_tag(:ul, html_options) do
25
+ content
26
+ end,
27
+ block.binding
28
+ )
29
+ end
30
+
31
+ def admin_sidebar_link( name, path, opts = {} )
32
+ html_options = opts[:html]
33
+ content_tag(:li, html_options ) do
34
+ opts[:function] ? link_to_function(name, opts[:function] ) : link_to( name, path )
35
+ end
36
+
37
+ end
38
+
39
+
40
+ end
@@ -0,0 +1,53 @@
1
+ module UsersHelper
2
+
3
+
4
+ def if_authorized?(action, resource, &block)
5
+ if authorized?(action, resource)
6
+ yield action, resource
7
+ end
8
+ end
9
+
10
+
11
+
12
+ def link_to_user(user, options={})
13
+ raise "Invalid user" unless user
14
+ options.reverse_merge! :content_method => :email, :title_method => :email, :class => :nickname
15
+ content_text = options.delete(:content_text)
16
+ content_text ||= user.send(options.delete(:content_method))
17
+ options[:title] ||= user.send(options.delete(:title_method))
18
+ if user.is_admin?
19
+ link_to h(content_text), admin_path, options
20
+ else
21
+ link_to h(content_text), profile_index_path, options
22
+ end
23
+
24
+
25
+ end
26
+
27
+
28
+
29
+ def link_to_login_with_IP content_text=nil, options={}
30
+ ip_addr = request.remote_ip
31
+ content_text ||= ip_addr
32
+ options.reverse_merge! :title => ip_addr
33
+ if tag = options.delete(:tag)
34
+ content_tag tag, h(content_text), options
35
+ else
36
+ link_to h(content_text), login_path, options
37
+ end
38
+ end
39
+
40
+
41
+
42
+ def link_to_current_user(options={})
43
+ if current_user
44
+ link_to_user current_user, options
45
+ else
46
+ content_text = options.delete(:content_text) || 'not signed in'
47
+ # kill ignored options from link_to_user
48
+ [:content_method, :title_method].each{|opt| options.delete(opt)}
49
+ link_to_login_with_IP content_text, options
50
+ end
51
+ end
52
+
53
+ end
@@ -0,0 +1,91 @@
1
+ # Methods added to this helper will be available to all templates in the application.
2
+ ## TEMPLATE ##
3
+ module <%= file_name.classify %>Helper
4
+
5
+ # return first partial-file that exist in *a
6
+ def existing_partial( *a )
7
+ a.each { |v| return v if File.exist?( "#{RAILS_ROOT}/app/views/#{File.split(v)[0]}/_#{File.split(v)[1]}.html.erb" ) }
8
+ end
9
+
10
+ def ordinalized_time(time = Time.now)
11
+ time.strftime("%d-%m-%Y %H:%M:%S")
12
+ end
13
+
14
+ def shop_menu_links
15
+ returning("") do |str|
16
+ str.concat( link_to( "Index", opensteam_index_path ) )
17
+ str.concat( link_to( "Search", new_search_path ) )
18
+ if logged_in?
19
+ str.concat( link_to( "Logout", logout_path) )
20
+ str.concat( link_to( "admin", admin_path ) ) if current_user.is_a?( Opensteam::UserBase::Admin )
21
+ else
22
+ str.concat( link_to("Login", login_path) )
23
+ str.concat( link_to( "Register", signup_path) )
24
+ end
25
+ end
26
+
27
+ end
28
+
29
+
30
+ def render_configured_table( mdl, opts = {}, &block )
31
+ mdl = mdl.to_s.classify.constantize unless mdl.is_a?(Class)
32
+
33
+ html_options = opts[:html] || {}
34
+
35
+ content = capture( &block )
36
+ html_options[:id] ||= mdl.configured_table.table_id
37
+
38
+ concat(
39
+ content_tag( :div, { :class => 'configured_table' } ) do
40
+ content_tag( :table, html_options ) do
41
+ content
42
+ end
43
+ end,
44
+ block.binding )
45
+
46
+ end
47
+
48
+
49
+
50
+
51
+ def render_configured_table_header(mdl, partial = nil, opts = {}, &block )
52
+
53
+ mdl = mdl.to_s.classify.constantize unless mdl.is_a?(Class)
54
+ if partial
55
+ return controller.render_to_string( partial, :object => mdl.configured_table.columns.collect(&:name) )
56
+ end
57
+
58
+ table_id = mdl.configured_table.table_id
59
+
60
+ ct = mdl.configured_table
61
+ html_options = opts[:html]
62
+ content_tag( :thead, {} ) do
63
+ content_tag( :tr, html_options ) do
64
+ ct.columns.collect do |column|
65
+ content_tag( :th, {} ) do
66
+ if block_given?
67
+ block.call(column)
68
+ else
69
+ link_to_remote( column.name,
70
+ :url => { :controller =>"admin/#{controller.controller_name}", :action => 'sort', :model => 'Order', :sort => column.id },
71
+ :update => table_id )
72
+ end
73
+ end
74
+ end.to_s
75
+ end
76
+ end
77
+
78
+ end
79
+
80
+
81
+ def render_configured_table_content( *opts )
82
+ opts = opts.first unless opts.is_a?(Hash)
83
+ if opts[:partial]
84
+ return content_tag( :tbody, :id => opts.delete(:id) ) do
85
+ controller.render_to_string(opts)
86
+ end
87
+ end
88
+ end
89
+
90
+
91
+ end
@@ -0,0 +1,36 @@
1
+ class Search < ActiveRecord::Base
2
+ belongs_to :customer, :class_name => 'Opensteam::UserBase::Customer'
3
+
4
+ def products
5
+ @products ||= find_products
6
+ end
7
+
8
+
9
+ private
10
+
11
+ def find_products
12
+ klasses = []
13
+ ( klasses << ( kind.blank? ? Opensteam::Find.find_product_klasses : kind.classify.constantize ) ).flatten!
14
+ klasses.inject([]) do |ret, klass|
15
+ ret += find_products_for( klass )
16
+ end
17
+ end
18
+
19
+ def find_products_for(klass)
20
+ scope = klass.scoped({})
21
+ scope = scope.scoped :include => { :inventories_properties => :property }, :conditions => ["#{klass.table_name}.name LIKE ? OR #{klass.table_name}.description LIKE ? OR properties.name LIKE ?",
22
+ "%#{keywords}%", "%#{keywords}%", "%#{keywords}%"] unless keywords.blank?
23
+ scope = scope.scoped :include => :inventories, :conditions => ['inventories.price >= ?', minimum_price ] unless minimum_price.blank?
24
+ scope = scope.scoped :include => :inventories, :conditions => ['inventories.price <= ?', maximum_price ] unless maximum_price.blank?
25
+ scope = scope.scoped :include => :inventories, :conditions => ['inventories.price >= ?', minimum_storage ] unless minimum_storage.blank?
26
+ scope = scope.scoped :include => :inventories, :conditions => ['inventories.storage <= ?', maximum_storage ] unless maximum_storage.blank?
27
+ scope
28
+ end
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+ end
@@ -0,0 +1,5 @@
1
+ <div id="nav" style="">
2
+ <%= link_to "admin index", admin_path %> |
3
+ <%= link_to "view site", shop_index_path %>
4
+ <%= render :partial => "users/user_bar" %>
5
+ </div>
@@ -0,0 +1,5 @@
1
+ <ul>
2
+ <li><%= link_to "Products", :controller => 'admin', :action => 'products' %></li>
3
+ <li><%= link_to "Properties", :controller => 'admin', :action => 'properties' %></li>
4
+ <li><%= link_to "Inventories", admin_inventories_path %></li>
5
+ </ul>
@@ -0,0 +1,21 @@
1
+ <b>Administration - Section</b><br />
2
+ <br />
3
+ <ul>
4
+ <li>Catalog
5
+ <%= render "admin/catalog" %>
6
+ </li>
7
+ <li>Sales
8
+ <%= render "admin/sales" %>
9
+ </li>
10
+ <li>Users
11
+ <%= render "admin/users" %>
12
+ </li>
13
+ <% for ext in @extensions %>
14
+ <li><%= link_to ext.name.capitalize, :controller => "admin/#{ext.name}", :action => 'index' %>
15
+ <%= render "admin/#{ext.name}/index" %>
16
+ </li>
17
+ <% end %>
18
+
19
+
20
+ </ul>
21
+
@@ -1,10 +1,11 @@
1
1
 
2
- <% content_for :sub_nav do %>
3
- <%= link_to "#{@inventory.product.class.to_s.pluralize} Index", :controller => @inventory.product.class.to_s.tableize, :action => :index %> ||
4
- <%= link_to "Show Product", [:administration, @inventory.product ] %>
5
- <%= link_to "Edit Product", [:edit, :administration, @inventory.product ] %>
6
- <%= link_to "Show Inventory", administration_inventory_path( @inventory ) %>
7
-
2
+ <% content_for :admin_sidebar do %>
3
+ <% admin_sidebar_links do %>
4
+ <%= admin_sidebar_link "#{@inventory.product.class.to_s.pluralize} Index", :controller => @inventory.product.class.to_s.tableize, :action => :index %>
5
+ <%= admin_sidebar_link "Show Product", [:admin, @inventory.product ] %>
6
+ <%= admin_sidebar_link "Edit Product", [:edit, :admin, @inventory.product ] %>
7
+ <%= admin_sidebar_link "Show Inventory", admin_inventory_path( @inventory ) %>
8
+ <% end %>
8
9
  <% end %>
9
10
 
10
11
 
@@ -43,6 +44,6 @@
43
44
  </p>
44
45
  <% end %>
45
46
 
46
- <%= link_to 'Show', administration_inventory_path( @inventory )%> |
47
- <%= link_to 'Back', [:administration, @inventory.product ] %> |
48
- <%= link_to 'Index', administration_inventories_path %>
47
+ <%= link_to 'Show', admin_inventory_path( @inventory )%> |
48
+ <%= link_to 'Back', [:admin, @inventory.product ] %> |
49
+ <%= link_to 'Index', admin_inventories_path %>
@@ -16,9 +16,9 @@
16
16
  <td><%=h inventory.active %></td>
17
17
  <td><%=h inventory.description %></td>
18
18
  <td><%=h inventory.back_ordered %></td>
19
- <td><%= link_to 'Show', administration_inventory_path( inventory ) %></td>
20
- <td><%= link_to 'Edit', edit_administration_inventory_path(inventory) %></td>
21
- <td><%= link_to 'Destroy', administration_inventory_path( inventory ), :confirm => 'Are you sure?', :method => :delete %></td>
19
+ <td><%= link_to 'Show', admin_inventory_path( inventory ) %></td>
20
+ <td><%= link_to 'Edit', edit_admin_inventory_path(inventory) %></td>
21
+ <td><%= link_to 'Destroy', admin_inventory_path( inventory ), :confirm => 'Are you sure?', :method => :delete %></td>
22
22
  </tr>
23
23
  <% end %>
24
24
  </table>
@@ -2,7 +2,7 @@
2
2
 
3
3
  <%= error_messages_for :inventory %>
4
4
 
5
- <% form_for([:administration, @inventory]) do |f| %>
5
+ <% form_for([:admin, @inventory]) do |f| %>
6
6
  <p>
7
7
  <b>Price</b><br />
8
8
  <%= f.text_field :price %>
@@ -34,8 +34,8 @@
34
34
  <% end %>
35
35
 
36
36
 
37
- <%= link_to 'Back', [:administration, @inventory.product ] %> |
38
- <%= link_to 'Inventory Index', administration_inventories_path %>
37
+ <%= link_to 'Back', [:admin, @inventory.product ] %> |
38
+ <%= link_to 'Inventory Index', admin_inventories_path %>
39
39
 
40
40
 
41
41
 
@@ -0,0 +1,46 @@
1
+
2
+ <% content_for :admin_sidebar do %>
3
+ <% admin_sidebar_links do %>
4
+ <%= admin_sidebar_link "#{@inventory.product.class.to_s.pluralize} Index", :controller => @inventory.product.class.to_s.tableize, :action => :index %> <br />
5
+ <%= admin_sidebar_link "Show Product", [:admin, @inventory.product ] %> <br />
6
+ <%= admin_sidebar_link "Edit Product", [:edit, :admin, @inventory.product ] %> <br />
7
+ <%= admin_sidebar_link "Edit Inventory", edit_admin_inventory_path( @inventory ) %>
8
+ <% end %>
9
+ <% end %>
10
+
11
+
12
+
13
+ <h3>Showing Inventory for <%=h @inventory.product.class %> '<%=h @inventory.product.name %>'</h3>
14
+ <h4>Configuration: <%=h @inventory.properties.collect(&:name) * "," %></h4>
15
+
16
+ <p>
17
+ <b>Price:</b>
18
+ <%=h @inventory.price %>
19
+ </p>
20
+
21
+ <p>
22
+ <b>Storage:</b>
23
+ <%=h @inventory.storage %>
24
+ </p>
25
+
26
+ <p>
27
+ <b>Active:</b>
28
+ <%=h @inventory.active == 1 ? "true" : "false"%>
29
+ </p>
30
+
31
+ <p>
32
+ <b>Back ordered:</b>
33
+ <%=h @inventory.back_ordered == 1 ? "true" : "false" %>
34
+ </p>
35
+
36
+ <p>
37
+ <b>Description:</b>
38
+ <%=h @inventory.description %>
39
+ </p>
40
+
41
+
42
+
43
+
44
+ <%= link_to 'Edit', edit_admin_inventory_path(@inventory) %> |
45
+ <%= link_to 'Back', [:admin, @inventory.product ] %> |
46
+ <%= link_to 'Inventory Index', admin_inventories_path %>
@@ -0,0 +1,12 @@
1
+
2
+ <tr class="<%= cycle('odd','even') %>">
3
+ <td><%=h invoice.id %></td>
4
+ <td><%=h invoice.order_items.size %></td>
5
+ <td><%=h invoice.address.to_s %></td>
6
+ <td><%=h invoice.state %></td>
7
+ <td><%=h invoice.comment %></td>
8
+ <td><%=h invoice.price %></td>
9
+ <td><%=h ordinalized_time( invoice.created_at) %></td>
10
+ <td><%=h ordinalized_time( invoice.updated_at ) %></td>
11
+ <td><%= link_to "show", admin_order_invoice_path( invoice.order, invoice ) %></td>
12
+ </tr>
@@ -0,0 +1,11 @@
1
+ <% render_configured_table :invoice do %>
2
+ <%= render_configured_table_header :invoice do |column|
3
+ url = { :controller =>"admin/invoices", :action => 'sort', :sort => column.id, :model => 'Invoice' }
4
+ url[:order_id] = @order.id if @order
5
+ link_to_remote( column.name,
6
+ :url => url,
7
+ :update => id )
8
+ end %>
9
+
10
+ <%= render_configured_table_content( :partial => "admin/invoices/invoice", :collection => invoices, :id => id ) %>
11
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h2> Invoices </h2>
2
+ <br />
3
+ <div id="invoices_content_div">
4
+ <%= render :partial => "invocies", :object => @invoices, :locals => { :id => "invoices_content_table1" } %>
5
+ </div>
6
+
@@ -0,0 +1,54 @@
1
+ <% content_for :admin_sidebar do %>
2
+ <% admin_sidebar_links do %>
3
+ <%= admin_sidebar_link "Show Order", admin_order_path( @order ) %>
4
+ <%= admin_sidebar_link "Show Order Shipments", admin_order_shipments_path %>
5
+ <%= admin_sidebar_link "Show Order Invoices", admin_order_invoices_path %>
6
+ <% end %>
7
+ <% end %>
8
+
9
+ <h2>New Invoice</h2>
10
+
11
+ <%= error_messages_for :invoice %>
12
+ <%= error_messages_for :address %>
13
+
14
+
15
+
16
+ <% form_for :invoice, @nivoice, :url => { :action => 'create', :controller => 'invoices' }, :html => { :method => 'post' } do |f| %>
17
+
18
+ <% fields_for :address, @invoice.address do |a| %>
19
+ <p>Street<br />
20
+ <%= a.text_field :street %>
21
+ </p>
22
+ <p>Postal<br />
23
+ <%= a.text_field :postal %>
24
+ </p>
25
+ <p>City<br />
26
+ <%= a.text_field :city %>
27
+ </p>
28
+ <p>Land<br />
29
+ <%= a.text_field :land %>
30
+ </p>
31
+ <% end %>
32
+
33
+ <p>Comment<br />
34
+ <%= f.text_area :comment, :rows => 5%>
35
+ </p>
36
+ <p>Price<br />
37
+ <%= f.text_field :price, :rows => 5%>
38
+ </p>
39
+ <% fields_for :order_items, nil do |a| %>
40
+ <p>Select Order Items
41
+ <ul>
42
+ <% for oi in @order.order_items.select { |s| s.invoice == nil } %>
43
+ <li> <%= a.check_box "#{oi.id}", {} , 1, 0 %> <%=h oi.inventory.product.name %> (<%=h oi.inventory.product.class %>)
44
+ | <%- unless oi.inventory.properties.empty? -%><b>Configuration:</b> <%=h oi.inventory.properties.collect(&:name) * "," %><%- end -%>
45
+ | <%=h oi.quantity %> | <%=h oi.quantity * oi.inventory.price %></li>
46
+ <% end %>
47
+ </ul>
48
+ </p>
49
+ <% end %>
50
+
51
+
52
+
53
+ <%= submit_tag "save" %>
54
+ <% end %>