artfully_ose 1.1.0 → 1.2.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (719) hide show
  1. checksums.yaml +13 -5
  2. data/README.md +28 -0
  3. data/app/assets/fonts/FontAwesome.otf +0 -0
  4. data/app/assets/fonts/fontawesome-webfont.eot +0 -0
  5. data/app/assets/fonts/fontawesome-webfont.svg +472 -252
  6. data/app/assets/fonts/fontawesome-webfont.ttf +0 -0
  7. data/app/assets/fonts/fontawesome-webfont.woff +0 -0
  8. data/app/assets/images/actions/do.png +0 -0
  9. data/app/assets/images/actions/do.psd +0 -0
  10. data/app/assets/images/actions/get.png +0 -0
  11. data/app/assets/images/actions/get.psd +0 -0
  12. data/app/assets/images/actions/give.png +0 -0
  13. data/app/assets/images/actions/give.psd +0 -0
  14. data/app/assets/images/actions/go.png +0 -0
  15. data/app/assets/images/actions/go.psd +0 -0
  16. data/app/assets/images/actions/hear.png +0 -0
  17. data/app/assets/images/actions/hear.psd +0 -0
  18. data/app/assets/images/actions/join.png +0 -0
  19. data/app/assets/images/actions/join.psd +0 -0
  20. data/app/assets/images/actions/say.png +0 -0
  21. data/app/assets/images/actions/say.psd +0 -0
  22. data/app/assets/images/business-default-avatar.png +0 -0
  23. data/app/assets/images/foundation-default-avatar.png +0 -0
  24. data/app/assets/images/glyphish/people/208-facebook.png +0 -0
  25. data/app/assets/images/glyphish/people/210-twitterbird.png +0 -0
  26. data/app/assets/images/glyphish/people/218-trash2-small.png +0 -0
  27. data/app/assets/images/glyphish/people/291-idcard.png +0 -0
  28. data/app/assets/images/glyphish/people/email.png +0 -0
  29. data/app/assets/images/glyphish/people/email.psd +0 -0
  30. data/app/assets/images/glyphish/people/linkedin.png +0 -0
  31. data/app/assets/images/glyphish/people/linkedin.psd +0 -0
  32. data/app/assets/images/glyphish/people/website.png +0 -0
  33. data/app/assets/images/glyphish/people/website.psd +0 -0
  34. data/app/assets/images/government-default-avatar.png +0 -0
  35. data/app/assets/images/household-default-avatar.png +0 -0
  36. data/app/assets/images/loading.gif +0 -0
  37. data/app/assets/images/nonprofit-default-avatar.png +0 -0
  38. data/app/assets/images/other-default-avatar.png +0 -0
  39. data/app/assets/images/person-default-avatar.png +0 -0
  40. data/app/assets/images/person-default-avatar.psd +0 -0
  41. data/app/assets/javascripts/angular-bootstrap-ui.js +1 -0
  42. data/app/assets/javascripts/angular-resource.js +546 -0
  43. data/app/assets/javascripts/angular.js +20311 -0
  44. data/app/assets/javascripts/application.js +340 -24
  45. data/app/assets/javascripts/bootstrap-wysihtml5.js +511 -0
  46. data/app/assets/javascripts/bootstrap.js +1005 -455
  47. data/app/assets/javascripts/boxoffice.js +558 -0
  48. data/app/assets/javascripts/change-membership.js +152 -0
  49. data/app/assets/javascripts/custom/door-list.js +14 -0
  50. data/app/assets/javascripts/custom/endless-scroll.js +25 -0
  51. data/app/assets/javascripts/custom/inline-people-search.js +51 -49
  52. data/app/assets/javascripts/custom/kits-config.js +33 -0
  53. data/app/assets/javascripts/custom/people.js +74 -9
  54. data/app/assets/javascripts/custom/prices.js +1 -0
  55. data/app/assets/javascripts/custom/show.js +116 -27
  56. data/app/assets/javascripts/households.js +59 -0
  57. data/app/assets/javascripts/jquery-lib/fullcalendar.js +5982 -0
  58. data/app/assets/javascripts/jquery-lib/jquery-ui-1.10.3.custom.min.js +7 -0
  59. data/app/assets/javascripts/jquery-lib/jquery-ui-timepicker-addon.js +1992 -949
  60. data/app/assets/javascripts/jquery-lib/jquery.mask-money.js +305 -294
  61. data/app/assets/javascripts/jquery-migrate-1.2.1.js +521 -0
  62. data/app/assets/javascripts/jquery-migrate-1.2.1.min.js +2 -0
  63. data/app/assets/javascripts/jquery.js +5318 -4987
  64. data/app/assets/javascripts/locationselector.js +107 -0
  65. data/app/assets/javascripts/relationships.js +63 -0
  66. data/app/assets/javascripts/sales-console.js +158 -0
  67. data/app/assets/javascripts/store/jquery.validate.additional-methods.js +476 -159
  68. data/app/assets/javascripts/store/jquery.validate.js +449 -406
  69. data/app/assets/javascripts/store/store.js +107 -349
  70. data/app/assets/javascripts/storefront.js +1 -0
  71. data/app/assets/javascripts/wysihtml5-0.3.0.min.js +261 -0
  72. data/app/assets/stylesheets/application.sass +414 -48
  73. data/app/assets/stylesheets/bootstrap-overrides.css +100 -26
  74. data/app/assets/stylesheets/bootstrap-wysihtml5.css +102 -0
  75. data/app/assets/stylesheets/bootstrap.css +6 -3607
  76. data/app/assets/stylesheets/boxoffice.css.scss +258 -0
  77. data/app/assets/stylesheets/font-awesome.css.scss +1566 -0
  78. data/app/assets/stylesheets/jquery/fullcalendar.css +223 -252
  79. data/app/assets/stylesheets/pages/bootstrap-responsive.css +1109 -0
  80. data/app/assets/stylesheets/sass/_event_list.sass +43 -0
  81. data/app/assets/stylesheets/sass/_tags.sass +24 -2
  82. data/app/assets/stylesheets/sass/box-office.sass +24 -4
  83. data/app/assets/stylesheets/sass/cart.sass +0 -6
  84. data/app/assets/stylesheets/sass/store.sass +274 -55
  85. data/app/assets/stylesheets/storefront.css +2 -1
  86. data/app/assets/stylesheets/wysiwyg-color.css +67 -0
  87. data/app/concerns/cart_finder.rb +50 -0
  88. data/app/concerns/immutable_action.rb +9 -0
  89. data/app/concerns/pdf_generation.rb +74 -0
  90. data/app/{models/orders → concerns}/unrefundable.rb +0 -0
  91. data/app/controllers/actions_controller.rb +29 -22
  92. data/app/controllers/addresses_controller.rb +3 -3
  93. data/app/controllers/artfully_ose_controller.rb +56 -7
  94. data/app/controllers/assignments_controller.rb +28 -0
  95. data/app/controllers/charts_controller.rb +1 -1
  96. data/app/controllers/console_sales_controller.rb +182 -0
  97. data/app/controllers/contributions_controller.rb +31 -6
  98. data/app/controllers/discounts_controller.rb +10 -3
  99. data/app/controllers/events_controller.rb +42 -33
  100. data/app/controllers/events_pass_types_controller.rb +87 -0
  101. data/app/controllers/exchanges_controller.rb +16 -8
  102. data/app/controllers/export_controller.rb +10 -2
  103. data/app/controllers/households_controller.rb +71 -0
  104. data/app/controllers/imports_controller.rb +46 -7
  105. data/app/controllers/index_controller.rb +6 -1
  106. data/app/controllers/member_cards_controller.rb +45 -0
  107. data/app/controllers/members/index_controller.rb +4 -0
  108. data/app/controllers/members/invitations_controller.rb +7 -0
  109. data/app/controllers/members/members_controller.rb +9 -0
  110. data/app/controllers/members/passwords_controller.rb +10 -0
  111. data/app/controllers/members/people_controller.rb +17 -0
  112. data/app/controllers/members/sessions_controller.rb +14 -0
  113. data/app/controllers/membership_cancellations_controller.rb +46 -0
  114. data/app/controllers/membership_changes_controller.rb +39 -0
  115. data/app/controllers/membership_comps_controller.rb +102 -0
  116. data/app/controllers/membership_kits_controller.rb +25 -0
  117. data/app/controllers/membership_types_controller.rb +57 -0
  118. data/app/controllers/memberships_controller.rb +18 -47
  119. data/app/controllers/merges_controller.rb +11 -5
  120. data/app/controllers/mobile/dashboard_controller.rb +17 -0
  121. data/app/controllers/mobile/events_controller.rb +16 -0
  122. data/app/controllers/mobile/orders_controller.rb +61 -0
  123. data/app/controllers/mobile/shows_controller.rb +39 -0
  124. data/app/controllers/mobile/tickets_controller.rb +114 -0
  125. data/app/controllers/mobile/users_controller.rb +30 -0
  126. data/app/controllers/notes_controller.rb +3 -3
  127. data/app/controllers/orders_controller.rb +87 -8
  128. data/app/controllers/organizations_controller.rb +3 -2
  129. data/app/controllers/pass_types_controller.rb +53 -0
  130. data/app/controllers/passes_controller.rb +52 -0
  131. data/app/controllers/passes_kits_controller.rb +25 -0
  132. data/app/controllers/passes_reports_controller.rb +5 -0
  133. data/app/controllers/people_controller.rb +83 -28
  134. data/app/controllers/refunds_controller.rb +7 -7
  135. data/app/controllers/regular_donation_kits_controller.rb +32 -0
  136. data/app/controllers/relationships_controller.rb +15 -0
  137. data/app/controllers/sales_controller.rb +95 -31
  138. data/app/controllers/searches_controller.rb +15 -7
  139. data/app/controllers/sections_controller.rb +3 -3
  140. data/app/controllers/segments_controller.rb +4 -4
  141. data/app/controllers/shows_controller.rb +119 -98
  142. data/app/controllers/slices_controller.rb +3 -2
  143. data/app/controllers/statements_controller.rb +1 -1
  144. data/app/controllers/store/checkouts_controller.rb +27 -8
  145. data/app/controllers/store/donations_controller.rb +22 -0
  146. data/app/controllers/store/events_controller.rb +19 -1
  147. data/app/controllers/store/memberships_controller.rb +16 -0
  148. data/app/controllers/store/orders_controller.rb +46 -77
  149. data/app/controllers/store/passes_controller.rb +13 -0
  150. data/app/controllers/store/retrievals_controller.rb +29 -0
  151. data/app/controllers/store/shows_controller.rb +6 -0
  152. data/app/controllers/store/store_controller.rb +21 -23
  153. data/app/controllers/ticket_types_controller.rb +41 -0
  154. data/app/controllers/tickets_controller.rb +16 -0
  155. data/app/controllers/user_memberships_controller.rb +57 -0
  156. data/app/controllers/users/sessions_controller.rb +3 -0
  157. data/app/helpers/artfully_ose_helper.rb +88 -37
  158. data/app/helpers/households_helper.rb +7 -0
  159. data/app/helpers/link_helper.rb +15 -1
  160. data/app/helpers/members_helper.rb +9 -0
  161. data/app/helpers/membership_types_helper.rb +22 -0
  162. data/app/helpers/people_helper.rb +55 -1
  163. data/app/helpers/relationships_helper.rb +26 -0
  164. data/app/helpers/sales_helper.rb +29 -0
  165. data/app/helpers/searches_helper.rb +13 -0
  166. data/app/helpers/suggested_households_helper.rb +5 -0
  167. data/app/mailers/order_mailer.rb +28 -1
  168. data/app/mailers/pass_mailer.rb +17 -0
  169. data/app/mailers/producer_mailer.rb +2 -2
  170. data/app/mailers/reports_mailer.rb +6 -5
  171. data/app/models/ability.rb +1 -0
  172. data/app/models/action.rb +48 -24
  173. data/app/models/actions/change_action.rb +13 -0
  174. data/app/models/actions/comp_action.rb +15 -0
  175. data/app/models/actions/do_action.rb +12 -0
  176. data/app/models/actions/exchange_action.rb +15 -0
  177. data/app/models/actions/get_action.rb +7 -1
  178. data/app/models/actions/give_action.rb +20 -4
  179. data/app/models/actions/go_action.rb +27 -8
  180. data/app/models/actions/hear_action.rb +14 -2
  181. data/app/models/actions/join_action.rb +4 -0
  182. data/app/models/actions/refund_action.rb +2 -1
  183. data/app/models/actions/say_action.rb +23 -0
  184. data/app/models/address.rb +39 -9
  185. data/app/models/cart.rb +254 -0
  186. data/app/models/chart.rb +30 -23
  187. data/app/models/checkout.rb +94 -38
  188. data/app/models/comp.rb +25 -17
  189. data/app/models/company.rb +18 -0
  190. data/app/models/console_sale.rb +30 -0
  191. data/app/models/contribution.rb +11 -9
  192. data/app/models/daily_donation_report.rb +11 -8
  193. data/app/models/daily_membership_report.rb +50 -0
  194. data/app/models/daily_pass_report.rb +48 -0
  195. data/app/models/daily_ticket_report.rb +34 -14
  196. data/app/models/database_views/item_view.rb +148 -0
  197. data/app/models/discount.rb +7 -7
  198. data/app/models/discounts/buy_one_get_one_free_discount_type.rb +6 -1
  199. data/app/models/discounts/discount_type.rb +5 -1
  200. data/app/models/discounts/dollars_off_tickets_discount_type.rb +8 -2
  201. data/app/models/donation.rb +10 -6
  202. data/app/models/donation_search.rb +1 -1
  203. data/app/models/door_list.rb +14 -9
  204. data/app/models/event.rb +81 -10
  205. data/app/models/events_pass_type.rb +18 -0
  206. data/app/models/exchange.rb +23 -15
  207. data/app/models/{ext/ext.rb → ext.rb} +16 -3
  208. data/app/models/ext/integrations.rb +47 -32
  209. data/app/models/ext/preprocessor.rb +7 -0
  210. data/app/models/extendable.rb +6 -0
  211. data/app/models/fee_calculator.rb +13 -0
  212. data/app/models/fee_strategy.rb +5 -0
  213. data/app/models/gateway_transaction.rb +3 -1
  214. data/app/models/household.rb +61 -0
  215. data/app/models/household_suggester.rb +58 -0
  216. data/app/models/import.rb +48 -15
  217. data/app/models/import_message.rb +6 -0
  218. data/app/models/imports/donations_import.rb +3 -22
  219. data/app/models/imports/events_import.rb +56 -57
  220. data/app/models/imports/memberships_import.rb +43 -0
  221. data/app/models/imports/people_import.rb +45 -17
  222. data/app/models/imports/rollback.rb +7 -2
  223. data/app/models/imports/status.rb +8 -0
  224. data/app/models/individual.rb +20 -0
  225. data/app/models/item.rb +65 -54
  226. data/app/models/job/checkout_processor.rb +46 -0
  227. data/app/models/job/cleanup_suggested_households_job.rb +17 -0
  228. data/app/models/job/daily_email_report_job.rb +28 -7
  229. data/app/models/job/destroy_show_job.rb +10 -0
  230. data/app/models/job/expire_ticket_job.rb +9 -0
  231. data/app/models/job/geocode_address_job.rb +11 -0
  232. data/app/models/job/mailchimp_sync_job.rb +1 -3
  233. data/app/models/job/order_mailer_job.rb +8 -0
  234. data/app/models/job/order_processor.rb +93 -0
  235. data/app/models/job/person_lifetime_value_job.rb +10 -0
  236. data/app/models/job/recall_import_job.rb +5 -0
  237. data/app/models/job/refund_order_processor.rb +16 -0
  238. data/app/models/job/show_creator.rb +39 -0
  239. data/app/models/kit.rb +2 -4
  240. data/app/models/kits/mailchimp_kit.rb +49 -22
  241. data/app/models/kits/membership_kit.rb +62 -0
  242. data/app/models/kits/passes_kit.rb +62 -0
  243. data/app/models/kits/regular_donation_kit.rb +38 -8
  244. data/app/models/kits/scannable_tickets_kit.rb +23 -0
  245. data/app/models/member.rb +190 -0
  246. data/app/models/member_card_generator.rb +63 -0
  247. data/app/models/member_number_generator.rb +8 -0
  248. data/app/models/member_walkup.rb +150 -0
  249. data/app/models/membership.rb +97 -7
  250. data/app/models/membership_cancellation.rb +80 -0
  251. data/app/models/membership_change.rb +187 -0
  252. data/app/models/membership_comp.rb +105 -0
  253. data/app/models/membership_comp_job.rb +32 -0
  254. data/app/models/membership_sale_search.rb +36 -0
  255. data/app/models/membership_type.rb +67 -0
  256. data/app/models/note.rb +1 -1
  257. data/app/models/{orders/order.rb → order.rb} +224 -28
  258. data/app/models/order_handler.rb +154 -0
  259. data/app/models/orders/comp_order.rb +4 -0
  260. data/app/models/orders/exchange_order.rb +16 -0
  261. data/app/models/orders/imported_order.rb +4 -0
  262. data/app/models/orders/refund_order.rb +8 -0
  263. data/app/models/organization.rb +68 -17
  264. data/app/models/organization_ability.rb +1 -0
  265. data/app/models/parsed_row.rb +103 -20
  266. data/app/models/pass.rb +196 -0
  267. data/app/models/pass_summary.rb +18 -0
  268. data/app/models/pass_type.rb +41 -0
  269. data/app/models/{payments/payment.rb → payment.rb} +29 -1
  270. data/app/models/payments/cash_payment.rb +3 -1
  271. data/app/models/payments/check_payment.rb +33 -0
  272. data/app/models/payments/comp_payment.rb +3 -1
  273. data/app/models/payments/credit_card_payment.rb +44 -23
  274. data/app/models/person.rb +270 -62
  275. data/app/models/phone.rb +0 -8
  276. data/app/models/refund.rb +28 -18
  277. data/app/models/relation.rb +27 -0
  278. data/app/models/relation_builder.rb +32 -0
  279. data/app/models/relationship.rb +55 -0
  280. data/app/models/relationship_builder.rb +12 -0
  281. data/app/models/relationship_validator.rb +46 -0
  282. data/app/models/relationships_kit.rb +31 -0
  283. data/app/models/rolling_membership_type.rb +11 -0
  284. data/app/models/sale.rb +28 -21
  285. data/app/models/sale_search.rb +1 -1
  286. data/app/models/search.rb +334 -45
  287. data/app/models/seasonal_membership_type.rb +3 -0
  288. data/app/models/section.rb +49 -17
  289. data/app/models/segment.rb +1 -1
  290. data/app/models/show.rb +93 -16
  291. data/app/models/slices.rb +26 -10
  292. data/app/models/statement.rb +38 -9
  293. data/app/models/suggested_household.rb +24 -0
  294. data/app/models/sundial.rb +12 -0
  295. data/app/models/ticket.rb +109 -15
  296. data/app/models/ticket/glance.rb +1 -2
  297. data/app/models/ticket/locker.rb +51 -0
  298. data/app/models/ticket/pricing.rb +30 -22
  299. data/app/models/ticket/qr_code.rb +21 -0
  300. data/app/models/ticket/reports.rb +16 -10
  301. data/app/models/ticket/sale_transitions.rb +4 -0
  302. data/app/models/ticket/template.rb +1 -0
  303. data/app/models/ticket/transfers.rb +12 -1
  304. data/app/models/ticket_summary.rb +7 -1
  305. data/app/models/ticket_type.rb +137 -0
  306. data/app/models/user.rb +22 -9
  307. data/app/models/user_membership.rb +28 -0
  308. data/app/models/valuation/lifetime_donations.rb +2 -2
  309. data/app/models/valuation/lifetime_fees.rb +40 -0
  310. data/app/models/valuation/lifetime_memberships.rb +24 -0
  311. data/app/models/valuation/lifetime_ticket_value.rb +30 -0
  312. data/app/models/valuation/lifetime_value.rb +3 -8
  313. data/app/models/venue.rb +25 -7
  314. data/app/presenters/event_presenter.rb +1 -1
  315. data/app/serializers/show_serializer.rb +15 -0
  316. data/app/views/actions/_action.html.haml +21 -0
  317. data/app/views/actions/_form.html.haml +47 -0
  318. data/app/views/actions/_inline.html.haml +1 -0
  319. data/app/views/actions/_modal.html.haml +5 -0
  320. data/app/views/actions/get/_show.html.haml +3 -0
  321. data/app/views/actions/give/_show.html.haml +8 -0
  322. data/app/views/actions/shared/_show.html.haml +5 -0
  323. data/app/views/addresses/_address.html.haml +7 -6
  324. data/app/views/assignments/new.html.haml +31 -0
  325. data/app/views/console_sales/_aloha.html.haml +26 -0
  326. data/app/views/console_sales/_cart.html.haml +60 -0
  327. data/app/views/console_sales/_payment.html.haml +111 -0
  328. data/app/views/console_sales/_shows.html.haml +24 -0
  329. data/app/views/console_sales/new.html.haml +143 -0
  330. data/app/views/contributions/_form.html.haml +3 -3
  331. data/app/views/contributions/find_person.html.haml +1 -1
  332. data/app/views/contributions/index.html.haml +8 -6
  333. data/app/views/contributions/new.html.haml +5 -9
  334. data/app/views/discounts/_discount_section_fields.html.haml +1 -1
  335. data/app/views/discounts/_form.html.haml +3 -3
  336. data/app/views/discounts/index.html.haml +1 -1
  337. data/app/views/events/_day_date_show.html.haml +2 -2
  338. data/app/views/events/_discount_section_fields.html.haml +1 -1
  339. data/app/views/events/_glance.html.haml +28 -37
  340. data/app/views/events/_header.html.haml +1 -0
  341. data/app/views/events/_list.html.haml +11 -5
  342. data/app/views/events/_menu.html.haml +25 -20
  343. data/app/views/events/_section_fields.html.haml +16 -46
  344. data/app/views/events/_share_and_sell.haml +9 -5
  345. data/app/views/events/_ticket_type_fields.html.haml +86 -0
  346. data/app/views/events/edit.html.haml +13 -3
  347. data/app/views/events/image.html.haml +4 -3
  348. data/app/views/events/index.html.haml +20 -3
  349. data/app/views/events/messages.html.haml +2 -2
  350. data/app/views/events/prices.html.haml +4 -12
  351. data/app/views/events/show.html.haml +3 -1
  352. data/app/views/events/storefront_link.html.haml +1 -1
  353. data/app/views/events/temp_discount_form.html.haml +1 -1
  354. data/app/views/events/temp_discounts_index.html.haml +1 -1
  355. data/app/views/events_pass_types/_form.html.haml +42 -0
  356. data/app/views/events_pass_types/edit.html.haml +22 -0
  357. data/app/views/events_pass_types/index.html.haml +47 -0
  358. data/app/views/events_pass_types/new.html.haml +22 -0
  359. data/app/views/exchanges/new.html.haml +58 -35
  360. data/app/views/households/_action.html.haml +24 -0
  361. data/app/views/households/_edit_modal.html.haml +143 -0
  362. data/app/views/households/_form.html.haml +26 -0
  363. data/app/views/households/_header.html.haml +25 -0
  364. data/app/views/households/_individual_fields.html.haml +8 -0
  365. data/app/views/households/_list.html.haml +10 -0
  366. data/app/views/households/_note.html.haml +33 -0
  367. data/app/views/households/edit.html.haml +1 -0
  368. data/app/views/households/index.html.haml +13 -0
  369. data/app/views/households/new.html.haml +14 -0
  370. data/app/views/households/show.html.haml +72 -0
  371. data/app/views/households/suggested.html.haml +38 -0
  372. data/app/views/imports/_export_links.html.haml +3 -0
  373. data/app/views/imports/donations/_new.html.haml +6 -0
  374. data/app/views/imports/donations/_pending.html.haml +6 -22
  375. data/app/views/imports/events/_new.html.haml +7 -1
  376. data/app/views/imports/events/_pending.html.haml +6 -17
  377. data/app/views/imports/index.html.haml +6 -3
  378. data/app/views/imports/people/_imported.html.haml +35 -5
  379. data/app/views/imports/people/_importing.html.haml +8 -0
  380. data/app/views/imports/people/_new.html.haml +61 -21
  381. data/app/views/imports/people/_pending.html.haml +26 -20
  382. data/app/views/imports/people/_recalled.html.haml +25 -0
  383. data/app/views/imports/people/_recalling.html.haml +15 -0
  384. data/app/views/imports/shared/_knowledge_base.haml +11 -2
  385. data/app/views/imports/shared/_sidebar.html.haml +1 -1
  386. data/app/views/index/_action.html.haml +7 -0
  387. data/app/views/index/_recent_activity.html.haml +11 -0
  388. data/app/views/index/_recent_activity.js.haml +5 -0
  389. data/app/views/index/dashboard.html.haml +40 -36
  390. data/app/views/index/recent_activity.js.haml +5 -0
  391. data/app/views/kits/_list.html.haml +9 -0
  392. data/app/views/layouts/_flash.html.haml +3 -3
  393. data/app/views/layouts/_google_analytics.html.haml +5 -2
  394. data/app/views/layouts/_menu.html.haml +10 -6
  395. data/app/views/layouts/application.html.haml +6 -3
  396. data/app/views/layouts/devise_layout.html.haml +2 -2
  397. data/app/views/layouts/mail.html.haml +20 -0
  398. data/app/views/layouts/members.html.haml +14 -0
  399. data/app/views/layouts/storefront.html.haml +39 -3
  400. data/app/views/members/index/index.html.haml +41 -0
  401. data/app/views/members/invitations/edit.html.haml +17 -0
  402. data/app/views/members/invitations/new.html.erb +14 -0
  403. data/app/views/members/mailer/_invitation_body.html.haml +18 -0
  404. data/app/views/members/mailer/invitation_instructions.html.haml +6 -0
  405. data/app/views/members/mailer/reset_password_instructions.html.erb +8 -0
  406. data/app/views/members/passwords/edit.html.haml +18 -0
  407. data/app/views/members/sessions/new.html.haml +19 -0
  408. data/app/views/membership_cancellations/_form.html.haml +39 -0
  409. data/app/views/membership_cancellations/_modal.html.haml +2 -0
  410. data/app/views/membership_cancellations/_processing.html.haml +12 -0
  411. data/app/views/membership_cancellations/create.js.erb +3 -0
  412. data/app/views/membership_cancellations/new.js.erb +3 -0
  413. data/app/views/membership_comps/confirm.html.haml +86 -0
  414. data/app/views/membership_comps/create.html.haml +20 -0
  415. data/app/views/membership_comps/new.html.haml +95 -0
  416. data/app/views/membership_kits/edit.html.haml +52 -0
  417. data/app/views/membership_mailer/cancellation_confirmation.html.haml +9 -0
  418. data/app/views/membership_mailer/cancellation_confirmation.text.haml +6 -0
  419. data/app/views/membership_mailer/refund_problem.html.haml +18 -0
  420. data/app/views/membership_mailer/refund_problem.text.haml +14 -0
  421. data/app/views/membership_types/_form.html.haml +89 -0
  422. data/app/views/membership_types/_membership_type_fees.html.haml +0 -0
  423. data/app/views/membership_types/_rolling_membership_type_form.html.haml +5 -0
  424. data/app/views/membership_types/_seasonal_membership_type_form.html.haml +8 -0
  425. data/app/views/membership_types/edit.html.haml +4 -0
  426. data/app/views/membership_types/index.html.haml +28 -0
  427. data/app/views/membership_types/new.html.haml +4 -0
  428. data/app/views/membership_types/type.html.haml +19 -0
  429. data/app/views/memberships/_membership_scripts.js.erb +15 -0
  430. data/app/views/memberships/index.html.haml +160 -0
  431. data/app/views/merges/_merge_preview_person.html.haml +11 -6
  432. data/app/views/merges/find_person.html.haml +5 -5
  433. data/app/views/merges/new.html.haml +7 -6
  434. data/app/views/notes/_note.html.haml +29 -0
  435. data/app/views/order_mailer/confirmation_for.html.haml +34 -22
  436. data/app/views/order_mailer/confirmation_for.text.haml +7 -4
  437. data/app/views/order_mailer/confirmation_for_exchange.html.haml +34 -0
  438. data/app/views/order_mailer/confirmation_for_exchange.text.haml +26 -0
  439. data/app/views/order_mailer/confirmation_for_refund.html.haml +36 -0
  440. data/app/views/order_mailer/confirmation_for_refund.text.haml +22 -0
  441. data/app/views/orders/_item_donations_table.html.haml +27 -0
  442. data/app/views/orders/_item_memberships_table.html.haml +16 -0
  443. data/app/views/orders/_item_table.haml +31 -13
  444. data/app/views/orders/_item_tickets_table.html.haml +27 -0
  445. data/app/views/orders/_order_sidebar.html.haml +40 -18
  446. data/app/views/orders/index.html.haml +2 -0
  447. data/app/views/orders/membership.html.haml +104 -0
  448. data/app/views/orders/sales.html.haml +15 -13
  449. data/app/views/orders/show.html.haml +3 -3
  450. data/app/views/organizations/_connection_form.html.haml +1 -1
  451. data/app/views/organizations/_form.html.haml +25 -20
  452. data/app/views/organizations/edit.html.haml +2 -2
  453. data/app/views/organizations/new.html.haml +1 -1
  454. data/app/views/organizations/show.html.haml +22 -16
  455. data/app/views/pass_mailer/pass_info_for.html.haml +21 -0
  456. data/app/views/pass_types/_form.html.haml +76 -0
  457. data/app/views/pass_types/_pass_type_fees.html.haml +0 -0
  458. data/app/views/pass_types/edit.html.haml +4 -0
  459. data/app/views/pass_types/index.html.haml +34 -0
  460. data/app/views/pass_types/new.html.haml +4 -0
  461. data/app/views/passes/index.html.haml +108 -0
  462. data/app/views/passes_kits/edit.html.haml +30 -0
  463. data/app/views/passes_reports/index.html.haml +2 -0
  464. data/app/views/pdfs/member.html.haml +66 -0
  465. data/app/views/pdfs/member_card_generator/blanks_usa_idc6.html.haml +109 -0
  466. data/app/views/pdfs/order.html.haml +84 -0
  467. data/app/views/people/_convert_to_company_modal.html.haml +42 -0
  468. data/app/views/people/_edit_modal.html.haml +186 -0
  469. data/app/views/people/_form.html.haml +23 -5
  470. data/app/views/people/_header.html.haml +50 -0
  471. data/app/views/people/_household_fields.html.haml +5 -0
  472. data/app/views/people/_phone_fields.html.haml +10 -0
  473. data/app/views/people/_relationship_fields.html.haml +14 -0
  474. data/app/views/people/_work_with_menu.html.haml +39 -0
  475. data/app/views/people/index.html.haml +18 -6
  476. data/app/views/people/new.html.haml +2 -2
  477. data/app/views/people/show.html.haml +149 -28
  478. data/app/views/people/show.js.haml +5 -0
  479. data/app/views/producer_mailer/donation_kit_notification.html.haml +8 -0
  480. data/app/views/producer_mailer/donation_kit_notification.text.erb +8 -0
  481. data/app/views/producer_mailer/mailchimp_kit_initial_sync_notification.html.haml +21 -0
  482. data/app/views/producer_mailer/ticket_offer_accepted.html.haml +7 -0
  483. data/app/views/producer_mailer/ticket_offer_accepted.text.erb +7 -0
  484. data/app/views/producer_mailer/ticket_offer_rejected.html.haml +11 -0
  485. data/app/views/producer_mailer/ticket_offer_rejected.text.erb +13 -0
  486. data/app/views/refunds/new.html.haml +45 -27
  487. data/app/views/regular_donation_kits/edit.html.haml +140 -0
  488. data/app/views/relationships/index.html.haml +32 -0
  489. data/app/views/reports_mailer/_fine_print.html.haml +0 -0
  490. data/app/views/reports_mailer/daily.html.haml +113 -51
  491. data/app/views/reports_mailer/daily.text.erb +5 -5
  492. data/app/views/sales/_boxoffice.html.haml +141 -0
  493. data/app/views/sales/_doorlist.html.haml +79 -0
  494. data/app/views/sales/new.html.haml +33 -125
  495. data/app/views/searches/_form.html.haml +180 -34
  496. data/app/views/searches/_household.html.haml +7 -0
  497. data/app/views/searches/_person.html.haml +5 -2
  498. data/app/views/searches/new.html.haml +1 -1
  499. data/app/views/searches/show.html.haml +29 -21
  500. data/app/views/sections/edit.html.haml +1 -1
  501. data/app/views/sections/new.html.haml +1 -1
  502. data/app/views/segments/show.html.haml +19 -15
  503. data/app/views/shared/_door_list_table.haml +19 -6
  504. data/app/views/shared/_error_messages.html.haml +1 -1
  505. data/app/views/shared/_event_image_icon.html.haml +1 -3
  506. data/app/views/shared/_save_save_and_next.html.haml +2 -0
  507. data/app/views/shared/_show_summary.html.haml +0 -6
  508. data/app/views/shared/_show_time_and_calendar.html.haml +21 -0
  509. data/app/views/shared/_submit_cancel.haml +1 -1
  510. data/app/views/shared/_tags.html.haml +5 -3
  511. data/app/views/shows/_controls.html.haml +5 -23
  512. data/app/views/shows/_glance.html.haml +3 -11
  513. data/app/views/shows/_sections_table.html.haml +89 -0
  514. data/app/views/shows/_ticket_table.html.haml +12 -88
  515. data/app/views/shows/_work_with.html.haml +23 -0
  516. data/app/views/shows/calendar.html.haml +18 -0
  517. data/app/views/shows/door_list.html.haml +2 -2
  518. data/app/views/shows/door_list.pdf.haml +29 -0
  519. data/app/views/shows/index.html.haml +88 -19
  520. data/app/views/shows/new.html.haml +13 -27
  521. data/app/views/shows/show.html.haml +11 -11
  522. data/app/views/slices/index.html.haml +2 -1
  523. data/app/views/statements/_discounts_table.html.haml +1 -1
  524. data/app/views/statements/_order_location_table.html.haml +1 -1
  525. data/app/views/statements/_passes_table.html.haml +22 -0
  526. data/app/views/statements/_payment_method_table.haml +1 -1
  527. data/app/views/statements/_ticket_type_table.haml +5 -2
  528. data/app/views/statements/show.html.haml +5 -2
  529. data/app/views/store/checkouts/_membership_info.html.haml +12 -0
  530. data/app/views/store/checkouts/thanks.html.haml +134 -0
  531. data/app/views/store/donations/index.html.haml +19 -0
  532. data/app/views/store/events/_calendar.html.haml +4 -5
  533. data/app/views/store/events/_venue.html.haml +9 -0
  534. data/app/views/store/events/calendar.html.haml +50 -0
  535. data/app/views/store/events/index.html.haml +23 -0
  536. data/app/views/store/events/show.html.haml +26 -185
  537. data/app/views/store/events/single_show.html.haml +45 -0
  538. data/app/views/store/memberships/index.html.haml +40 -0
  539. data/app/views/store/orders/show.html.haml +198 -0
  540. data/app/views/store/passes/index.html.haml +33 -0
  541. data/app/views/store/retrievals/index.html.haml +11 -0
  542. data/app/views/store/shared/_donate_form.html.haml +31 -0
  543. data/app/views/store/shared/_small_donate_form.html.haml +21 -0
  544. data/app/views/store/shows/_show.html.haml +50 -0
  545. data/app/views/store/shows/show.html.haml +1 -0
  546. data/app/views/ticket_types/edit.html.haml +12 -0
  547. data/app/views/ticket_types/new.html.haml +13 -0
  548. data/app/views/user_memberships/_list.html.haml +30 -0
  549. data/app/views/users/invitations/edit.html.haml +19 -9
  550. data/app/views/users/mailer/invitation_instructions.html.haml +14 -0
  551. data/app/views/users/passwords/edit.html.haml +2 -2
  552. data/app/views/users/registrations/edit.html.erb +3 -3
  553. data/app/views/users/sessions/new.html.haml +2 -2
  554. data/app/views/venues/edit.html.haml +6 -4
  555. data/config/initializers/devise.rb +2 -5
  556. data/config/initializers/paperclip.rb +69 -0
  557. data/config/locales/devise.en.yml +1 -1
  558. data/config/locales/devise_invitable.en.yml +1 -1
  559. data/config/locales/en.yml +16 -3
  560. data/config/routes.rb +178 -22
  561. data/db/migrate/20130311184839_rename_memberships.rb +5 -0
  562. data/db/migrate/20130329201707_clean_geographic_data.rb +230 -0
  563. data/db/migrate/20130411162346_add_country_zip_state_phone_number_discipline_to_organizations.rb +9 -0
  564. data/db/migrate/20130412145428_massage_action_subtypes.rb +15 -0
  565. data/db/migrate/20130412184415_add_first_name_and_last_name_to_users.rb +6 -0
  566. data/db/migrate/20130420232537_add_starred_to_note.rb +5 -0
  567. data/db/migrate/20130425153848_add_notes_to_orders.rb +5 -0
  568. data/db/migrate/20130506173918_add_token_to_cart.rb +6 -0
  569. data/db/migrate/20130508180421_ticket_types_ahoy.rb +17 -0
  570. data/db/migrate/20130508194552_add_members_to_section.rb +6 -0
  571. data/db/migrate/20130514153006_add_import_messages.rb +17 -0
  572. data/db/migrate/20130520190452_add_ticket_type_to_tickets.rb +6 -0
  573. data/db/migrate/20130521185848_add_sti_to_cart.rb +12 -0
  574. data/db/migrate/20130526021126_add_validated_to_ticket.rb +5 -0
  575. data/db/migrate/20130528193811_add_widget_requests.rb +12 -0
  576. data/db/migrate/20130530011409_add_ticket_types_to_discounts.rb +5 -0
  577. data/db/migrate/20130531160800_migrate_to_ticket_types.rb +59 -0
  578. data/db/migrate/20130531160801_drop_price_from_ticket.rb +5 -0
  579. data/db/migrate/20130531160802_remove_price_from_section.rb +5 -0
  580. data/db/migrate/20130531180955_add_defaults_to_people_types.rb +21 -0
  581. data/db/migrate/20130604161411_add_validated_action_to_ticket.rb +5 -0
  582. data/db/migrate/20130607180250_change_institution_to_company.rb +9 -0
  583. data/db/migrate/20130609233536_revenue_applies_at.rb +11 -0
  584. data/db/migrate/20130611175122_add_more_indexes.rb +8 -0
  585. data/db/migrate/20130612183117_add_types_to_searches.rb +6 -0
  586. data/db/migrate/20130712145416_add_middle_name_and_suffix_to_people.rb +6 -0
  587. data/db/migrate/20130722153731_add_autentication_token_to_users.rb +5 -0
  588. data/db/migrate/20130722182255_create_membership_types.rb +18 -0
  589. data/db/migrate/20130723182754_create_slugged_slugs.rb +20 -0
  590. data/db/migrate/20130723182811_add_cached_slug_to_organizations.rb +16 -0
  591. data/db/migrate/20130723212712_add_qr_code_to_tickets.rb +9 -0
  592. data/db/migrate/20130725012338_create_new_memberships.rb +28 -0
  593. data/db/migrate/20130725013145_devise_create_members.rb +41 -0
  594. data/db/migrate/20130729140618_convert_to_company.rb +5 -0
  595. data/db/migrate/20130731145336_last_member_number.rb +5 -0
  596. data/db/migrate/20130731153806_add_member_number.rb +5 -0
  597. data/db/migrate/20130801194634_make_events_public.rb +5 -0
  598. data/db/migrate/20130802235709_add_memberships_to_search.rb +9 -0
  599. data/db/migrate/20130808002742_add_lifetime_ticket_value_to_person.rb +9 -0
  600. data/db/migrate/20130808005856_add_members_only_to_events.rb +5 -0
  601. data/db/migrate/20130820011240_add_uuid_to_tickets.rb +13 -0
  602. data/db/migrate/20130820025134_make_ticket_uuid_not_null.rb +11 -0
  603. data/db/migrate/20130823191625_add_pdf_to_orders.rb +5 -0
  604. data/db/migrate/20130827190839_add_fee_to_tickets_and_donations.rb +8 -0
  605. data/db/migrate/20130829015011_migrate_fees_to_items.rb +5 -0
  606. data/db/migrate/20130916194547_add_relationships.rb +21 -0
  607. data/db/migrate/20130917165559_add_service_fee_to_memberships.rb +5 -0
  608. data/db/migrate/20131002191646_create_show_stats_view.rb +16 -0
  609. data/db/migrate/20131003134821_add_relationships_to_search.rb +7 -0
  610. data/db/migrate/20131003200508_add_starred_to_relationships.rb +5 -0
  611. data/db/migrate/20131007141421_add_counters_to_member.rb +7 -0
  612. data/db/migrate/20131007144456_remove_expires_at_from_membership.rb +6 -0
  613. data/db/migrate/20131011154027_add_purchased_to_searches.rb +5 -0
  614. data/db/migrate/20131013144010_add_type_to_membership_type.rb +5 -0
  615. data/db/migrate/20131013150230_add_duration_to_membership_type.rb +6 -0
  616. data/db/migrate/20131013192807_change_number_of_shows_to_tickets.rb +5 -0
  617. data/db/migrate/20131015151550_add_households.rb +18 -0
  618. data/db/migrate/20131022183913_add_search_output_options.rb +24 -0
  619. data/db/migrate/20131023200559_add_admin_to_user_memberships.rb +14 -0
  620. data/db/migrate/20131025162155_default_search_filter_values.rb +10 -0
  621. data/db/migrate/20131025180139_unique_household_names.rb +8 -0
  622. data/db/migrate/20131029173612_add_sales_start_to_membership_typ.rb +6 -0
  623. data/db/migrate/20131106191847_add_suggested_households.rb +13 -0
  624. data/db/migrate/20131127162818_add_buyer_id_index_to_tickets.rb +5 -0
  625. data/db/migrate/20131127164000_member_tickets.rb +9 -0
  626. data/db/migrate/20131204162642_add_shared_address.rb +9 -0
  627. data/db/migrate/20131206153323_add_membership_kit.rb +5 -0
  628. data/db/migrate/20131206175325_add_marketing_to_membership_type.rb +6 -0
  629. data/db/migrate/20131210212342_add_show_fee_to_memberhsip_type.rb +5 -0
  630. data/db/migrate/20131210222814_add_renewal_price_to_membership_type.rb +6 -0
  631. data/db/migrate/20131212164553_add_copy_to_individuals_option.rb +5 -0
  632. data/db/migrate/20131223215615_goodbye_order_view.rb +6 -0
  633. data/db/migrate/20140114011856_add_welcome_message_to_memberships.rb +5 -0
  634. data/db/migrate/20140114212127_add_send_email_to_memberships.rb +5 -0
  635. data/db/migrate/20140125183606_index_memberships_and_types.rb +6 -0
  636. data/db/migrate/20140128213101_add_pdf_to_members.rb +5 -0
  637. data/db/migrate/20140128223140_add_uuid_to_member.rb +6 -0
  638. data/db/migrate/20140128223948_add_qr_code_to_member.rb +9 -0
  639. data/db/migrate/20140207135731_update_items_view.rb +38 -0
  640. data/db/migrate/20140210154723_add_cached_stats.rb +5 -0
  641. data/db/migrate/20140218202726_cache_stats.rb +7 -0
  642. data/db/migrate/20140304171625_passes_ahoy.rb +52 -0
  643. data/db/migrate/20140304174807_add_passes_kit.rb +5 -0
  644. data/db/migrate/20140307144454_add_events_pass_types.rb +9 -0
  645. data/db/migrate/20140307193350_add_pass_id_to_cart.rb +7 -0
  646. data/db/migrate/20140314162422_add_total_paid_to_membership.rb +13 -0
  647. data/db/migrate/20140319191237_add_show_dates_to_advanced_search.rb +6 -0
  648. data/db/migrate/20140328172333_add_cols_to_events_pass_types.rb +6 -0
  649. data/db/migrate/20140328174217_add_deleted_at_to_ept.rb +9 -0
  650. data/db/migrate/20140328185432_add_active_to_ept.rb +5 -0
  651. data/db/migrate/20140328192612_add_pass_type_id_to_search.rb +5 -0
  652. data/db/migrate/20140415212841_add_min_max_start_dates_to_searches.artfully_ose_engine.rb +6 -0
  653. data/db/migrate/20140422193345_add_email_copy_to_pass_type.rb +5 -0
  654. data/db/migrate/20140423181639_add_min_max_end_dates_to_searches.artfully_ose_engine.rb +6 -0
  655. data/db/migrate/20140423185921_add_cached_stats_to_event.rb +9 -0
  656. data/db/migrate/20140424174423_add_lifetime_memberships_to_people.artfully_ose_engine.rb +5 -0
  657. data/db/migrate/20140506155241_add_lpt_to_membership_type.rb +5 -0
  658. data/db/migrate/20140507184646_add_bday_attributes_to_person.rb +7 -0
  659. data/db/migrate/20140507201048_add_check_number_to_orders.rb +5 -0
  660. data/db/migrate/20140515143651_remove_show_stats_view.rb +6 -0
  661. data/db/migrate/20140521195853_add_deleted_at_to_pass_type.rb +5 -0
  662. data/db/migrate/20140522205554_add_limit_to_events_pass_types.rb +5 -0
  663. data/db/migrate/20140523180444_remove_tickets_purchased_from_passes.rb +5 -0
  664. data/db/migrate/20140603200735_add_subtitle_to_events.rb +5 -0
  665. data/db/migrate/20140619194127_add_do_not_call_to_people.artfully_ose_engine.rb +5 -0
  666. data/db/migrate/20140623160543_add_index_to_items.rb +7 -0
  667. data/lib/artfully_ose.rb +7 -4
  668. data/lib/artfully_ose/common_abilities.rb +8 -2
  669. data/lib/artfully_ose/engine.rb +34 -10
  670. data/lib/artfully_ose/version.rb +1 -1
  671. data/spec/factories/action_factories.rb +19 -0
  672. data/spec/factories/address_factories.rb +11 -0
  673. data/spec/factories/cart_factories.rb +26 -0
  674. data/spec/factories/chart_factories.rb +52 -0
  675. data/spec/factories/discount_factories.rb +11 -0
  676. data/spec/factories/donation_factories.rb +14 -0
  677. data/spec/factories/event_factories.rb +29 -0
  678. data/spec/factories/household_factories.rb +8 -0
  679. data/spec/factories/import_factories.rb +61 -0
  680. data/spec/factories/item_factories.rb +51 -0
  681. data/spec/factories/kit_factories.rb +33 -0
  682. data/spec/factories/member_factories.rb +19 -0
  683. data/spec/factories/membership_factories.rb +9 -0
  684. data/spec/factories/membership_type_factories.rb +18 -0
  685. data/spec/factories/order_factories.rb +40 -0
  686. data/spec/factories/organization_factories.rb +48 -0
  687. data/spec/factories/pass_type_factories.rb +11 -0
  688. data/spec/factories/payments_factories.rb +97 -0
  689. data/spec/factories/person_factories.rb +47 -0
  690. data/spec/factories/phone_factories.rb +6 -0
  691. data/spec/factories/section_factories.rb +21 -0
  692. data/spec/factories/segment_factories.rb +6 -0
  693. data/spec/factories/show_factories.rb +33 -0
  694. data/spec/factories/ticket_factories.rb +57 -0
  695. data/spec/factories/ticket_offer_factories.rb +16 -0
  696. data/spec/factories/ticket_type_factories.rb +8 -0
  697. data/spec/factories/user_factories.rb +24 -0
  698. metadata +522 -49
  699. data/app/assets/javascripts/box-office.js +0 -244
  700. data/app/assets/javascripts/jquery-lib/fullcalendar.min.js +0 -113
  701. data/app/assets/javascripts/jquery-lib/jquery-ui-1.8.14.custom.min.js +0 -570
  702. data/app/assets/javascripts/jquery_ujs.js +0 -316
  703. data/app/assets/stylesheets/font-awesome.sass +0 -759
  704. data/app/models/adjustments.rb +0 -10
  705. data/app/models/carts/cart.rb +0 -171
  706. data/app/models/database_views/order_view.rb +0 -34
  707. data/app/views/actions/_list.html.haml +0 -25
  708. data/app/views/actions/edit.html.haml +0 -19
  709. data/app/views/actions/new.html.haml +0 -19
  710. data/app/views/memberships/_list.html.haml +0 -31
  711. data/app/views/notes/_list.html.haml +0 -30
  712. data/app/views/notes/edit.html.haml +0 -14
  713. data/app/views/notes/new.html.haml +0 -14
  714. data/app/views/orders/_grouped_form_help.haml +0 -4
  715. data/app/views/people/_person_summary_sidebar.html.haml +0 -86
  716. data/app/views/people/edit.html.haml +0 -10
  717. data/app/views/shared/_new_person_popup.html.haml +0 -21
  718. data/app/views/store/events/_show.html.haml +0 -43
  719. data/app/views/users/mailer/invitation_instructions.html.erb +0 -8
