Module: FinePrint::ControllerAdditions::ClassMethods
- Defined in:
- lib/fine_print/controller_additions.rb
Instance Method Summary collapse
-
#fine_print_get_signatures(*args) ⇒ Object
See the README.
-
#fine_print_skip_signatures(*args) ⇒ Object
See the README.
Instance Method Details
#fine_print_get_signatures(*args) ⇒ Object
See the README
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/fine_print/controller_additions.rb', line 22 def fine_print_get_signatures(*args) = args.last.is_a?(Hash) ? args.pop : {} = .except(*FinePrint::SIGNATURE_OPTIONS) = .slice(*FinePrint::SIGNATURE_OPTIONS) # Convert all names to string names = args.flatten.collect{|n| n.to_s} class_eval do before_filter() do |controller| # If the user isn't signed in, they can't sign a contract. Since there # may be some pages that logged in and non-logged in users can visit, # just return quietly instead of raising an exception. user = FinePrint.current_user_proc.call(self) return true unless FinePrint.can_sign?(user) contract_names = names - fine_print_skipped_contract_names # Bail if nothing to do return true if contract_names.blank? unsigned_contract_names = FinePrint.get_unsigned_contract_names(user, contract_names) # Ignore contracts that don't yet exist or aren't yet published (happens # when adding code that requires a new contract but before that contract # has been added and published) unsigned_contract_names.reject!{|name| FinePrint.get_contract(name).blank?} return true if unsigned_contract_names.empty? # http://stackoverflow.com/a/2165727/1664216 session[:fine_print_return_to] = "#{request.protocol}#{request.host_with_port}#{request.fullpath}" # http://stackoverflow.com/a/6561953 path = [:pose_contracts_path] || FinePrint.pose_contracts_path redirect_to path + (path.include?('?') ? '&' : '?') + {:terms => unsigned_contract_names}.to_query end end end |
#fine_print_skip_signatures(*args) ⇒ Object
See the README
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/fine_print/controller_additions.rb', line 64 def fine_print_skip_signatures(*args) = args.last.is_a?(Hash) ? args.pop : {} # Convert all names to string names = args.flatten.collect{|n| n.to_s} class_eval do prepend_before_filter() do |controller| fine_print_skipped_contract_names.push(*names) end end end |