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
@@ -1,3 +1,19 @@
1
+ # openSteam - http://www.opensteam.net
2
+ # Copyright (C) 2008 DiamondDogs Webconsulting
3
+ #
4
+ # This program is free software; you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; version 2 of the License.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License along
14
+ # with this program; if not, write to the Free Software Foundation, Inc.,
15
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
+
1
17
  class OpensteamGenerator < Rails::Generator::NamedBase
2
18
 
3
19
 
@@ -12,195 +28,109 @@ class OpensteamGenerator < Rails::Generator::NamedBase
12
28
 
13
29
  end
14
30
 
31
+ require 'find'
32
+ require 'yaml'
33
+
34
+ def ffind_in_file(file,*strs)
35
+ if File.file?( file )
36
+ strs.each { |str| File.open(file).grep(/#{str}/) { |line| return :template } }
37
+ return :file
38
+ end
39
+ return :directory
40
+ end
41
+
42
+
15
43
  def manifest
16
44
  record do |m|
17
45
 
18
46
  m.class_collisions class_path, class_name, "#{class_name}Test"
19
47
  m.class_collisions class_path, "#{controller_class_name}"
20
-
21
-
22
-
23
- ### Controllers ###
24
-
25
- ## directories ##
26
- m.directory( File.join('app/controllers', 'administration') )
27
-
28
- # app/controllers/* #
29
- %w(administration webshop checkout ).each { |f|
30
- if f =~ /webshop/
31
- m.template("controllers/#{f}_controller.rb", "app/controllers/#{file_name}_controller.rb" )
32
- else
33
- m.template("controllers/#{f}_controller.rb", "app/controllers/#{f}_controller.rb")
34
- end
35
- }
36
-
37
- # app/controllers/administration/* #
38
- %w( customers inventories orders ).each { |f|
39
- m.file( "controllers/administration/#{f}_controller.rb", "app/controllers/administration/#{f}_controller.rb" )
40
- }
41
-
42
-
43
- ### Helpers ###
44
- m.template( "helpers/webshop_helper.rb", "app/helpers/#{file_name}_helper.rb")
45
-
46
-
47
- ### Initializers ###
48
- m.directory( File.join('config', 'initializers') )
49
- m.file('init/opensteam.rb', 'config/initializers/opensteam.rb')
50
-
51
-
52
-
53
- ### Views ###
54
48
 
55
- ## directories ##
56
- %w( administration layouts checkout administration_mailer common ).each { |f|
57
- m.directory( File.join('app/views',"#{f}") )
58
- }
59
- m.directory( File.join('app/views', file_name) )
60
-
61
- # app/views/administration/* #
62
- %w( _address orders admin_info _nav order show_order_item _update_tree index login products properties signup tree update_products update_properties ).each { |f|
63
- m.file("views/administration/#{f}.html.erb", "app/views/administration/#{f}.html.erb" ) }
64
- m.file("views/administration/update_tree.rjs", "app/views/administration/update_tree.rjs")
65
-
66
- # app/views/layouts/* #
67
- m.template("views/layouts/webshop.html.erb", "app/views/layouts/#{file_name}.html.erb" )
68
- m.template("views/layouts/administration.html.erb", "app/views/layouts/administration.html.erb")
69
-
70
-
71
- # app/views/administration_mailer/* #
72
- %w( order_admin order_customer ).each { |f|
73
- m.file( "views/administration_mailer/#{f}.erb", "app/views/administration_mailer/#{f}.erb")
74
- }
75
-
76
- # app/views/common/* #
77
- %w( _cart _cart_content _header ).each { |f|
78
- m.file( "views/common/#{f}.html.erb", "app/views/common/#{f}.html.erb" )
79
- }
80
-
81
- # app/views/webshop/* #
82
- %w( _inventory_content ).each { |f|
83
- m.file("views/webshop/#{f}.html.erb", "app/views/#{file_name}/#{f}.html.erb" )
84
- }
85
- %w( add_to_cart_with_parameters del_item inventory add_inventory_to_cart ).each { |f|
86
- m.file("views/webshop/#{f}.rjs", "app/views/#{file_name}/#{f}.rjs" )
87
- }
88
- %w( index show ).each { |f|
89
- m.template("views/webshop/#{f}.html.erb", "app/views/#{file_name}/#{f}.html.erb")
90
- }
91
-
92
-
93
- # app/views/checkout/* #
94
- %w( intro outro shipping ).each { |f|
95
- m.file("views/checkout/#{f}.html.erb", "app/views/checkout/#{f}.html.erb")
96
- }
97
- m.template("views/checkout/show_cart.html.erb", "app/views/checkout/show_cart.html.erb")
98
- m.file( "views/checkout/update_cart_content.rjs", "app/views/checkout/update_cart_content.rjs")
99
-
100
-
101
- ## app/views/administration directories ##
102
- %w( inventories customers orders).each do |d|
103
- m.directory( File.join( 'app/views', 'administration', "#{d}") )
49
+ Dir.chdir( File.dirname(__FILE__) )
50
+ Find.find("./templates/" ) do |f|
51
+ ret = ffind_in_file(f, "<%%", "## TEMPLATE ##" )
52
+ f = f.gsub(/^\.\/templates\//,'')
53
+ ret == :directory ? m.send( ret, f =~ /webshop/ ? f.gsub(/webshop/,"#{file_name}") : f ) : m.send(ret,f , f =~ /webshop/ ? f.gsub(/webshop/,"#{file_name}") : f )
104
54
  end
105
55
 
106
- # app/views/administration/inventories/* #
107
- %w( edit index new show ).each do |f|
108
- m.file( "views/administration/inventories/#{f}.html.erb", "app/views/administration/inventories/#{f}.html.erb" )
109
- end
110
56
 
111
-
112
- # app/views/administration/orders/* #
113
- %w( _order_item index show ).each { |f|
114
- m.file( "views/administration/orders/#{f}.html.erb", "app/views/administration/orders/#{f}.html.erb")
115
- }
116
-
117
- # app/views/administration/customers/* #
118
- %w( index show ).each { |f|
119
- m.file( "views/administration/customers/#{f}.html.erb", "app/views/administration/customers/#{f}.html.erb" )
120
- }
121
-
122
- ### Tasks ###
123
- m.file("tasks/opensteam.rake", "lib/tasks/opensteam.rake")
124
-
125
-
126
- ### Fixtures ###
127
- %w( inventories inventories_properties product_animals product_dog_foods properties ).each do |f|
128
- m.file("fixtures/#{f}.yml", "test/fixtures/#{f}.yml")
129
- end
130
-
131
-
132
- ### Public ###
133
- m.directory("public/stylesheets")
134
- m.file("public/stylesheets/webshop.css", "public/stylesheets/#{file_name}.css", :collision => :force )
135
- m.directory("public/images")
136
- %w( bullet_arrow_down bullet_arrow_up cancel minus plus palette folder_database).each { |f|
137
- m.file("public/images/#{f}.png", "public/images/#{f}.png")
138
- }
139
- m.file("public/images/opensteam_logo_web.jpg", "public/images/opensteam_logo_web.jpg")
140
- m.file("public/images/indicator.gif", "public/images/indicator.gif")
141
- m.file("public/index.html", "public/index.html", :collision => :force )
142
-
143
-
144
-
145
- ### Migrations ###
146
- unless options[:skip_migration]
147
- %w( create_properties create_sessions create_orders create_order_items create_addresses
148
- create_users create_payment_types create_customers create_dummy_users
149
- create_inventories create_inventories_properties ).each { |f|
150
- m.migration_template "migrations/#{f}.rb", "db/migrate", :assigns => {
151
- :migration_name => "#{f.classify}" }, :migration_file_name => "#{f}.rb"
152
- }
153
- end
154
-
155
-
156
- ### Routes ###
157
- map_namedroutes(file_name, "/#{file_name}", :controller => "#{file_name}", :action => "index" )
158
- map_namedroutes("logout", "/logout", :controller => "administration", :action => "logout" )
159
- map_namedroutes("login", "/login", :controller => "administration", :action => "login" )
160
- map_namedroutes("signup", "/signup", :controller => "administration", :action => "signup" )
161
- map_namedroutes("administration", "/administration", :controller => "administration", :action => "index" )
162
- map_namedroutes("shop_index", "/#{file_name}", :controller => "#{file_name}", :action => "signup" )
163
- map_namedroutes("#{file_name}_index", "/#{file_name}", :action => "index", :controller => "#{file_name}")
164
- map_namedroutes("opensteam_index", "/#{file_name}", :action => "index", :controller => "#{file_name}")
165
- map_namedroutes("connect", "/administration/:action", :controller => "administration" )
166
- map_namedroutes("connect", "/checkout/:action", :controller => "checkout" )
167
- map_namedroutes("connect", "/#{file_name}/:action", :controller => "#{file_name}" )
168
- map_namedroutes("connect", "/#{file_name}/:action/:type/:id", :controller => "#{file_name}" )
169
- map_namedroutes("connect", "/#{file_name}", :controller => "#{file_name}", :action => "index" )
170
-
171
- administration_routes = <<END_ADMIN_ROUTES
172
- require 'opensteam/finder'
173
- map.namespace :administration do |administration|
174
-
175
- administration.resources :inventories
176
- administration.resources :customers
177
- administration.resources :orders
57
+ administration_routes = <<END_OPENSTEAM_ROUTES
58
+ require 'opensteam/finder'
59
+
60
+ # authentication
61
+ map.logout '/logout', :controller => 'user_sessions', :action => 'destroy'
62
+ map.login '/login', :controller => 'user_sessions', :action => 'new'
63
+ map.register '/register', :controller => 'users', :action => 'create'
64
+ map.signup '/signup', :controller => 'users', :action => 'new'
65
+ # ---
66
+
67
+ map.resources :searches
68
+ map.resources :users, :has_many => [ :orders ]
69
+ map.resources :orders, :belongs_to => [ :users ]
70
+ map.resource :user_session
71
+
72
+ map.cart "/cart", :controller => 'cart', :action => 'index'
73
+ map.order_state '/orders/state/*state', :controller => 'orders', :action => 'index'
74
+ map.connect "/admin", :controller => 'admin', :action => 'index'
75
+ map.show_cart_item '/#{file_name}/show_cart_item/:id', :controller => '#{file_name}', :action => 'show_cart_item'
76
+
77
+ map.namespace :profile do |profile|
78
+ profile.orders_state "orders/state/*state", :controller => 'orders', :action => 'index'
79
+ profile.orders_state_formatted "orders.:format/state/*state", :controller => 'orders', :action => 'index'
80
+ profile.index "profile", :controller => 'profile', :action => 'index'
81
+ profile.resource :infos
82
+ profile.resources :orders
83
+ end
84
+
178
85
 
86
+ map.namespace :admin do |admin|
87
+
88
+ admin.orders_sort "orders/sort/:sort", :controller => 'orders', :action => 'sort'
89
+ admin.users_admins "users/type/admin", :controller => 'users', :action => 'index', :type => 'admin'
90
+ admin.users_customers "users/type/customer", :controller => 'users', :action => 'index', :type => 'customer'
91
+
92
+ admin.resources :inventories
93
+ admin.resources :users, :has_many => [ :orders ]
94
+ admin.resources :orders, :has_many => [ :shipments, :invoices ]
95
+ admin.resources :shipments
96
+ admin.resources :invoices
97
+
179
98
  Opensteam::Find.find_product_tables.collect(&:to_sym).each do |m|
180
99
  if m.to_s.classify.constantize.column_names.include? m.to_s.classify.constantize.inheritance_column
181
100
  m.to_s.classify.constantize.find(:all).collect(&:type).collect(&:tableize).uniq.collect(&:to_sym).each do |mm|
182
- administration.resources mm, :controller => m
101
+ admin.resources mm, :controller => m
102
+ end
183
103
  end
104
+ admin.resources m
184
105
  end
185
- administration.resources m
186
- end
187
106
 
188
- Opensteam::Find.find_property_tables.collect(&:to_sym).each do |m|
189
- administration.resources m
107
+ Opensteam::Find.find_property_tables.collect(&:to_sym).each do |m|
108
+ admin.resources m
109
+ end
110
+
190
111
  end
191
-
192
- end
193
- END_ADMIN_ROUTES
112
+
113
+ map.#{file_name} "/#{file_name}", :controller => "#{file_name}", :action => "index"
114
+ map.connect "/#{file_name}/:action/:type/:id", :controller => "#{file_name}"
115
+ map.connect "/#{file_name}/:action", :controller => "#{file_name}"
116
+ map.connect "/checkout/:action", :controller => "checkout"
117
+
118
+ map.opensteam_index "/#{file_name}", :controller => "#{file_name}", :action=>"index"
119
+ map.#{file_name}_index "/#{file_name}", :controller => "#{file_name}", :action=>"index"
120
+ map.connect "/store", :controller => "#{file_name}", :action => "index"
121
+ map.shop_index "/#{file_name}", :controller => "#{file_name}", :action => "index"
122
+ map.admin "/admin", :controller=>"admin", :action=>"index"
123
+ map.administration "/admin", :controller=>"admin", :action=>"index"
124
+
125
+ END_OPENSTEAM_ROUTES
194
126
 
195
127
  map_namespaceroutes( administration_routes )
196
-
197
-
198
128
 
199
129
 
200
130
  ### Patch application.rb ###
201
131
  sentinel = 'class ApplicationController < ActionController::Base'
202
132
  app_contr = 'app/controllers/application.rb'
203
- incl = 'include Opensteam::UserBase::Helper'
133
+ incl = "layout '#{file_name}'\n\n public :render_to_string\n include AuthenticatedSystem\n helper :all\n"
204
134
  gsub_file app_contr, /(#{Regexp.escape(sentinel)})/mi do |match|
205
135
  "#{match}\n #{incl}"
206
136
  end
@@ -208,19 +138,8 @@ END_ADMIN_ROUTES
208
138
 
209
139
  ### Patch environment.rb ###
210
140
  sentinel = 'Rails::Initializer.run do |config|'
211
-
212
- # incl = 'RAILS_DEFAULT_LOGGER = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log") unless defined? RAILS_DEFAULT_LOGGER'
213
- # incl += "\nrequire 'has_many_polymorphs'"
214
141
  incl = "require 'opensteam'"
215
-
216
- incl2 = " config.after_initialize do"
217
- incl2 += "\n require 'opensteam/user_base'"
218
- incl2 += "\n require 'opensteam/shopping_cart'"
219
- incl2 += "\n require 'opensteam/checkout'"
220
- incl2 += "\n end\n\n"
221
-
222
142
  gsub_file 'config/environment.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
223
- # "#{incl}\n\n#{match}\n\n#{incl2}"
224
143
  "#{incl}\n\n#{match}\n"
225
144
  end
226
145
 
@@ -251,24 +170,6 @@ END_ADMIN_ROUTES
251
170
  end
252
171
  end
253
172
  end
254
-
255
-
256
- def map_namedroutes(name, path, *r)
257
- route_list = r.inspect.gsub(/[\[\]{}]/, " ")
258
- sentinel = 'ActionController::Routing::Routes.draw do |map|'
259
-
260
- logger.route "map.#{name} \"#{path}\", #{route_list}"
261
- unless options[:pretend]
262
- gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
263
- "#{match}\n map.#{name} \"#{path}\", #{route_list}\n"
264
- end
265
- end
266
- end
267
-
268
- def map_customroutes
269
- end
270
-
271
-
272
173
 
273
174
 
274
175
  # Override with your own usage banner.
@@ -1,4 +1,4 @@
1
- class Administration::InventoriesController < AdministrationController
1
+ class Admin::InventoriesController < AdminController
2
2
  # GET /inventories
3
3
  # GET /inventories.xml
4
4
 
@@ -48,7 +48,7 @@ class Administration::InventoriesController < AdministrationController
48
48
  respond_to do |format|
49
49
  if @inventory.save
50
50
  flash[:notice] = 'Inventory was successfully created.'
51
- format.html { redirect_to( administration_inventory_path( @inventory ) ) }
51
+ format.html { redirect_to( admin_inventory_path( @inventory ) ) }
52
52
  format.xml { render :xml => @inventory, :status => :created, :location => @inventory }
53
53
  else
54
54
  format.html { render :action => "new" }
@@ -65,7 +65,7 @@ class Administration::InventoriesController < AdministrationController
65
65
  respond_to do |format|
66
66
  if @inventory.update_attributes(params[:inventory])
67
67
  flash[:notice] = 'Inventory was successfully updated.'
68
- format.html { redirect_to( administration_inventory_path( @inventory ) ) }
68
+ format.html { redirect_to( admin_inventory_path( @inventory ) ) }
69
69
  format.xml { head :ok }
70
70
  else
71
71
  format.html { render :action => "edit" }
@@ -81,7 +81,7 @@ class Administration::InventoriesController < AdministrationController
81
81
  @inventory.destroy
82
82
 
83
83
  respond_to do |format|
84
- format.html { redirect_to(administration_inventories_url) }
84
+ format.html { redirect_to(admin_inventories_url) }
85
85
  format.xml { head :ok }
86
86
  end
87
87
  end
@@ -0,0 +1,106 @@
1
+ class Admin::InvoicesController < AdminController
2
+
3
+
4
+ include Opensteam::Helper::ConfigurableTableController
5
+
6
+ def sort
7
+ if params[:sort]
8
+ if params[:order_id]
9
+ @order = Order.find( params[:order_id] )
10
+ conditions = { :order_id => params[:order_id] }
11
+ end
12
+ @results = sort_model( Invoice, @sort_column, conditions )
13
+ @invoices = @results
14
+ end
15
+
16
+ respond_to do |respond|
17
+ respond.html { render :action => :sort }
18
+ respond.js { render :partial => "invoice", :collection => @results, :layout => false }
19
+ end
20
+
21
+ end
22
+
23
+
24
+ def index
25
+ @invoices ||= Opensteam::InvoiceBase::Invoice.find( :all )
26
+ @order = Opensteam::OrderBase::Order.find( params[:order_id] ) if params[:order_id]
27
+
28
+ respond_to do |format|
29
+ format.html # index.html.erb
30
+ format.xml { render :xml => @invoices }
31
+ format.js { render :partial => "invoices", :layout => false }
32
+ end
33
+ end
34
+
35
+
36
+ def show
37
+ @order = Opensteam::OrderBase::Order.find( params[:order_id] )
38
+ @invoice ||= Opensteam::InvoiceBase::Invoice.find( params[:id] )
39
+
40
+ respond_to do |format|
41
+ format.html # show.html.erb
42
+ format.xml { render :xml => @invoice.to_xml( :root => 'invoice' ) }
43
+ end
44
+ end
45
+
46
+
47
+ def new
48
+ @order = Opensteam::OrderBase::Order.find( params[:order_id] )
49
+ @invoice = @order.invoices.new
50
+
51
+ if @order.order_items.all_invoiced?
52
+ flash[:error] = "Cannot create invoice : All order-items have an invoice!"
53
+ redirect_to admin_order_path( @order )
54
+ end
55
+
56
+ end
57
+
58
+
59
+
60
+ def create
61
+ @order = Opensteam::OrderBase::Order.find( params[:order_id] )
62
+ @invoice = @order.invoices.new( params[:invoice] )
63
+ @address = @invoice.address
64
+
65
+ @order_items = @order.order_items.select { |o|
66
+ params[:order_items].keys.include?( o.id.to_s ) && params[:order_items][ o.id.to_s ] == "1"
67
+ }
68
+
69
+ @invoice.order_items << @order_items
70
+
71
+ ret = @address.update_attributes( params[:address] ) &&
72
+ @invoice.save
73
+
74
+
75
+
76
+ respond_to do |format|
77
+ if ret
78
+ flash[:notice] = 'Invoice was successfully created.'
79
+ format.html { redirect_to( admin_order_path( @order ) ) }
80
+ format.xml { render :xml => @invoice.to_xml( :root => 'invoice') , :status => :created, :location => @invoice }
81
+ else
82
+ format.html { render :action => "new" }
83
+ format.xml { render :xml => @invoice.errors, :status => :unprocessable_entity }
84
+ end
85
+ end
86
+
87
+ end
88
+
89
+ def update
90
+ @invoice = Opensteam::InvoiceBase::Invoice.find( params[:id] )
91
+
92
+ respond_to do |format|
93
+ if @invoice.update_attributes( params[:invoice] )
94
+ format.html { redirect_to( admin_order_path( @invoice.order ) ) }
95
+ format.xml { head :ok }
96
+ else
97
+ format.html { render :action => "show" }
98
+ format.xml { render :xml => @invoice.errors, :status => :unprocessable_entity }
99
+ end
100
+ end
101
+
102
+
103
+ end
104
+
105
+
106
+ end
@@ -0,0 +1,113 @@
1
+ class Admin::OrdersController < AdminController
2
+
3
+
4
+
5
+ include Opensteam::Helper::ConfigurableTableController
6
+
7
+ helper :all
8
+
9
+
10
+
11
+ def livesearch
12
+ if params[:livesearch]
13
+
14
+ @result = Order.find(:all, :include => [:customer, :shipping_address, :payment_address ] )
15
+
16
+ @result = @result.select { |s|
17
+ Order.configured_table.columns.collect { |c|
18
+ seek = s.__send__( c.id )
19
+ seek = seek.__send__( c.method ) if c.method
20
+ seek.to_s.include?( params[:livesearch] )
21
+ }.any?
22
+ }
23
+ render :partial => 'order', :collection => @result, :layout => false
24
+ end
25
+
26
+ end
27
+
28
+
29
+
30
+
31
+ def sort
32
+
33
+ if params[:sort]
34
+ if params[:user_id]
35
+ @customer = Opensteam::UserBase::User.find( params[:user_id] )
36
+ conditions = { :customer_id => params[:customer_id] }
37
+ end
38
+ @results = sort_model( Order, @sort_column, conditions, [:customer, :payment_address, :shipping_address ] )
39
+ @orders = @results
40
+ end
41
+
42
+ respond_to do |respond|
43
+ respond.html { render :action => :sort }
44
+ respond.js { render :partial => "order", :collection => @results, :layout => false }
45
+ end
46
+
47
+ end
48
+
49
+
50
+ def index
51
+ if params[:user_id]
52
+ @customer = Opensteam::UserBase::User.find( params[:user_id] )
53
+ @orders = @customer.orders
54
+ else
55
+ @orders ||= find_orders
56
+ end
57
+
58
+ respond_to do |format|
59
+ format.html # index.html.erb
60
+ format.xml { render :xml => @orders }
61
+ format.js { render :partial => "orders", :layout => false }
62
+ end
63
+ end
64
+
65
+
66
+ def show
67
+ @order ||= Opensteam::OrderBase::Order.find( params[:id] )
68
+
69
+ respond_to do |format|
70
+ format.html # show.html.erb
71
+ format.xml { render :xml => @order }
72
+ end
73
+ end
74
+
75
+
76
+
77
+ def update
78
+ @order = Opensteam::OrderBase::Order.find( params[:id] )
79
+
80
+ respond_to do |format|
81
+ if @order.update_attributes( params[:order] )
82
+ format.html { redirect_to admin_order_path( @order ) }
83
+ format.xml { head :ok }
84
+ else
85
+ format.html { render :action => "show" }
86
+ format.xml { render :xml => @order.errors, :status => :unprocessable_entity }
87
+ end
88
+ end
89
+
90
+
91
+ end
92
+
93
+
94
+ private
95
+
96
+ def find_orders
97
+ if params[:filter] && (params[:filter][:enabled] == "1")
98
+ params[:state] = params[:filter][:state] || [""]
99
+ params[:last] = params[:filter][:last] unless params[:filter][:last].blank?
100
+ end
101
+
102
+ scope = Opensteam::OrderBase::Order.scoped({})
103
+
104
+ scope = scope.scoped :include => :state, :conditions => ["state_bases.name in (?)", params[:state] ] if params[:state]
105
+
106
+ scope = scope.scoped :order => :state_id if params[:state]
107
+ scope = scope.scoped :conditions => { :customer_id => params[:customer_id] } if params[:customer_id]
108
+ scope = scope.scoped :conditions => ["orders.created_at >= ?", 1.send(params[:last]).ago ] if params[:last]
109
+ # scope = scope.scoped :conditions => [ "orders.created_at < ?", params[:before]] if params[:before]
110
+ scope = scope.scoped :include => :customer
111
+ end
112
+
113
+ end
@@ -0,0 +1,17 @@
1
+ class Admin::SearchController < AdminController
2
+
3
+
4
+ def sort
5
+ if params[:sort]
6
+ model = params[:model].demodulize.classify.constantize rescue nil
7
+ @result = sort_model( model, @sort_column )
8
+ end
9
+ render :partial => params[:partial], :collection => @result
10
+ end
11
+
12
+
13
+
14
+
15
+
16
+
17
+ end