To accept the event and build confirmation for the event with accept
# File app/controllers/events_controller.rb, line 82 def accept @confirmation = @event.confirmations.build(user: current_user) @confirmation.accept if @confirmation.save EventMailer.delay(queue: :mailer).notify_owner_for_event_acceptance(@event.id, current_user.id, 'accepted') end respond_to do |format| format.js {render 'confirmation'} end end
Method to create event and send invitation of event to the selected group member.
# File app/controllers/events_controller.rb, line 48 def create @event = current_user.owned_events.build(event_params) if !event_params["user_emails"].blank? users = User.where(email: event_params["user_emails"].split(',')) invitee_emails = event_params["user_emails"].split(',') - users.map(&:email) users.each do |user| @event.shares.build(user_id: current_user.id, shared_to: user) end end if @event.save Invite.invite_users(invitee_emails, @event) if invitee_emails.present? respond_to do |format| format.js {render 'save'} end end end
Destroy the event.
# File app/controllers/events_controller.rb, line 74 def destroy @event.destroy respond_to do |format| format.js {render 'remove'} end end
Opens the edit form without rendering layout.
# File app/controllers/events_controller.rb, line 12 def edit render layout: false end
Retrieves all event.
# File app/controllers/events_controller.rb, line 7 def index @events = Event.all end
Method to intialize object for event and tutoring session.
# File app/controllers/events_controller.rb, line 35 def new @event = Event.new(start_time: params[:start_time], end_time: params[:end_time]) @tutoring_session = TutoringSession.new(start_time: params[:start_time], end_time: params[:end_time], date: params[:start_time].to_date) if params[:user_id] @tutor = User.find(params[:user_id]) if @tutor.tutor? @tutoring_session.tutor = @tutor end end render layout: false end
To reject the event and build confirmation for the event with reject
# File app/controllers/events_controller.rb, line 94 def reject @confirmation = @event.confirmations.build(user: current_user) @confirmation.reject if @confirmation.save EventMailer.delay(queue: :mailer).notify_owner_for_event_acceptance(@event.id, current_user.id, 'rejected') end respond_to do |format| format.js {render 'confirmation'} end end
Displays the event information.
# File app/controllers/events_controller.rb, line 66 def show if @event && @event.grouped? @group = @event.shares.last.shared_to end render layout: false end
Update the event.
# File app/controllers/events_controller.rb, line 17 def update if @event.update_attributes(event_params) if !event_params["user_emails"].blank? @event.share_with!(event_params["user_emails"].split(',')) end respond_to do |format| format.js {render 'save'} format.json {render json: {}} end else respond_to do |format| format.js {render 'save'} format.json {render json: {error: @event.errors.full_messages}, status: 403} end end end