data/app/models/phone.rb CHANGED
@@ -2,14 +2,6 @@ class Phone < ActiveRecord::Base
2
2
  attr_accessible :kind, :number
3
3
  belongs_to :person
4
4
 
5
- #This method is here solely to parse phones in the Athena migration
6
- #There were in the form type:number
7
- def self.from_athena(unparsed_phone)
8
- Phone.new.tap do |phone|
9
- phone.kind, phone.number = unparsed_phone.split(":")
10
- end
11
- end
12
-
13
5
  def self.kinds
14
6
  [ "Work", "Home", "Cell", "Fax", "Other" ]
15
7
  end
data/app/models/refund.rb CHANGED
@@ -1,9 +1,8 @@
1
1
  class Refund
2
- include Adjustments
3
- attr_accessor :order, :refund_order, :items, :message
2
+ attr_accessor :order, :refund_order, :items, :message, :send_email_confirmation
4
3
 
5
4
  BRAINTREE_UNSETTLED_MESSAGE = "Cannot refund a transaction unless it is settled. (91506)"
6
- FRIENDLY_UNSETTLED_MESSAGE = "The processor cannot refund that transaction yet. Please try again in a few hours."
5
+ FRIENDLY_UNSETTLED_MESSAGE = "Unfortunately we cannot refund credit card transactions until the day after they were processed. Please re-issue the refund tomorrow."
7
6
 
