Module: OfficeHelper
- Included in:
- OfficeController
- Defined in:
- app/helpers/office_helper.rb
Instance Method Summary collapse
-
#best_euros(p) ⇒ Object
this is the helper that best in place uses to display euros.
-
#current_basket ⇒ Object
the current user has a shopping basket which is also stored in the session we always return a basket, even if we have to create one (and then store in the session) this is not associated with the user until an order is finalized at which point the order gets the users email (not id) that way people don’t have to log in to order, but if they are we can retrieve their orders by email.
- #current_basket_or_nil ⇒ Object
-
#current_clerk ⇒ Object
users are stored in the session by email if user is not logged i , return nil.
- #date(d) ⇒ Object
-
#euros(price) ⇒ Object
euros displays the prices in …
- #has_ssl? ⇒ Boolean
- #markdown(text) ⇒ Object
-
#new_basket ⇒ Object
when the order is made and the basket locked, it’s time to make a new one.
-
#paginate(collection, options = {}) ⇒ Object
change the default link renderer for will_paginate and add global options.
- #shipping_method(name) ⇒ Object
Instance Method Details
#best_euros(p) ⇒ Object
this is the helper that best in place uses to display euros. it is different so it can be overriden
60 61 62 |
# File 'app/helpers/office_helper.rb', line 60 def best_euros p euros(p) end |
#current_basket ⇒ Object
the current user has a shopping basket which is also stored in the session we always return a basket, even if we have to create one (and then store in the session) this is not associated with the user until an order is finalized at which point the order gets the users email (not id) that way people don’t have to log in to order, but if they are we can retrieve their orders by email
23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/office_helper.rb', line 23 def current_basket @current_basket = current_basket_or_nil if @current_basket.nil? @current_basket = Basket.new(:kori_type => "Order") @current_basket.save! session[:current_basket] = @current_basket.id end @current_basket end |
#current_basket_or_nil ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'app/helpers/office_helper.rb', line 11 def current_basket_or_nil return @current_basket unless @current_basket.nil? if session[:current_basket] Basket.where( :id => session[:current_basket] ).limit(1).first else nil end end |
#current_clerk ⇒ Object
users are stored in the session by email if user is not logged i , return nil
6 7 8 9 10 |
# File 'app/helpers/office_helper.rb', line 6 def current_clerk return @current_clerk if @current_clerk return nil unless session[:clerk_email] @current_clerk = Clerk.where( :email => session[:clerk_email] ).limit(1).first end |
#date(d) ⇒ Object
64 65 66 67 |
# File 'app/helpers/office_helper.rb', line 64 def date d return "" unless d I18n.l d end |
#euros(price) ⇒ Object
euros displays the prices in … da da .. . euros. This could of course be configurable, but since taxes and possibly shipping don’t work in us, i wait for the pull
54 55 56 |
# File 'app/helpers/office_helper.rb', line 54 def euros price price ? number_to_currency(price , :precision => 2 , :unit => "€") : 0.0 end |
#has_ssl? ⇒ Boolean
33 34 35 36 |
# File 'app/helpers/office_helper.rb', line 33 def has_ssl? return false unless Rails.env.production? OfficeClerk.config(:has_ssl) == true end |
#markdown(text) ⇒ Object
47 48 49 50 |
# File 'app/helpers/office_helper.rb', line 47 def markdown text return "" if text.blank? return sanitize Kramdown::Document.new(text).to_html end |
#new_basket ⇒ Object
when the order is made and the basket locked, it’s time to make a new one
39 40 41 |
# File 'app/helpers/office_helper.rb', line 39 def new_basket session[:current_basket] = nil end |
#paginate(collection, options = {}) ⇒ Object
change the default link renderer for will_paginate and add global options
70 71 72 73 74 75 |
# File 'app/helpers/office_helper.rb', line 70 def paginate(collection , = {}) #options = options.merge defaults [:renderer] = BootstrapPagination::Rails [:params] = { :url_scope => :office } will_paginate collection, end |
#shipping_method(name) ⇒ Object
43 44 45 |
# File 'app/helpers/office_helper.rb', line 43 def shipping_method name OfficeClerk::ShippingMethod.method(name) end |