app/controllers/store/donations_controller.rb in artfully_ose-1.2.0 vs app/controllers/store/donations_controller.rb in artfully_ose-1.3.0.pre1
- old
+ new
@@ -4,19 +4,35 @@
:content_type => Mime::HTML,
:status => :not_found
end
def index
- # If there is no kit at all, NotFound
- raise ActionController::RoutingError.new('Not Found') unless @store_organization.has_kit?(:regular_donation)
+ bonk if no_kit
+ bonk if storefront_off && !producer_logged_in?
+ add_preview_text if storefront_off && producer_logged_in?
+ load_types_and_kit
+ end
- # If there's a kit, and they're logged in, show them a preview if the kit is off
- if current_user && current_user.current_organization == @store_organization
- if !@store_organization.has_active_donation_only_storefront?
- flash[:notice] = "You are seeing a preview of your donation-only storefront. To make this page visible to the general public, go to your 501(c)(3) kit configuration and check \"Display Donation-Only Storefront\""
- end
- else
- # show everyone else NotFound
- raise ActionController::RoutingError.new('Not Found') unless @store_organization.has_active_donation_only_storefront?
+ private
+ def load_types_and_kit
end
- end
+
+ def bonk
+ raise ActionController::RoutingError.new('Not Found')
+ end
+
+ def no_kit
+ !@store_organization.has_kit?(:regular_donation)
+ end
+
+ def storefront_off
+ !@store_organization.has_active_donation_only_storefront?
+ end
+
+ def producer_logged_in?
+ current_user && current_user.current_organization == @store_organization
+ end
+
+ def add_preview_text
+ flash[:notice] = "You are seeing a preview of your donation-only storefront. To make this page visible to the general public, go to your 501(c)(3) kit configuration and check \"Display Donation-Only Storefront\""
+ end
end