8
7
  def initialize(order, items)
9
8
  self.order = order
@@ -12,22 +11,33 @@ class Refund
12
11
 
13
12
  def submit(options = {})
14
13
  return_items_to_inventory = options[:and_return] || false
14
+ @send_email_confirmation = options[:send_email_confirmation] || false
15
15
 
16
- items.each do |i|
17
- unless i.refundable?
18
- @message = "Those items have already been refunded."
19
- return
16
+
17
+ ActiveRecord::Base.transaction do
18
+ items.each do |i|
19
+ unless i.refundable?
20
+ @message = "Those items have already been refunded."
21
+ return
22
+ end
20
23
  end
21
- end
22
24
 
23
- @payment = Payment.create(@order.payment_method)
24
- @success = @payment.refund(refund_amount, order.transaction_id, options.merge({:service_fee => service_fee}))
25
- @message = format_message(@payment)
26
-
27
- if @success
28
- items.each { |i| i.return!(return_items_to_inventory) }
29
- items.each(&:refund!)
30
- create_refund_order(@payment.transaction_id)
25
+ @payment = Payment.create(@order.payment_method)
26
+ @success = @payment.refund(refund_amount, order.transaction_id, options.merge({:service_fee => service_fee}))
27
+ @message = format_message(@payment)
28
+
29
+ if @success
30
+ #
31
+ # NOTE: That this will clean up the items, but the tickets will remain sold
32
+ # if the show date has passed.
33
+ # because ticket.reset_price! is guarded with sold? and return_to_inventory
34
+ # is guarded with expired? (show date passed)
35
+ #
36
+ items.each { |i| i.return!(return_items_to_inventory) }
37
+ items.each(&:refund!)
38
+ create_refund_order(@payment.transaction_id)
39
+ end
40
+ #TODO: rollback refund as well
31
41
  end
