artfully_ose 1.0.0.rc4 → 1.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +661 -0
- data/app/assets/fonts/FontAwesome.otf +0 -0
- data/app/assets/fonts/fontawesome-webfont.eot +0 -0
- data/app/assets/fonts/fontawesome-webfont.svg +284 -0
- data/app/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/app/assets/fonts/fontawesome-webfont.woff +0 -0
- data/app/assets/images/chosen-sprite.png +0 -0
- data/app/assets/javascripts/application.js +88 -44
- data/app/assets/javascripts/box-office.js +7 -3
- data/app/assets/javascripts/custom/grouped-form.js +1 -1
- data/app/assets/javascripts/custom/modernizr.custom.12828.js +4 -0
- data/app/assets/javascripts/custom/people.js +30 -1
- data/app/assets/javascripts/jquery-lib/chosen.jquery.js +1026 -0
- data/app/assets/javascripts/jquery-lib/jquery.jeditable.js +1 -1
- data/app/assets/javascripts/jquery-lib/jquery.mask-money.js +90 -60
- data/app/assets/javascripts/store/store.js +112 -67
- data/app/assets/stylesheets/application.sass +174 -1
- data/app/assets/stylesheets/bootstrap-overrides.css +51 -13
- data/app/assets/stylesheets/bootstrap.css +4 -379
- data/app/assets/stylesheets/font-awesome.sass +759 -0
- data/app/assets/stylesheets/jquery/chosen.scss +397 -0
- data/app/assets/stylesheets/printing.css +5 -1
- data/app/assets/stylesheets/sass/store.sass +18 -3
- data/app/concerns/itemable.rb +11 -0
- data/app/concerns/oh_noes.rb +24 -0
- data/app/controllers/actions_controller.rb +39 -20
- data/app/controllers/addresses_controller.rb +2 -2
- data/app/controllers/artfully_ose_controller.rb +15 -1
- data/app/controllers/charts_controller.rb +6 -2
- data/app/controllers/contributions_controller.rb +28 -1
- data/app/controllers/discounts_controller.rb +65 -0
- data/app/controllers/discounts_reports_controller.rb +22 -0
- data/app/controllers/events_controller.rb +48 -45
- data/app/controllers/exchanges_controller.rb +10 -10
- data/app/controllers/imports_controller.rb +38 -20
- data/app/controllers/index_controller.rb +1 -1
- data/app/controllers/memberships_controller.rb +1 -0
- data/app/controllers/merges_controller.rb +1 -1
- data/app/controllers/orders_controller.rb +6 -12
- data/app/controllers/organizations_controller.rb +0 -1
- data/app/controllers/people_controller.rb +10 -12
- data/app/controllers/refunds_controller.rb +2 -2
- data/app/controllers/returns_controller.rb +0 -1
- data/app/controllers/sales_controller.rb +9 -6
- data/app/controllers/searches_controller.rb +53 -0
- data/app/controllers/sections_controller.rb +12 -1
- data/app/controllers/segments_controller.rb +23 -10
- data/app/controllers/shows_controller.rb +37 -28
- data/app/controllers/slices_controller.rb +37 -0
- data/app/controllers/statements_controller.rb +4 -4
- data/app/controllers/store/checkouts_controller.rb +14 -12
- data/app/controllers/store/events_controller.rb +1 -1
- data/app/controllers/store/orders_controller.rb +32 -5
- data/app/controllers/store/store_controller.rb +4 -0
- data/app/controllers/venues_controller.rb +6 -2
- data/app/helpers/artfully_ose_helper.rb +31 -5
- data/app/helpers/discounts_helper.rb +3 -0
- data/app/helpers/people_helper.rb +2 -19
- data/app/mailers/order_mailer.rb +21 -3
- data/app/mailers/producer_mailer.rb +9 -1
- data/app/mailers/reports_mailer.rb +12 -0
- data/app/models/action.rb +29 -3
- data/app/models/actions/get_action.rb +4 -0
- data/app/models/actions/go_action.rb +18 -0
- data/app/models/actions/refund_action.rb +14 -0
- data/app/models/address.rb +6 -16
- data/app/models/adjustments.rb +10 -0
- data/app/models/box_office.rb +1 -1
- data/app/models/carts/cart.rb +35 -24
- data/app/models/chart.rb +16 -8
- data/app/models/checkout.rb +32 -9
- data/app/models/comp.rb +2 -8
- data/app/models/contribution.rb +111 -25
- data/app/models/daily_donation_report.rb +45 -0
- data/app/models/daily_ticket_report.rb +51 -0
- data/app/models/discount.rb +137 -0
- data/app/models/discounts/buy_one_get_one_free_discount_type.rb +20 -0
- data/app/models/discounts/discount_type.rb +66 -0
- data/app/models/discounts/dollars_off_tickets_discount_type.rb +32 -0
- data/app/models/discounts/percentage_off_tickets_discount_type.rb +25 -0
- data/app/models/discounts_report.rb +87 -0
- data/app/models/donation.rb +2 -0
- data/app/models/door_list.rb +5 -4
- data/app/models/event.rb +45 -16
- data/app/models/exchange.rb +26 -15
- data/app/models/ext/delayed_indexing.rb +24 -0
- data/app/models/ext/due.rb +7 -0
- data/app/models/ext/ext.rb +37 -0
- data/app/models/ext/integrations.rb +30 -0
- data/app/models/ext/resellable.rb +8 -1
- data/app/models/gateway_transaction.rb +47 -0
- data/app/models/import.rb +83 -101
- data/app/models/import_error.rb +1 -1
- data/app/models/import_row.rb +1 -1
- data/app/models/imports/donations_import.rb +103 -0
- data/app/models/imports/events_import.rb +207 -0
- data/app/models/imports/people_import.rb +41 -0
- data/app/models/imports/processing.rb +53 -0
- data/app/models/imports/rollback.rb +11 -0
- data/app/models/imports/status.rb +48 -0
- data/app/models/imports/validations.rb +31 -0
- data/app/models/item.rb +112 -29
- data/app/models/job/action_job.rb +29 -0
- data/app/models/job/daily_email_report_job.rb +11 -0
- data/app/models/job/tag_job.rb +15 -0
- data/app/models/kit.rb +14 -6
- data/app/models/kits/mailchimp_kit.rb +448 -0
- data/app/models/kits/reseller_kit.rb +2 -2
- data/app/models/kits/sponsored_donation_kit.rb +2 -2
- data/app/models/orders/application_order.rb +3 -1
- data/app/models/orders/comp_order.rb +15 -2
- data/app/models/orders/exchange_order.rb +8 -0
- data/app/models/orders/imported_order.rb +7 -0
- data/app/models/orders/order.rb +164 -51
- data/app/models/orders/refund_order.rb +14 -1
- data/app/models/orders/unrefundable.rb +5 -0
- data/app/models/orders/web_order.rb +1 -1
- data/app/models/organization.rb +38 -7
- data/app/models/parsed_row.rb +167 -0
- data/app/models/payments/comp_payment.rb +10 -1
- data/app/models/payments/credit_card_payment.rb +63 -10
- data/app/models/payments/payment.rb +28 -0
- data/app/models/person.rb +115 -43
- data/app/models/refund.rb +28 -28
- data/app/models/return.rb +2 -0
- data/app/models/sale.rb +8 -5
- data/app/models/search.rb +117 -0
- data/app/models/section.rb +18 -0
- data/app/models/segment.rb +14 -4
- data/app/models/show.rb +14 -4
- data/app/models/slices.rb +82 -0
- data/app/models/statement.rb +170 -3
- data/app/models/temp_discount.rb +14 -0
- data/app/models/ticket.rb +42 -134
- data/app/models/ticket/pricing.rb +45 -0
- data/app/models/ticket/reports.rb +10 -7
- data/app/models/ticket/sale_transitions.rb +44 -0
- data/app/models/ticket/transfers.rb +50 -0
- data/app/models/user.rb +10 -2
- data/app/models/valuation/lifetime_donations.rb +35 -0
- data/app/models/venue.rb +12 -1
- data/app/presenters/event_presenter.rb +41 -0
- data/app/views/actions/_list.html.haml +1 -2
- data/app/views/actions/new.html.haml +1 -1
- data/app/views/contributions/_form.html.haml +40 -0
- data/app/views/contributions/_sidebar.html.haml +12 -0
- data/app/views/contributions/edit.html.haml +11 -0
- data/app/views/contributions/index.html.haml +2 -2
- data/app/views/contributions/new.html.haml +5 -35
- data/app/views/discounts/_discount_section_fields.html.haml +25 -0
- data/app/views/discounts/_form.html.haml +95 -0
- data/app/views/discounts/edit.html.haml +16 -0
- data/app/views/discounts/index.html.haml +33 -0
- data/app/views/discounts/new.html.haml +16 -0
- data/app/views/discounts_reports/index.html.haml +76 -0
- data/app/views/events/_discount_section_fields.html.haml +25 -0
- data/app/views/events/_glance.html.haml +4 -1
- data/app/views/events/_list.html.haml +2 -4
- data/app/views/events/_menu.html.haml +3 -3
- data/app/views/events/_section_fields.html.haml +32 -15
- data/app/views/events/_share_and_sell.haml +2 -1
- data/app/views/events/edit.html.haml +7 -6
- data/app/views/events/image.html.haml +1 -0
- data/app/views/events/index.html.haml +3 -1
- data/app/views/events/messages.html.haml +1 -0
- data/app/views/events/prices.html.haml +2 -1
- data/app/views/events/resell.html.haml +1 -1
- data/app/views/events/show.html.haml +25 -1
- data/app/views/events/storefront_link.html.haml +1 -1
- data/app/views/events/temp_discount_form.html.haml +108 -0
- data/app/views/events/temp_discounts_index.html.haml +38 -0
- data/app/views/events/widget.html.haml +14 -1
- data/app/views/exchanges/new.html.haml +50 -73
- data/app/views/imports/{_imported.html.haml → donations/_approved.html.haml} +2 -5
- data/app/views/imports/donations/_caching.html.haml +17 -0
- data/app/views/imports/donations/_failed.html.haml +5 -0
- data/app/views/imports/donations/_imported.html.haml +9 -0
- data/app/views/imports/donations/_importing.html.haml +12 -0
- data/app/views/imports/donations/_invalid.html.haml +5 -0
- data/app/views/imports/donations/_new.html.haml +99 -0
- data/app/views/imports/donations/_pending.html.haml +41 -0
- data/app/views/imports/events/_approved.html.haml +10 -0
- data/app/views/imports/events/_caching.html.haml +17 -0
- data/app/views/imports/events/_failed.html.haml +5 -0
- data/app/views/imports/events/_imported.html.haml +9 -0
- data/app/views/imports/events/_importing.html.haml +12 -0
- data/app/views/imports/events/_invalid.html.haml +5 -0
- data/app/views/imports/events/_new.html.haml +95 -0
- data/app/views/imports/events/_pending.html.haml +35 -0
- data/app/views/imports/index.html.haml +41 -18
- data/app/views/imports/new.html.haml +1 -93
- data/app/views/imports/{_approved.html.haml → people/_approved.html.haml} +0 -1
- data/app/views/imports/{_caching.html.haml → people/_caching.html.haml} +0 -0
- data/app/views/imports/people/_failed.html.haml +5 -0
- data/app/views/imports/people/_imported.html.haml +25 -0
- data/app/views/imports/{_importing.html.haml → people/_importing.html.haml} +1 -2
- data/app/views/imports/people/_invalid.html.haml +5 -0
- data/app/views/imports/people/_new.html.haml +120 -0
- data/app/views/imports/people/_pending.html.haml +39 -0
- data/app/views/imports/shared/_date_format.html.haml +14 -0
- data/app/views/imports/shared/_failed.html.haml +18 -0
- data/app/views/imports/shared/_inspect_modal.html.haml +11 -0
- data/app/views/imports/shared/_invalid.html.haml +18 -0
- data/app/views/imports/shared/_knowledge_base.haml +2 -0
- data/app/views/imports/shared/_sidebar.html.haml +5 -0
- data/app/views/imports/show.html.haml +2 -2
- data/app/views/index/dashboard.html.haml +4 -2
- data/app/views/layouts/_custom_css_includes.haml +0 -0
- data/app/views/layouts/_custom_js_includes.haml +0 -0
- data/app/views/layouts/_google_analytics.html.haml +3 -3
- data/app/views/layouts/_menu.html.haml +6 -2
- data/app/views/layouts/application.html.haml +4 -0
- data/app/views/layouts/{devise.html.haml → devise_layout.html.haml} +0 -0
- data/app/views/order_mailer/confirmation_for.html.haml +3 -2
- data/app/views/order_mailer/confirmation_for.text.haml +3 -2
- data/app/views/orders/_grouped_form_help.haml +4 -0
- data/app/views/orders/_item_table.haml +15 -4
- data/app/views/orders/_order_sidebar.html.haml +27 -6
- data/app/views/orders/index.html.haml +1 -12
- data/app/views/orders/show.html.haml +1 -1
- data/app/views/organizations/_form.html.haml +20 -6
- data/app/views/organizations/edit.html.haml +2 -1
- data/app/views/organizations/new.html.haml +1 -0
- data/app/views/organizations/show.html.haml +7 -1
- data/app/views/people/_form.html.haml +5 -2
- data/app/views/people/_key_relationships.html.haml +1 -1
- data/app/views/people/_list.html.haml +1 -12
- data/app/views/people/_person_summary_sidebar.html.haml +82 -50
- data/app/views/people/_relationship_table_row.html.haml +1 -1
- data/app/views/people/edit.html.haml +3 -1
- data/app/views/people/index.html.haml +7 -1
- data/app/views/people/new.html.haml +2 -0
- data/app/views/people/show.html.haml +2 -0
- data/app/views/refunds/new.html.haml +4 -6
- data/app/views/reports_mailer/daily.html.haml +67 -0
- data/app/views/reports_mailer/daily.text.erb +16 -0
- data/app/views/sales/new.html.haml +5 -20
- data/app/views/searches/_form.html.haml +43 -0
- data/app/views/searches/_person.html.haml +7 -0
- data/app/views/searches/new.html.haml +10 -0
- data/app/views/searches/show.html.haml +64 -0
- data/app/views/sections/edit.html.haml +12 -0
- data/app/views/segments/index.html.haml +8 -4
- data/app/views/segments/show.html.haml +39 -5
- data/app/views/shared/_door_list_table.haml +24 -0
- data/app/views/shared/_event_image_icon.html.haml +1 -1
- data/app/views/shared/_preload_assets.html.haml +2 -0
- data/app/views/shared/_tags.html.haml +3 -2
- data/app/views/shows/_glance.html.haml +8 -2
- data/app/views/shows/_ticket_table.html.haml +17 -10
- data/app/views/shows/_upcoming.html.haml +1 -1
- data/app/views/shows/door_list.html.haml +2 -24
- data/app/views/shows/index.html.haml +3 -3
- data/app/views/shows/new.html.haml +2 -2
- data/app/views/shows/show.html.haml +1 -1
- data/app/views/slices/_data.json +50 -0
- data/app/views/slices/index.html.haml +58 -0
- data/app/views/statements/_discounts_table.html.haml +26 -0
- data/app/views/statements/_order_location_table.html.haml +20 -0
- data/app/views/statements/_payment_method_table.haml +20 -0
- data/app/views/statements/{_played_shows.html.haml → _shows.html.haml} +3 -3
- data/app/views/statements/_ticket_type_table.haml +20 -0
- data/app/views/statements/_top_stats.haml +12 -0
- data/app/views/statements/show.html.haml +24 -32
- data/app/views/store/events/_show.html.haml +11 -5
- data/app/views/store/events/show.html.haml +24 -5
- data/app/views/users/registrations/edit.html.erb +1 -1
- data/app/views/venues/edit.html.haml +1 -0
- data/config/artfully.yml.sample +3 -0
- data/config/initializers/active_model_serializer.rb +3 -0
- data/config/initializers/braintree_error_mapping.rb +5 -0
- data/config/initializers/devise.rb +1 -1
- data/config/locales/en.yml +1 -0
- data/config/routes.rb +31 -8
- data/db/migrate/0000_set_up_artfully.rb +9 -11
- data/db/migrate/20120809212802_add_do_not_email_to_people.rb +5 -0
- data/db/migrate/20120831200120_create_advanced_search.rb +30 -0
- data/db/migrate/20120926201927_add_email_to_organization.rb +5 -0
- data/db/migrate/20121001143351_add_import_id_orders_events.rb +6 -0
- data/db/migrate/20121006024736_add_import_to_actions.rb +5 -0
- data/db/migrate/20121011180654_add_type_to_imports.rb +14 -0
- data/db/migrate/20121024143846_create_discounts.rb +15 -0
- data/db/migrate/20121026131454_deleted_at_to_orders_items_actions.rb +7 -0
- data/db/migrate/20121026203948_add_initial_price_to_tickets.rb +5 -0
- data/db/migrate/20121029183949_change_initial_price_to_cart_price.rb +5 -0
- data/db/migrate/20121113144826_migrate_donation_types.rb +41 -0
- data/db/migrate/20121115020441_add_salutation_to_people.rb +5 -0
- data/db/migrate/20121130004314_add_visibility_to_sections.rb +6 -0
- data/db/migrate/20121205184343_add_discount_to_ticket.rb +6 -0
- data/db/migrate/20121206212835_add_discount_to_carts_and_items.rb +7 -0
- data/db/migrate/20121211193728_add_deleted_at_to_discounts.rb +5 -0
- data/db/migrate/20121212022026_add_uuid_to_show_and_event.rb +9 -0
- data/db/migrate/20121212023203_set_uuids.rb +11 -0
- data/db/migrate/20121217201422_add_minimum_ticket_count_to_discounts.rb +5 -0
- data/db/migrate/20121221154152_add_shows_and_sections_to_discounts.rb +5 -0
- data/db/migrate/20130103153946_make_shows_and_sections_habtm.rb +19 -0
- data/db/migrate/20130108213102_add_original_price_to_items.rb +10 -0
- data/db/migrate/20130111211929_convert_discounts_sections_to_array_of_strings.rb +14 -0
- data/db/migrate/20130114200128_add_discount_code_to_search.rb +5 -0
- data/db/migrate/20130114212408_add_limit_to_discounts.rb +5 -0
- data/db/migrate/20130116203331_add_title_to_person.rb +5 -0
- data/db/migrate/20130122143845_install_audited.rb +28 -0
- data/db/migrate/20130131024955_add_gateway_transactions.rb +13 -0
- data/db/migrate/20130301144159_add_receive_daily_sales_report_boolean_to_organizations.rb +5 -0
- data/db/migrate/20130306213416_add_subscribed_lists_to_people.rb +5 -0
- data/db/migrate/20130308193328_people_arent_dummies.rb +6 -0
- data/db/migrate/20130312173340_add_categories_to_events.rb +6 -0
- data/db/migrate/20130319110520_add_transaction_id_index.rb +6 -0
- data/db/migrate/20130320192827_add_index_to_notes.rb +8 -0
- data/db/migrate/20130324173939_add_index_to_import_rows.rb +5 -0
- data/db/migrate/20130325190110_add_indexes_to_actions.rb +9 -0
- data/db/migrate/20130326173653_add_lifetime_donations_to_people_and_searches.rb +9 -0
- data/lib/artfully_ose.rb +5 -1
- data/lib/artfully_ose/common_abilities.rb +6 -9
- data/lib/artfully_ose/engine.rb +19 -5
- data/lib/artfully_ose/version.rb +1 -1
- data/lib/email_validator.rb +6 -0
- metadata +442 -138
- data/MIT-LICENSE +0 -20
- data/app/controllers/pages_controller.rb +0 -29
- data/app/models/import_person.rb +0 -78
- data/app/views/imports/_failed.html.haml +0 -20
- data/app/views/imports/_pending.html.haml +0 -35
- data/app/views/index/splash.html.erb +0 -160
- data/app/views/segments/new.html.haml +0 -20
@@ -1,5 +1,5 @@
|
|
1
1
|
class ProducerMailer < ActionMailer::Base
|
2
|
-
default :from =>
|
2
|
+
default :from => ARTFULLY_CONFIG[:contact_email]
|
3
3
|
layout "mail"
|
4
4
|
|
5
5
|
def donation_kit_notification(kit, producer)
|
@@ -35,4 +35,12 @@ class ProducerMailer < ActionMailer::Base
|
|
35
35
|
|
36
36
|
mail :to => @producer.email, :subject => "Artful.ly: Ticket Offer Rejected"
|
37
37
|
end
|
38
|
+
|
39
|
+
def mailchimp_kit_initial_sync_notification(kit, producer, list_name)
|
40
|
+
@kit = kit
|
41
|
+
@list_name = list_name
|
42
|
+
@organization = kit.organization
|
43
|
+
|
44
|
+
mail :to => producer.email, :subject => "Artful.ly: MailChimp kit synced"
|
45
|
+
end
|
38
46
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class ReportsMailer < ActionMailer::Base
|
2
|
+
default :from => ARTFULLY_CONFIG[:contact_email]
|
3
|
+
layout "mail"
|
4
|
+
add_template_helper(ApplicationHelper)
|
5
|
+
add_template_helper(ArtfullyOseHelper)
|
6
|
+
|
7
|
+
def daily(tix, donations)
|
8
|
+
@tix = tix
|
9
|
+
@donations = donations
|
10
|
+
mail to: @tix.organization.owner.email, subject: "Daily Report for #{@tix.date.to_s(:long)}"
|
11
|
+
end
|
12
|
+
end
|
data/app/models/action.rb
CHANGED
@@ -1,18 +1,21 @@
|
|
1
1
|
class Action < ActiveRecord::Base
|
2
|
+
include OhNoes::Destroy
|
3
|
+
|
2
4
|
belongs_to :person
|
3
5
|
belongs_to :creator, :class_name => "User", :foreign_key => "creator_id"
|
4
6
|
belongs_to :organization
|
5
7
|
belongs_to :subject, :polymorphic => true
|
8
|
+
belongs_to :import
|
6
9
|
|
7
10
|
validates_presence_of :occurred_at
|
8
11
|
validates_presence_of :person_id
|
9
12
|
|
10
13
|
set_watch_for :occurred_at, :local_to => :organization
|
14
|
+
|
11
15
|
#
|
12
16
|
# Action types: give, go, do, get, join, hear
|
13
17
|
#
|
14
|
-
|
15
|
-
GIVE_TYPES = [ "Donation (Cash)", "Donation (Check)", "Donation (In-Kind)" ].freeze
|
18
|
+
GIVE_TYPES = [ "Monetary", "In-Kind" ].freeze
|
16
19
|
|
17
20
|
def self.create_of_type(type)
|
18
21
|
case type
|
@@ -67,11 +70,34 @@ class Action < ActiveRecord::Base
|
|
67
70
|
"Press" ]
|
68
71
|
end
|
69
72
|
|
73
|
+
#This returnes an ARel, so you can chain
|
70
74
|
def self.recent(organization, limit = 5)
|
71
|
-
Action.includes(:person).where(:organization_id => organization).order('
|
75
|
+
Action.includes(:person).where(:organization_id => organization).order('occurred_at DESC').limit(limit)
|
72
76
|
end
|
73
77
|
|
74
78
|
def give_action_subtypes
|
75
79
|
GIVE_TYPES
|
76
80
|
end
|
81
|
+
|
82
|
+
#
|
83
|
+
# This exists solely so that DJ can serialize an unsaved action so that ActionJob can run
|
84
|
+
# There's nothing inherent to Action in this method so it looks like a good candidate to
|
85
|
+
# move into a Module. But, I'm not thrilled with it and don't want it used willy-nilly
|
86
|
+
# Perhaps in an DelayedJob::Unsaved::Serializable Module or something.
|
87
|
+
#
|
88
|
+
def to_open_struct
|
89
|
+
action_struct = OpenStruct.new
|
90
|
+
self.class.column_names.each do |col|
|
91
|
+
action_struct.send("#{col}=", self.send(col))
|
92
|
+
end
|
93
|
+
action_struct
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.from_open_struct(action_struct)
|
97
|
+
action = Kernel.const_get(action_struct.type).new
|
98
|
+
Kernel.const_get(action_struct.type).column_names.each do |col|
|
99
|
+
action.send("#{col}=", action_struct.send(col)) unless action_struct.send(col).nil?
|
100
|
+
end
|
101
|
+
action
|
102
|
+
end
|
77
103
|
end
|
@@ -2,4 +2,22 @@ class GoAction < Action
|
|
2
2
|
def action_type
|
3
3
|
"Go"
|
4
4
|
end
|
5
|
+
|
6
|
+
def verb
|
7
|
+
"attended"
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.for(show, person, occurred_at=nil)
|
11
|
+
GoAction.new.tap do |go_action|
|
12
|
+
go_action.person = person
|
13
|
+
go_action.subject = show
|
14
|
+
go_action.details = "attended #{show.event}"
|
15
|
+
go_action.organization = show.organization
|
16
|
+
go_action.occurred_at = ( occurred_at.nil? ? show.datetime : occurred_at )
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def sentence
|
21
|
+
details
|
22
|
+
end
|
5
23
|
end
|
data/app/models/address.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class Address < ActiveRecord::Base
|
2
|
-
attr_accessible :address1, :address2, :city, :state, :zip, :country
|
2
|
+
attr_accessible :address1, :address2, :city, :state, :zip, :country, :person_id
|
3
3
|
belongs_to :person
|
4
4
|
|
5
5
|
validates :person_id, :presence => true
|
@@ -22,20 +22,7 @@ class Address < ActiveRecord::Base
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.from_payment(payment)
|
25
|
-
|
26
|
-
billing_address = payment.billing_address
|
27
|
-
|
28
|
-
new({
|
29
|
-
:address1 => billing_address.street_address1,
|
30
|
-
:address2 => billing_address.street_address2,
|
31
|
-
:city => billing_address.city,
|
32
|
-
:state => billing_address.state,
|
33
|
-
:zip => billing_address.postal_code,
|
34
|
-
:country => billing_address.country
|
35
|
-
})
|
36
|
-
else
|
37
|
-
nil
|
38
|
-
end
|
25
|
+
payment.try(:customer).try(:address)
|
39
26
|
end
|
40
27
|
|
41
28
|
def self.unhash(address)
|
@@ -57,9 +44,12 @@ class Address < ActiveRecord::Base
|
|
57
44
|
|
58
45
|
if save
|
59
46
|
extra = updated_by.nil? ? "" : " from #{updated_by}"
|
47
|
+
text = "address updated#{extra}"
|
48
|
+
text = text + ", old address was: (#{old_addr})" unless old_addr.blank?
|
60
49
|
note = person.notes.create({
|
61
50
|
:occurred_at => DateTime.now.in_time_zone(time_zone),
|
62
|
-
:text =>
|
51
|
+
:text => text
|
52
|
+
})
|
63
53
|
note.user = user
|
64
54
|
else
|
65
55
|
return false
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Adjustments
|
2
|
+
def service_fee_per_item(itmz)
|
3
|
+
#ternery operation solely to avoid dividing by zero
|
4
|
+
number_of_non_free_items(itmz) == 0 ? 0 : (order.service_fee || 0) / number_of_non_free_items(itmz)
|
5
|
+
end
|
6
|
+
|
7
|
+
def number_of_non_free_items(itmz)
|
8
|
+
itmz.reject{|item| item.original_price == 0}.size
|
9
|
+
end
|
10
|
+
end
|
data/app/models/box_office.rb
CHANGED
data/app/models/carts/cart.rb
CHANGED
@@ -3,15 +3,17 @@ class Cart < ActiveRecord::Base
|
|
3
3
|
|
4
4
|
has_many :donations, :dependent => :destroy
|
5
5
|
has_many :tickets, :after_add => :set_timeout
|
6
|
-
after_destroy :
|
6
|
+
after_destroy :clear!
|
7
7
|
attr_accessor :special_instructions
|
8
8
|
|
9
|
+
belongs_to :discount
|
10
|
+
|
9
11
|
state_machine do
|
10
12
|
state :started
|
11
13
|
state :approved
|
12
14
|
state :rejected
|
13
15
|
|
14
|
-
event(:approve) { transitions :from => [ :started, :rejected ], :to => :approved }
|
16
|
+
event(:approve, :success => :record_sold_price) { transitions :from => [ :started, :rejected ], :to => :approved }
|
15
17
|
event(:reject) { transitions :from => [ :started, :rejected ], :to => :rejected }
|
16
18
|
end
|
17
19
|
|
@@ -25,6 +27,7 @@ class Cart < ActiveRecord::Base
|
|
25
27
|
end
|
26
28
|
|
27
29
|
def clear!
|
30
|
+
reset_prices_on_tickets
|
28
31
|
clear_tickets
|
29
32
|
clear_donations
|
30
33
|
end
|
@@ -39,7 +42,7 @@ class Cart < ActiveRecord::Base
|
|
39
42
|
end
|
40
43
|
|
41
44
|
def release_tickets
|
42
|
-
tickets.each { |ticket| ticket.
|
45
|
+
tickets.each { |ticket| ticket.remove_from_cart }
|
43
46
|
end
|
44
47
|
|
45
48
|
def set_timeout(ticket)
|
@@ -51,6 +54,7 @@ class Cart < ActiveRecord::Base
|
|
51
54
|
end
|
52
55
|
|
53
56
|
def expire_ticket(ticket)
|
57
|
+
ticket.reset_price!
|
54
58
|
tickets.delete(ticket)
|
55
59
|
end
|
56
60
|
|
@@ -76,10 +80,22 @@ class Cart < ActiveRecord::Base
|
|
76
80
|
self.tickets << tkts
|
77
81
|
end
|
78
82
|
|
79
|
-
def
|
83
|
+
def subtotal
|
84
|
+
items.sum(&:price)
|
85
|
+
end
|
86
|
+
|
87
|
+
def total_before_discount
|
80
88
|
items.sum(&:price) + fee_in_cents
|
81
89
|
end
|
82
90
|
|
91
|
+
def total
|
92
|
+
items.sum(&:cart_price) + fee_in_cents
|
93
|
+
end
|
94
|
+
|
95
|
+
def discount_amount
|
96
|
+
total_before_discount - total
|
97
|
+
end
|
98
|
+
|
83
99
|
def unfinished?
|
84
100
|
started? or rejected?
|
85
101
|
end
|
@@ -93,15 +109,14 @@ class Cart < ActiveRecord::Base
|
|
93
109
|
|
94
110
|
#TODO: Move the requires_authorization? check into the payments classes. Cart shouldn't care
|
95
111
|
if payment.requires_authorization?
|
112
|
+
options[:service_fee] = fee_in_cents
|
96
113
|
pay_with_authorization(payment, options)
|
97
114
|
else
|
98
115
|
approve!
|
99
116
|
end
|
100
117
|
end
|
101
118
|
|
102
|
-
def finish
|
103
|
-
metric_sale_total
|
104
|
-
tickets.each { |ticket| ticket.sell_to(person, order_timestamp) }
|
119
|
+
def finish
|
105
120
|
end
|
106
121
|
|
107
122
|
def generate_donations
|
@@ -134,27 +149,23 @@ class Cart < ActiveRecord::Base
|
|
134
149
|
reseller == nil
|
135
150
|
end
|
136
151
|
|
152
|
+
def reset_prices_on_tickets
|
153
|
+
transaction do
|
154
|
+
tickets.each {|ticket| ticket.reset_price! }
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
137
158
|
private
|
138
159
|
|
139
|
-
def
|
140
|
-
|
141
|
-
|
160
|
+
def record_sold_price
|
161
|
+
self.tickets.each do |ticket|
|
162
|
+
ticket.sold_price = ticket.cart_price || ticket.price
|
163
|
+
ticket.save
|
164
|
+
end
|
142
165
|
end
|
143
166
|
|
144
|
-
def
|
145
|
-
|
146
|
-
case self.total
|
147
|
-
when 0 then "$0.00"
|
148
|
-
when (1 ... 1000) then "$0.01 - $9.99"
|
149
|
-
when (1000 ... 2000) then "$10 - $19.99"
|
150
|
-
when (2000 ... 5000) then "$20 - $49.99"
|
151
|
-
when (5000 ... 10000) then "$50 - $99.99"
|
152
|
-
when (10000 ... 25000) then "$100 - $249.99"
|
153
|
-
when (25000 ... 50000) then "$250 - $499.99"
|
154
|
-
else "$500 or more"
|
155
|
-
end
|
156
|
-
|
157
|
-
RestfulMetrics::Client.add_compound_metric(ENV["RESTFUL_METRICS_APP"], "sale_complete", [ bracket ])
|
167
|
+
def pay_with_authorization(payment, options)
|
168
|
+
payment.purchase(options) ? approve! : reject!
|
158
169
|
end
|
159
170
|
|
160
171
|
end
|
data/app/models/chart.rb
CHANGED
@@ -1,23 +1,29 @@
|
|
1
1
|
class Chart < ActiveRecord::Base
|
2
2
|
include Ticket::Foundry
|
3
3
|
foundry :using => :sections, :with => lambda { { :venue => event.venue.name } }
|
4
|
-
|
5
|
-
attr_accessible :name, :is_template, :event_id, :organization_id, :old_mongo_id, :sections_attributes, :organization, :event
|
4
|
+
attr_accessor :skip_create_first_section
|
5
|
+
attr_accessible :name, :is_template, :event_id, :organization_id, :old_mongo_id, :sections_attributes, :organization, :event, :skip_create_first_section
|
6
6
|
|
7
7
|
belongs_to :event
|
8
8
|
belongs_to :organization
|
9
9
|
has_one :show
|
10
10
|
has_many :sections, :order => 'price DESC'
|
11
11
|
accepts_nested_attributes_for :sections, :reject_if => lambda { |a| a[:capacity].blank? }, :allow_destroy => true
|
12
|
-
|
12
|
+
|
13
|
+
after_create :create_first_section, :unless => lambda { @skip_create_first_section == true }
|
13
14
|
|
14
15
|
validates :name, :presence => true, :length => { :maximum => 255 }
|
16
|
+
scope :template, where(:is_template => true)
|
15
17
|
|
16
18
|
def as_json(options = {})
|
17
|
-
|
19
|
+
h = super(options)
|
20
|
+
h[:sections] = sections.storefront
|
21
|
+
h
|
22
|
+
end
|
23
|
+
|
24
|
+
def widget_sections
|
25
|
+
self.sections.storefront.all
|
18
26
|
end
|
19
|
-
|
20
|
-
scope :template, where(:is_template => true)
|
21
27
|
|
22
28
|
# copy! is when they're editing charts and want to create a copy of
|
23
29
|
# this chart to modify further (weekday and weekend charts)
|
@@ -47,8 +53,10 @@ class Chart < ActiveRecord::Base
|
|
47
53
|
# HACK: The move to bootstrap left us with currency submission in the form os "DD.CC" which
|
48
54
|
# Artfully interpreted as DD.00.
|
49
55
|
# This hack converts DD.CC to DDCC
|
50
|
-
#
|
51
|
-
params_hash
|
56
|
+
#
|
57
|
+
params_hash ||= {}
|
58
|
+
|
59
|
+
params_hash.fetch(:sections_attributes, []).each do |index, section_hash|
|
52
60
|
new_price = Section.price_to_cents(section_hash['price'])
|
53
61
|
section_hash['price'] = new_price
|
54
62
|
end
|
data/app/models/checkout.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
class Checkout
|
2
2
|
include ActiveSupport::Callbacks
|
3
3
|
define_callbacks :payment
|
4
|
+
define_callbacks :order
|
4
5
|
|
5
6
|
include Ext::Callbacks::Checkout
|
6
7
|
|
@@ -10,6 +11,19 @@ class Checkout
|
|
10
11
|
def self.for(cart, payment)
|
11
12
|
cart.checkout_class.new(cart, payment)
|
12
13
|
end
|
14
|
+
|
15
|
+
def message
|
16
|
+
message = @payment.errors.full_messages.to_sentence.downcase
|
17
|
+
message = message.gsub('customer', 'contact info')
|
18
|
+
message = message.gsub('credit card is', 'payment details are')
|
19
|
+
message = message[0].upcase + message[1..message.length] unless message.blank? #capitalize first word
|
20
|
+
|
21
|
+
if message.blank?
|
22
|
+
message = "We had a problem validating your payment. Wait a few moments and try again or contact us to complete your purchase."
|
23
|
+
end
|
24
|
+
|
25
|
+
message
|
26
|
+
end
|
13
27
|
|
14
28
|
def initialize(cart, payment)
|
15
29
|
@cart = cart
|
@@ -32,33 +46,42 @@ class Checkout
|
|
32
46
|
end
|
33
47
|
|
34
48
|
def finish
|
35
|
-
@person = Person.find_or_create(@customer, cart.organizations.first)
|
36
|
-
@person.update_address(Address.from_payment(payment), cart.organizations.first.time_zone, nil, "checkout")
|
37
|
-
|
38
49
|
run_callbacks :payment do
|
39
|
-
|
50
|
+
pay
|
40
51
|
end
|
41
52
|
|
42
|
-
::Rails.logger.debug("Payment made, cart is approved: [#{cart.approved?}]")
|
43
|
-
|
44
53
|
if cart.approved?
|
45
54
|
order_timestamp = Time.now
|
46
|
-
create_order(order_timestamp)
|
47
|
-
cart.finish(@person, order_timestamp)
|
48
|
-
end
|
49
55
|
|
56
|
+
run_callbacks :order do
|
57
|
+
@created_orders = create_order(order_timestamp)
|
58
|
+
end
|
59
|
+
|
60
|
+
cart.finish
|
61
|
+
end
|
62
|
+
|
50
63
|
cart.approved?
|
51
64
|
end
|
65
|
+
|
66
|
+
def pay
|
67
|
+
@cart.pay_with(@payment)
|
68
|
+
@cart.approved?
|
69
|
+
end
|
52
70
|
|
53
71
|
private
|
54
72
|
def create_sub_orders(order_timestamp)
|
55
73
|
created_orders = []
|
56
74
|
cart.organizations.each do |organization|
|
75
|
+
@person = Person.find_or_create(@customer, organization)
|
76
|
+
@person.update_address(Address.from_payment(payment), organization.time_zone, nil, "checkout")
|
77
|
+
@person.add_phone_if_missing(payment.payment_phone_number)
|
78
|
+
|
57
79
|
@order = new_order(organization, order_timestamp, @person)
|
58
80
|
@order.save!
|
59
81
|
OrderMailer.confirmation_for(order).deliver unless @person.dummy? || @person.email.blank?
|
60
82
|
created_orders << @order
|
61
83
|
end
|
84
|
+
|
62
85
|
created_orders
|
63
86
|
end
|
64
87
|
|