Module: Auth::Concerns::Work::CommunicationControllerConcern
- Extended by:
- ActiveSupport::Concern
- Included in:
- Work::CommunicationsController
- Defined in:
- app/controllers/auth/concerns/work/communication_controller_concern.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #initialize_vars ⇒ Object
- #new ⇒ Object
- #permitted_params ⇒ Object
- #set_cycle ⇒ Object
- #set_instruction ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/controllers/auth/concerns/work/communication_controller_concern.rb', line 76 def create if @auth_shopping_product @auth_work_instruction.communications << @auth_work_communication @auth_shopping_product.instructions[@instruction_index] = @auth_work_instruction @auth_shopping_product.save end respond_to do |format| format.html do render "show" end format.json do render :json => @auth_work_communication.to_json end end end |
#destroy ⇒ Object
112 113 114 |
# File 'app/controllers/auth/concerns/work/communication_controller_concern.rb', line 112 def destroy end |
#edit ⇒ Object
96 97 98 |
# File 'app/controllers/auth/concerns/work/communication_controller_concern.rb', line 96 def edit end |
#index ⇒ Object
100 101 102 |
# File 'app/controllers/auth/concerns/work/communication_controller_concern.rb', line 100 def index end |
#initialize_vars ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'app/controllers/auth/concerns/work/communication_controller_concern.rb', line 42 def initialize_vars instantiate_work_classes @auth_work_communication_params = permitted_params.fetch(:communication,{}) @auth_work_cycle = nil @auth_work_instruction = nil if @auth_work_communication_params[:cycle_id] set_cycle elsif @auth_work_communication_params[:instruction_id] set_instruction else not_found("please provide a cycle id or an instruction id") end not_found("instruction not found") unless @auth_work_instruction ## if the communication id is found, otherwise instantiate a new communication from the params. if params[:id] begin @auth_work_communication = @auth_work_communication_class.find(params[:id]) rescue Mongoid::Errors::DocumentNotFound @auth_work_communication = @auth_work_communication_class.new(@auth_work_communication_params) end else @auth_work_communication = @auth_work_communication_class.new(@auth_work_communication_params) end end |
#new ⇒ Object
92 93 94 |
# File 'app/controllers/auth/concerns/work/communication_controller_concern.rb', line 92 def new end |
#permitted_params ⇒ Object
116 117 118 |
# File 'app/controllers/auth/concerns/work/communication_controller_concern.rb', line 116 def permitted_params pr = params.permit({:communication => [:send_email,:email_template_path,:method_to_determine_recipients,:repeat,:repeat_times,:method_to_determine_communication_timing,:enqueue_at_time,:instruction_id,:cycle_id,:cart_item_id, :product_id, :name, :description]}, :id) end |
#set_cycle ⇒ Object
37 38 39 |
# File 'app/controllers/auth/concerns/work/communication_controller_concern.rb', line 37 def set_cycle end |
#set_instruction ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/auth/concerns/work/communication_controller_concern.rb', line 5 def set_instruction if product_id = @auth_work_communication_params[:product_id] if instruction_id = @auth_work_communication_params[:instruction_id] if @auth_shopping_product = Auth.configuration.product_class.constantize.find(product_id) @auth_work_instruction = nil @instruction_index = 0 @auth_shopping_product.instructions.each do |inst| if inst.id.to_s == instruction_id @auth_work_instruction = inst break end @instruction_index+=1 end end end elsif cart_item_id = @auth_work_communication_params[:cart_item_id] if instruction_id = @auth_work_communication_params[:instruction_id] if @auth_shopping_cart_item = Auth.configuration.cart_item_class.constantize.find(cart_item_id) @auth_work_instruction = nil @instruction_index = 0 @auth_shopping_cart_item.instructions.each do |inst| if inst.id.to_s == instruction_id @auth_work_instruction = inst break end @instruction_index+=1 end end end end end |
#show ⇒ Object
108 109 110 |
# File 'app/controllers/auth/concerns/work/communication_controller_concern.rb', line 108 def show end |
#update ⇒ Object
104 105 106 |
# File 'app/controllers/auth/concerns/work/communication_controller_concern.rb', line 104 def update ## now this still needs to be coded but will come to that later. end |