32
42
  end
33
43
 
@@ -50,7 +60,7 @@ class Refund
50
60
  end
51
61
 
52
62
  def service_fee
53
- (number_of_non_free_items(items) * service_fee_per_item(order.items))
63
+ items.collect(&:service_fee).sum
54
64
  end
55
65
 
56
66
  private
@@ -67,7 +77,7 @@ class Refund
67
77
  @refund_order.parent = order
68
78
  @refund_order.for_organization order.organization
69
79
  @refund_order.items = items.collect(&:to_refund)
70
- @refund_order.service_fee = -1 * service_fee
80
+ @refund_order.skip_email = !send_email_confirmation
71
81
  @refund_order.save!
72
82
  @refund_order
73
83
  end
@@ -0,0 +1,27 @@
1
+ class Relation < ActiveRecord::Base
2
+ attr_accessible :description, :inverse,
3
+ :person_can_be_individual,
4
+ :person_can_be_company,
5
+ :other_can_be_individual,
6
+ :other_can_be_company
7
+
8
+ has_many :relationships
9
+ belongs_to :inverse, :class_name => 'Relation', :dependent => :destroy
10
+
11
+ def self.for_individual
12
+ where(:person_can_be_individual => true)
13
+ end
14
+
15
+ def self.for_company
16
+ where(:person_can_be_company => true)
17
+ end
18
+
19
+ def self.for_type(type)
20
+ send("for_#{type.downcase}")
21
+ end
22
+
23
+ def indefinite_article
24
+ %w(a e i o u).include?(description[0].downcase) ? 'an' : 'a'
25
+ end
26
+
27
+ end
@@ -0,0 +1,32 @@
1
+ class RelationBuilder
2
+ def self.build_single(description, pi, pc, oi, oc)
3
+ ActiveRecord::Base.transaction do
4
+ relation = Relation.create(:description => description,
5
+ :person_can_be_individual => pi,
6
+ :person_can_be_company => pc,
7
+ :other_can_be_individual => oi,
8
+ :other_can_be_company => oc)
9
+ relation.update_attribute(:inverse_id, relation.id)
10
+ relation
11
+ end
12
+ end
13
+
14
+ def self.build(description, inverse_description, pi, pc, oi, oc)
15
+ ActiveRecord::Base.transaction do
16
+ relation = Relation.create(:description => description,
17
+ :person_can_be_individual => pi,
18
+ :person_can_be_company => pc,
19
+ :other_can_be_individual => oi,
20
+ :other_can_be_company => oc)
21
+
22
+ inverse = relation.create_inverse(:description => inverse_description,
23
+ :person_can_be_individual => oi,
24
+ :person_can_be_company => oc,
25
+ :other_can_be_individual => pi,
26
+ :other_can_be_company => pc,
27
+ :inverse => relation)
28
+ relation.update_attribute(:inverse_id, inverse.id)
29
+ relation
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,55 @@
1
+ class Relationship < ActiveRecord::Base
2
+ attr_accessible :person, :relation, :other, :starred, :inverse, :relation_id, :other_id
3
+
4
+ belongs_to :person
5
+ belongs_to :other, :class_name => 'Person'
6
+ belongs_to :inverse, :class_name => 'Relationship', :dependent => :destroy, :foreign_key => :inverse_id
7
+ has_one :inverse_relationship, :class_name => 'Relationship', :dependent => :destroy, :foreign_key => :inverse_id
8
+ belongs_to :relation
9
+
10
+ validates_with RelationshipValidator
11
+
12
+ after_create :assign_company_name
13
+
14
+ def assign_company_name
15
+ return unless relation.description == 'employed by'
16
+ person.company_name = other.company_name unless person.company_name.present?
17
+ person.save!
18
+ end
19
+
20
+ def self.starred
21
+ where(:starred => true)
22
+ end
23
+
24
+ def self.unstarred
25
+ where(:starred => false)
26
+ end
27
+
28
+ def self.of_relation(relation)
29
+ where(:relation => {:description => relation})
30
+ end
31
+
32
+ def unstar!
33
+ Relationship.transaction do
34
+ self[:starred] = false
35
+ inverse[:starred] = false
36
+ save!
37
+ inverse.save!
38
+ end
39
+ end
40
+
41
+ def star!
42
+ Relationship.transaction do
43
+ self[:starred] = true
44
+ inverse[:starred] = true
45
+ save!
46
+ inverse.save!
47
+ end
48
+ end
49
+
50
+ def ensure_inverse
51
+ create_inverse(:relation => relation.inverse, :person => other, :other => person, :inverse => self)
52
+ save
53
+ end
54
+
55
+ end
@@ -0,0 +1,12 @@
1
+ class RelationshipBuilder
2
+ def self.build(person, other, relation)
3
+ ActiveRecord::Base.transaction do
4
+ relationship = person.relationships.create(:other => other, :relation => relation)
5
+ relationship.save!
6
+ inverse = other.relationships.create(:other => person, :relation => relation.inverse, :inverse => relationship)
7
+ inverse.save!
8
+ relationship.update_attribute(:inverse_id, inverse.id)
9
+ relationship
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,46 @@
1
+ class RelationshipValidator < ActiveModel::Validator
2
+ def validate(record)
3
+ validate_uniqueness(record)
4
+ validate_relation(record)
5
+ end
6
+
7
+ private
8
+
9
+ def validate_relation(record)
10
+
11
+ relation = record.relation
12
+
13
+ msg = "of type '#{relation.description}' cannot exist between #{record.person.class.name} and #{record.other.class.name}"
14
+
15
+ if record.person.company? && !relation.person_can_be_company
16
+ record.errors[:relation] = msg
17
+ end
18
+
19
+ if record.person.individual? && !relation.person_can_be_individual
20
+ record.errors[:relation] = msg
21
+ end
22
+
23
+ if record.other.company? && !relation.other_can_be_company
24
+ record.errors[:relation] = msg
25
+ end
26
+
27
+ if record.other.individual? && !relation.other_can_be_individual
28
+ record.errors[:relation] = msg
29
+ end
30
+ end
31
+
32
+ def validate_uniqueness(record)
33
+ identical = Relationship.where(:person_id => record.person_id,
34
+ :relation_id => record.relation_id,
35
+ :other_id => record.other_id)
36
+ unless record.id.nil?
37
+ identical = identical.where('id != ?', record.id)
38
+ end
39
+
40
+ if identical.count > 0
41
+ record.errors[:base] << "#{record.person} is already in a '#{record.relation.description}' relationship with #{record.other}"
42
+ end
43
+ end
44
+
45
+ end
46
+
@@ -0,0 +1,31 @@
1
+ class RelationshipsKit < Kit
2
+
3
+ acts_as_kit :admin_only => true do
4
+ self.configurable = false
5
+
6
+ state_machine do
7
+ state :cancelled, :enter => :kit_cancelled
8
+ end
9
+
10
+ when_active do |organization|
11
+ organization.can :access, :relationships
12
+ end
13
+ end
14
+
15
+ def friendly_name
16
+ "Relationships"
17
+ end
18
+
19
+ def pitch
20
+ "Track Relationships!"
21
+ end
22
+
23
+ def configured?
24
+ true
25
+ end
26
+
27
+ def configured!
28
+ settings[:membership_state] = "configured"
29
+ save
30
+ end
31
+ end
@@ -0,0 +1,11 @@
1
+ class RollingMembershipType < MembershipType
2
+ validates :duration, :presence => true
3
+
4
+ def starts_at
5
+ DateTime.now
6
+ end
7
+
8
+ def ends_at
9
+ self.duration.nil? ? nil : DateTime.now + (self.duration.send(self.period.downcase))
10
+ end
11
+ end
data/app/models/sale.rb CHANGED
@@ -1,23 +1,22 @@
1
1
  class Sale
