From e632f48600ae23b5f742773310b2a4ac16ae4ee8 Mon Sep 17 00:00:00 2001 From: Steven Miers Date: Mon, 29 Jun 2015 13:11:57 -0500 Subject: [PATCH] VRFS-3276 : Routes and controller implementation of user calendar ICS feed, which uses calendar manager. --- web/app/controllers/api_users_controller.rb | 26 +++++++++++++++------ web/config/routes.rb | 2 +- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/web/app/controllers/api_users_controller.rb b/web/app/controllers/api_users_controller.rb index ebe68290a..0cc78d470 100644 --- a/web/app/controllers/api_users_controller.rb +++ b/web/app/controllers/api_users_controller.rb @@ -1,7 +1,7 @@ require 'sanitize' class ApiUsersController < ApiController - before_filter :api_signed_in_user, :except => [:create, :show, :signup_confirm, :auth_session_create, :complete, :finalize_update_email, :isp_scoring, :add_play, :crash_dump, :validate_data] + before_filter :api_signed_in_user, :except => [:create, :calendar, :show, :signup_confirm, :auth_session_create, :complete, :finalize_update_email, :isp_scoring, :add_play, :crash_dump, :validate_data] before_filter :auth_user, :only => [:session_settings_show, :session_history_index, :session_user_history_index, :update, :delete, :liking_create, :liking_destroy, # likes :following_create, :following_show, :following_destroy, # followings @@ -15,19 +15,23 @@ class ApiUsersController < ApiController :share_session, :share_recording, :affiliate_report, :audio_latency, :broadcast_notification] - respond_to :json + respond_to :json, :except => :calendar + respond_to :ics, :only => :calendar def index @users = User.paginate(page: params[:page]) respond_with @users, responder: ApiResponder, :status => 200 end + def calendar + @user=lookup_user + ics = CalendarManager.new.create_ics_feed(@user) + puts "ICS: #{ics}" + send_data ics, :filename => 'JamKazam', :disposition => 'inline', :type => "text/calendar" + end + def show - @user = User.includes([{musician_instruments: :instrument}, - {band_musicians: :user}, - {genre_players: :genre}, - :bands, :instruments, :genres, :jam_track_rights, :affiliate_partner]) - .find(params[:id]) + @user=lookup_user respond_with @user, responder: ApiResponder, :status => 200 end @@ -880,6 +884,14 @@ class ApiUsersController < ApiController render json: { }, status: 200 end + def lookup_user + User.includes([{musician_instruments: :instrument}, + {band_musicians: :user}, + {genre_players: :genre}, + :bands, :instruments, :genres, :jam_track_rights, :affiliate_partner]) + .find(params[:id]) + end + ###################### RECORDINGS ####################### # def recording_index # @recordings = User.recording_index(current_user, params[:id]) diff --git a/web/config/routes.rb b/web/config/routes.rb index 43ee05098..924abf233 100644 --- a/web/config/routes.rb +++ b/web/config/routes.rb @@ -271,9 +271,9 @@ SampleApp::Application.routes.draw do #match '/users' => 'api_users#create', :via => :post match '/users/:id' => 'api_users#update', :via => :post match '/users/:id' => 'api_users#delete', :via => :delete + match '/users/:id/calendar.ics' => 'api_users#calendar', :via => :get, :as => 'api_users_calendar_feed' match '/users/confirm/:signup_token' => 'api_users#signup_confirm', :via => :post, :as => 'api_signup_confirmation' match '/users/complete/:signup_token' => 'api_users#complete', as: 'complete', via: 'post' - match '/users/:id/set_password' => 'api_users#set_password', :via => :post # recurly