2
2
  include ActiveModel::Validations
3
3
 
4
- attr_accessor :sections, :quantities, :tickets, :cart, :message, :error, :sale_made
4
+ attr_accessor :ticket_types, :quantities, :tickets, :cart, :message, :error, :sale_made, :notes, :order
5
5
  attr_reader :buyer
6
6
 
7
7
  validate :has_tickets?
8
8
 
9
- def initialize(show, sections, quantities = {})
9
+ def initialize(show, ticket_types, cart, quantities = {}, notes=nil)
10
10
  @show = show
11
- @sections = sections
12
-
11
+ @ticket_types = ticket_types
12
+ @notes = notes
13
+
13
14
  #When coming from a browser, all keys and values in @quantities are STRINGS
14
15
  @quantities = quantities
15
- @cart = BoxOffice::Cart.new
16
+ @cart = cart
16
17
  @tickets = []
17
-
18
- #This is irritating, it means you can't add tickets to a sale later
19
- load_tickets
20
- cart.tickets << tickets
18
+
19
+ load_tickets
21
20
  end
22
21
 
23
22
  def sell(payment)
@@ -42,16 +41,21 @@ class Sale
42
41
  end
43
42
 
44
43
  def load_tickets
45
- sections.each do |section|
46
- tickets_available_in_section = Ticket.available({:section_id => section.id, :show_id => @show.id}, @quantities[section.id.to_s])
47
- if tickets_available_in_section.length != @quantities[section.id.to_s].to_i
48
- errors.add(:base, "There aren't enough tickets available in that section")
49
- else
50
- @tickets = @tickets + tickets_available_in_section
44
+ @quantities.keys.each do |ticket_type_id|
45
+ amount_requested = @quantities[ticket_type_id].to_i
46
+ if amount_requested > 0
47
+ ticket_type = TicketType.find(ticket_type_id)
48
+ tickets_available_in_ticket_type = ticket_type.available_tickets(amount_requested)
49
+ if tickets_available_in_ticket_type.length != amount_requested
50
+ errors.add(:base, "There aren't enough tickets available for that ticket type")
51
+ else
52
+ Ticket.lock(tickets_available_in_ticket_type, ticket_type, @cart)
53
+ @tickets = @tickets + tickets_available_in_ticket_type
54
+ end
51
55
  end
52
56
  end
53
57
  end
54
-
58
+
55
59
  def has_tickets?
56
60
  unless non_zero_quantities?
57
61
  errors.add(:base, "Please select a number of tickets to purchase") and return false
@@ -63,22 +67,25 @@ class Sale
63
67
  private
64
68
 
65
69
  def comp_tickets(payment)
66
- @comp = Comp.new(tickets.first.show, tickets, payment.customer, payment.benefactor)
70
+ @comp = Comp.new(tickets.first.show, tickets, [], payment.customer, payment.benefactor, notes)
67
71
  @comp.submit
68
72
  @buyer = @comp.recipient
73
+ @order = @comp.order
74
+ self.cart.approve!
69
75
  true
70
76
  end
71
-
77
+
72
78
  def sell_tickets(payment)
73
- checkout = BoxOffice::Checkout.new(cart, payment)
79
+ checkout = BoxOffice::Checkout.new(cart, payment, notes)
74
80
  begin
75
81
  success = checkout.finish
76
82
  @buyer = checkout.person
83
+ @order = checkout.order
77
84
  if !success
78
85
  if checkout.payment.errors.blank?
79
86
  errors.add(:base, "payment was not accepted")
80
87
  else
81
- errors.add(:base, checkout.payment.errors.full_messages.to_sentence.downcase)
88
+ errors.add(:base, checkout.payment.errors.full_messages.to_sentence.downcase)
82
89
  end
83
90
  return success
84
91
  end
@@ -91,4 +98,4 @@ class Sale
91
98
  end
92
99
  success
93
100
  end
94
- end
101
+ end
@@ -24,7 +24,7 @@ class SaleSearch
24
24
  end
25
25
 
26
26
  def stop_with(stop)
27
- stop.present? ? DateTime.parse(stop) + 1.day - 1.minute : default_stop
27
+ stop.present? ? Sundial.midnightish(@organization, stop) : default_stop
28
28
  end
29
29
 
30
30
  def default_start
data/app/models/search.rb CHANGED
@@ -2,12 +2,26 @@ class Search < ActiveRecord::Base
2
2
 
3
3
  belongs_to :organization
4
4
  belongs_to :event
5
+ belongs_to :membership_type
6
+ belongs_to :pass_type
7
+ belongs_to :relation
8
+
5
9
  validates_presence_of :organization_id
6
10
 
7
- attr_accessible :zip, :state, :event_id, :tagging,
8
- :min_lifetime_value, :max_lifetime_value,
9
- :min_donations_amount, :max_donations_amount,
10
- :min_donations_date, :max_donations_date, :discount_code
11
+ attr_accessible :zip, :state,
12
+ :has_purchased_for, :event_id,
13
+ :tagging, :person_subtype,
14
+ :min_lifetime_value, :max_lifetime_value,
15
+ :min_donations_amount, :max_donations_amount,
16
+ :min_donations_date, :max_donations_date, :discount_code,
17
+ :membership_status, :pass_type_id, :pass_type, :membership_type_id, :membership_type,
18
+ :relation_id, :output_individuals, :output_households, :output_companies,
19
+ :show_date_start, :show_date_end,
20
+ :min_membership_start_date, :max_membership_start_date,
21
+ :min_membership_end_date, :max_membership_end_date
22
+
23
+ ANY_EVENT = -1
24
+ ANY_MEMBERSHIP_TYPE = -1
11
25
 
12
26
  def length
13
27
  people.length
@@ -25,26 +39,44 @@ attr_accessible :zip, :state, :event_id, :tagging,
25
39
  Delayed::Job.enqueue(ActionJob.new(action, people))
26
40
  end
27
41
 
42
+ def event_name
43
+ event.try(:name) || Event::ANY_EVENT_TEXT
44
+ end
45
+
28
46
  def description
29
- conditions = []
30
- conditions << "Are tagged with #{tagging}." if tagging.present?
31
- conditions << "Bought tickets for #{event.name}." if event_id.present?
47
+ c = ->(s){ "<li>#{s}</li>" }
48
+ conditions = ""
49
+
50
+ conditions << c.call("Are tagged with #{tagging}.") if tagging.present?
51
+ conditions << c.call("Have #{relation.indefinite_article} '#{relation.description}' relationship") if relation.present?
52
+
53
+ if event_id.present?
54
+ if has_purchased_for
55
+ conditions << c.call("Purchased tickets for #{event_name}.")
56
+ else
57
+ conditions << c.call("Have not purchased tickets for #{event_name}.")
58
+ end
59
+
60
+ conditions << c.call("For show dates after #{show_date_start.strftime('%D')}") if show_date_start.present?
61
+ conditions << c.call("For show dates through #{show_date_end.strftime('%D')}") if show_date_end.present?
62
+ end
63
+
32
64
  if zip.present? || state.present?
33
65
  locations = []
34
66
  locations << state if state.present?
35
67
  locations << "the zipcode of #{zip}" if zip.present?
36
- conditions << "Are located within #{locations.to_sentence}."
68
+ conditions << c.call("Are located within #{locations.to_sentence}.")
37
69
  end
38
70
  if min_lifetime_value.present? && max_lifetime_value.present?
39
- conditions << "Have a lifetime value between $#{min_lifetime_value} and $#{max_lifetime_value}."
71
+ conditions << c.call("Have a lifetime value between $#{min_lifetime_value} and $#{max_lifetime_value}.")
40
72
  elsif min_lifetime_value.present?
41
- conditions << "Have a minimum lifetime value of $#{min_lifetime_value}."
73
+ conditions << c.call("Have a minimum lifetime value of $#{min_lifetime_value}.")
42
74
  elsif max_lifetime_value.present?
43
- conditions << "Have a maximum lifetime value of $#{max_lifetime_value}."
75
+ conditions << c.call("Have a maximum lifetime value of $#{max_lifetime_value}.")
44
76
  end
45
77
 
46
78
  unless discount_code.blank?
47
- conditions << ((discount_code == Discount::ALL_DISCOUNTS_STRING) ? "Used any discount code" : "Used discount code #{discount_code}.")
79
+ conditions << ((discount_code == Discount::ALL_DISCOUNTS_STRING) ? c.call("Used any discount code") : ("Used discount code #{discount_code}."))
48
80
  end
49
81
 
50
82
  unless [min_donations_amount, max_donations_amount, min_donations_date, max_donations_date].all?(&:blank?)
@@ -67,51 +99,308 @@ attr_accessible :zip, :state, :event_id, :tagging,
67
99
  else
68
100
  string << " overall."
69
101
  end
70
- conditions << string
102
+ conditions << c.call(string)
103
+ end
104
+
105
+ categories = []
106
+
107
+ if output_companies
108
+ if person_subtype.present?
109
+ categories << person_subtype.downcase.pluralize
110
+ else
111
+ categories << "companies" if output_companies
112
+ end
113
+ end
114
+
115
+ if searching_membership?
116
+ if membership_status.present?
117
+ state_str = (membership_status == "None") ? "not" : membership_status.downcase
118
+ conditions << c.call("Are #{state_str} members")
119
+ end
120
+
121
+ if membership_type_id.present?
122
+ if any_membership_type?
123
+ conditions << c.call("Are members")
124
+ else
125
+ conditions << c.call("Are #{membership_type.name} members")
126
+ end
127
+ end
128
+
129
+
130
+ # Membership Start
131
+ if min_membership_start_date.present? && max_membership_start_date.present?
132
+ conditions << c.call("Have memberships starting from #{min_membership_start_date.strftime('%D')} through #{max_membership_start_date.strftime('%D')}.")
133
+ elsif min_membership_start_date.present?
134
+ conditions << c.call("Have memberships starting on or after #{min_membership_start_date.strftime('%D')}.")
135
+ elsif max_membership_start_date.present?
136
+ conditions << c.call("Have memberships starting on or before #{max_membership_start_date.strftime('%D')}.")
137
+ end
138
+
139
+ # Membership End
140
+ if min_membership_end_date.present? && max_membership_end_date.present?
141
+ conditions << c.call("Have memberships ending from #{min_membership_end_date.strftime('%D')} through #{max_membership_end_date.strftime('%D')}.")
142
+ elsif min_membership_end_date.present?
143
+ conditions << c.call("Have memberships ending on or after #{min_membership_end_date.strftime('%D')}.")
144
+ elsif max_membership_end_date.present?
145
+ conditions << c.call("Have memberships ending on or before #{max_membership_end_date.strftime('%D')}.")
146
+ end
71
147
  end
72
148
 
149
+ if searching_passes?
150
+ conditions << c.call("Have a current #{pass_type.passerize}.")
151
+ end
152
+
153
+ categories << "individuals" if output_individuals
154
+
155
+ if self.organization.can? :access,:relationships
156
+ categories << "households" if output_households
157
+ end
158
+
159
+ categories[-1] = "and #{categories[-1]}" if categories.length > 1
160
+
161
+ categories << "Anything " if categories.empty?
162
+
73
163
  if conditions.blank?
74
- return "All people."
164
+ result = "All " << categories.join(", ") << "."
75
165
  else
76
- return "People that: <ul>" + conditions.collect{|c| "<li>#{c}</li>"}.join + "</ul>"
166
+ result = categories.join(" ") << " that: " << "<ul>" << conditions << "</ul>"
167
+ result[0] = result[0].upcase
77
168
  end
169
+
170
+ result
171
+
172
+ end
173
+
174
+ def offset_show_date_start
175
+ return nil if self.show_date_start.blank?
176
+ @offset_show_date_start ||= self.show_date_start.to_datetime.change(:offset => offset(self.show_date_start))
177
+ end
178
+
179
+ def offset_show_date_end
180
+ return nil if self.show_date_end.blank?
181
+ @offset_show_date_end ||= self.show_date_end.to_datetime.end_of_day.change(:offset => offset(self.show_date_end))
182
+ end
183
+
184
+ def offset(datetime)
185
+ @offset ||= datetime.in_time_zone(ActiveSupport::TimeZone.create(self.organization.time_zone)).formatted_offset
78
186
  end
79
187
 
80
188
  private
81
189
 
82
- def find_people
83
- column_names = Person.column_names.collect {|cn| "people.#{cn}" }
84
- column_names << "lower(people.last_name) AS ordered_last_names"
85
-
86
- people = Person.where(:organization_id => organization_id)
87
- people = people.where(:dummy => false)
88
- people = people.order('ordered_last_names ASC')
89
- people = people.tagged_with(tagging) unless tagging.blank?
90
- people = people.joins(:address) unless zip.blank? && state.blank?
91
- people = people.joins(:tickets => {:show => :event}).where("events.id" => event_id) unless event_id.blank?
92
- people = people.where("addresses.zip" => zip.to_s) unless zip.blank?
93
- people = people.where("addresses.state" => state) unless state.blank?
94
- people = people.where("people.lifetime_value >= ?", min_lifetime_value * 100.0) unless min_lifetime_value.blank?
95
- people = people.where("people.lifetime_value <= ?", max_lifetime_value * 100.0) unless max_lifetime_value.blank?
190
+ def find_people
191
+ column_names = Person.column_names.collect {|cn| "people.#{cn}" }
96
192
 
97
- unless discount_code.blank?
98
- people = people.joins(:orders => [:items => [:discount]])
99
- people = (discount_code == Discount::ALL_DISCOUNTS_STRING) ? people.where("items.discount_id is not null") : people.where("discounts.code = ?", discount_code)
193
+ people = Person.where(:organization_id => organization_id)
194
+ people = people.where(:dummy => false)
195
+ people = people.order('ordered_last_names ASC')
196
+
197
+ people = people.tagged_with(tagging) unless tagging.blank?
198
+ people = people.joins(:address) unless zip.blank? && state.blank?
199
+
200
+ people = add_event_query(people, column_names)
201
+
202
+ people = people.where("addresses.zip" => zip.to_s) unless zip.blank?
203
+ people = people.where("addresses.state" => state) unless state.blank?
204
+ people = people.where("people.lifetime_value >= ?", min_lifetime_value * 100.0) unless min_lifetime_value.blank?
205
+ people = people.where("people.lifetime_value <= ?", max_lifetime_value * 100.0) unless max_lifetime_value.blank?
206
+
207
+ unless discount_code.blank?
208
+ people = people.joins(:orders => [:items => [:discount]])
209
+ people = (discount_code == Discount::ALL_DISCOUNTS_STRING) ? people.where("items.discount_id is not null") : people.where("discounts.code = ?", discount_code)
210
+ end
211
+
212
+ unless [min_donations_amount, max_donations_amount, min_donations_date, max_donations_date].all?(&:blank?)
213
+ people = people.joins(:orders => :items)
214
+ people = people.where("orders.created_at >= ?", min_donations_date) unless min_donations_date.blank?
215
+ people = people.where("orders.created_at <= ?", max_donations_date + 1.day) unless max_donations_date.blank?
216
+ people = people.where("items.product_type = 'Donation'")
217
+ people = people.group("people.id")
218
+ if min_donations_amount.blank?
219
+ people = people.having("SUM(items.price + items.nongift_amount) >= 1")
220
+ else
221
+ people = people.having("SUM(items.price + items.nongift_amount) >= ?", min_donations_amount * 100.0)
222
+ end
223
+ people = people.having("SUM(items.price + items.nongift_amount) <= ?", max_donations_amount * 100.0) unless max_donations_amount.blank?
224
+ end
225
+
226
+ ### MEMBERSHIP ##
227
+ if searching_membership?
228
+ people = people.joins('LEFT JOIN members ON members.person_id = people.id')
229
+ people = people.joins('LEFT JOIN memberships ON memberships.member_id = members.id ')
230
+ people = people.joins('LEFT JOIN membership_types ON membership_types.id = memberships.membership_type_id')
231
+ end
232
+
233
+ if membership_status.present?
234
+ people = people.merge(Member.current) if membership_status == 'Current'
235
+ people = people.merge(Member.lapsed) if membership_status == 'Lapsed'
236
+ people = people.merge(Member.past) if membership_status == 'Past'
237
+ people = people.where('members.id IS NULL') if membership_status == 'None'
238
+ end
239
+
240
+ if membership_type_id.present?
241
+ people = if any_membership_type?
242
+ people.where('memberships.member_id IS NOT NULL')
243
+ else
244
+ people.where('membership_types.id = ?', membership_type_id)
245
+ end
246
+ end
247
+
248
+ # Membership Start
249
+ people = people.where('memberships.starts_at >= ?', min_membership_start_date) if min_membership_start_date.present?
250
+ people = people.where('memberships.starts_at <= ?', max_membership_start_date) if max_membership_start_date.present?
251
+
252
+ # Membership End
253
+ people = people.where('memberships.ends_at >= ?', min_membership_end_date) if min_membership_end_date.present?
254
+ people = people.where('memberships.ends_at <= ?', max_membership_end_date) if max_membership_end_date.present?
255
+
256
+ ### PASSES ###
257
+ if searching_passes?
258
+ people = add_passes_query(people)
259
+ end
260
+
261
+ people = people.companies if output_companies && !output_individuals
262
+ people = people.where("people.subtype" => person_subtype) if output_companies && person_subtype.present?
263
+
264
+ people = people.individuals if !output_companies && output_individuals
265
+
266
+ people = people.joins('left join households on people.household_id = households.id') if output_households
267
+
268
+ people = people.in_household if households_only?
269
+
270
+ if relation_id.present?
271
+ people = people.joins('left join relationships on people.id = relationships.person_id')
272
+ people = people.where(:relationships => {:relation_id => relation_id})
273
+ end
274
+
275
+ column_names << "lower(people.last_name) AS ordered_last_names"
276
+ people.select(column_names).group("people.id")
100
277
  end
101
278
 
102
- unless [min_donations_amount, max_donations_amount, min_donations_date, max_donations_date].all?(&:blank?)
103
- people = people.joins(:orders => :items)
104
- people = people.where("orders.created_at >= ?", min_donations_date) unless min_donations_date.blank?
105
- people = people.where("orders.created_at <= ?", max_donations_date + 1.day) unless max_donations_date.blank?
106
- people = people.where("items.product_type = 'Donation'")
107
- people = people.group("people.id")
108
- if min_donations_amount.blank?
109
- people = people.having("SUM(items.price + items.nongift_amount) >= 1")
110
- else
111
- people = people.having("SUM(items.price + items.nongift_amount) >= ?", min_donations_amount * 100.0)
279
+ def households_only?
280
+ output_households && (!output_companies && !output_individuals)
281
+ end
282
+
283
+ def add_passes_query(people)
284
+ people = people.joins("LEFT JOIN #{Pass.table_name} ON #{Pass.table_name}.person_id = #{Person.table_name}.id")
285
+ people = people.merge(Pass.not_expired)
286
+ people = people.where("#{Pass.table_name}.pass_type_id = ?", pass_type_id)
287
+ people
288
+ end
289
+
290
+ def add_event_query(people, column_names)
291
+ if any_event?
292
+ people = add_any_event_query(people, column_names)
293
+ elsif specific_event?
294
+ people = add_specific_event_query(people, column_names)
112
295
  end
113
- people = people.having("SUM(items.price + items.nongift_amount) <= ?", max_donations_amount * 100.0) unless max_donations_amount.blank?
296
+
297
+ people
298
+ end
299
+
300
+ def add_specific_event_query(people, column_names)
301
+ if has_purchased_for
302
+ people = people.joins("LEFT JOIN `tickets` ON `tickets`.`buyer_id` = `people`.`id` ")
303
+ .joins("LEFT JOIN `shows` ON `shows`.`id` = `tickets`.`show_id` ")
304
+ .joins("LEFT JOIN `events` ON `events`.`id` = `shows`.`event_id`")
305
+
306
+ people = people.where("events.id" => event_id)
307
+
308
+ if show_date_search?
309
+ people = people.where("shows.datetime >= ?", offset_show_date_start) unless show_date_start.blank?
310
+ people = people.where("shows.datetime <= ?", offset_show_date_end) unless show_date_end.blank?
311
+ end
312
+
313
+ elsif !has_purchased_for
314
+ if show_date_search?
315
+ people_subquery = Ticket.joins(:show)
316
+ .where("shows.event_id = ?", event_id)
317
+ .where("tickets.buyer_id = people.id")
318
+
319
+ people_subquery = people_subquery.where("shows.datetime >= ?", offset_show_date_start) unless show_date_start.blank?
320
+ people_subquery = people_subquery.where("shows.datetime <= ?", offset_show_date_end) unless show_date_end.blank?
321
+
322
+ people = people.where("NOT EXISTS (#{people_subquery.to_sql})")
323
+ else
324
+ #
325
+ # Had to use a correlated subquery here. Sorry.
326
+ # ActiveRecord 3.2 does not support NOT IN, so we have to do some manual work here.
327
+ # AR 4.0 has NOT IN
328
+ #
329
+ people_subquery = Person.select("people.id")
330
+ .joins("LEFT JOIN `tickets` ON `tickets`.`buyer_id` = `people`.`id` ")
331
+ .joins("LEFT JOIN `shows` ON `shows`.`id` = `tickets`.`show_id` ")
332
+ .joins("LEFT JOIN `events` ON `events`.`id` = `shows`.`event_id`")
333
+ .where("events.id" => event_id)
334
+ people = people.where("people.id not in (#{people_subquery.to_sql})")
335
+ end
336
+
337
+ people
338
+ end
339
+
340
+ people
341
+ end
342
+
343
+ def add_any_event_query(people, column_names)
344
+ people = people.joins("LEFT JOIN `tickets` ON `tickets`.`buyer_id` = `people`.`id` ")
345
+
346
+ if has_purchased_for
347
+ column_names << "count(tickets.id) as ticket_count"
348
+ if show_date_search?
349
+ people = people.joins("LEFT JOIN `shows` ON `shows`.`id` = `tickets`.`show_id` ")
350
+ people = people.where("shows.datetime >= ?", offset_show_date_start) unless show_date_start.blank?
351
+ people = people.where("shows.datetime <= ?", offset_show_date_end) unless show_date_end.blank?
352
+ end
353
+ people = people.having("ticket_count > 0")
354
+ elsif !has_purchased_for
355
+ if show_date_search?
356
+ people_subquery = Ticket.joins(:show)
357
+ .where("tickets.buyer_id = people.id")
358
+
359
+ people_subquery = people_subquery.where("shows.datetime >= ?", offset_show_date_start) unless show_date_start.blank?
360
+ people_subquery = people_subquery.where("shows.datetime <= ?", offset_show_date_end) unless show_date_end.blank?
361
+
362
+ people = people.where("NOT EXISTS (#{people_subquery.to_sql})")
363
+ else
364
+ column_names << "count(tickets.id) as ticket_count"
365
+ people = people.having("ticket_count = 0")
366
+ end
367
+ end
368
+
369
+ people
370
+ end
371
+
372
+ def searching_for_event?
373
+ event_id.present?
374
+ end
375
+
376
+ def show_date_search?
377
+ show_date_start.present? || show_date_end.present?
378
+ end
379
+
380
+ def any_event?
381
+ self.event_id == ANY_EVENT
382
+ end
383
+
384
+ def specific_event?
385
+ self.event_id.present? && self.event_id > ANY_EVENT
386
+ end
387
+
388
+ def any_membership_type?
389
+ membership_type_id == ANY_MEMBERSHIP_TYPE
390
+ end
391
+
392
+ def searching_passes?
393
+ pass_type_id.present?
394
+ end
395
+
396
+ def searching_membership?
397
+ [
398
+ :membership_status,
399
+ :membership_type_id,
400
+ :min_membership_start_date,
401
+ :max_membership_start_date,
402
+ :min_membership_end_date,
403
+ :max_membership_end_date
404
+ ].any? { |s| send(s).present? }
114
405
  end
115
- people.select(column_names).uniq
116
- end
117
406
  end