From 0a2f0fb40fc7342351e8bc66f3c67b84b1bb543b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 23 Apr 2014 20:23:35 -0400 Subject: remove test code --- app/controllers/static_controller.rb | 3 --- 1 file changed, 3 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb index 038cc19..6fc9490 100644 --- a/app/controllers/static_controller.rb +++ b/app/controllers/static_controller.rb @@ -1,7 +1,4 @@ class StaticController < ApplicationController def homepage end - - def test - end end -- cgit v1.2.3-2-g168b From 8d99b715f7027848e76556de75ad22fa14ff522a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 23 Apr 2014 20:38:44 -0400 Subject: simplify a line in tournaments_controller --- app/controllers/tournaments_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index b276368..0390051 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -33,7 +33,7 @@ class TournamentsController < ApplicationController def new @games = Game.all if params[:tournament] - @tournament = Tournament.new(game: Game.find(params[:tournament][:game_id])) + @tournament = Tournament.new(tournament_params) else @tournament = Tournament.new() end -- cgit v1.2.3-2-g168b From 933199499f9adfa0347783c538a10b88ffb1b98b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 23 Apr 2014 20:56:43 -0400 Subject: run ./generate.sh --- app/controllers/static_controller.rb | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 app/controllers/static_controller.rb (limited to 'app/controllers') diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb deleted file mode 100644 index c6df11e..0000000 --- a/app/controllers/static_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class StaticController < ApplicationController -end -- cgit v1.2.3-2-g168b From cfa41fcc58acc9ae50b84eb51e3d9fa9ecb3b79e Mon Sep 17 00:00:00 2001 From: DavisLWebb Date: Wed, 23 Apr 2014 21:45:40 -0400 Subject: run ./generate.sh --- app/controllers/games_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index db610bc..8546efb 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -69,6 +69,6 @@ class GamesController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def game_params - params.require(:game).permit(:name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method) + params.require(:game).permit(:parent_id, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method) end end -- cgit v1.2.3-2-g168b From 47be7c86ca5193ffe4331fbb9358a9171abe748b Mon Sep 17 00:00:00 2001 From: DavisLWebb Date: Wed, 23 Apr 2014 22:28:27 -0400 Subject: Luke made the remote_username stuff work --- app/controllers/users_controller.rb | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index cfa5d67..4c36148 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -56,8 +56,25 @@ class UsersController < ApplicationController # PATCH/PUT /users/1 # PATCH/PUT /users/1.json def update + ok = true + if params[:user][:remote_usernames].nil? + ok &= @user.update(user_params) + else + params[:user][:remote_usernames].each do |game_name,user_name| + game = Game.find_by_name(game_name) + remote_username = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/by-name/#{user_name}?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") + + remote = @user.remote_usernames.where(:game => game).first + if remote.nil? + ok &= @user.remote_usernames.create(game: game, value: remote_username) + else + remote.value = remote_username + ok &= remote.save + end + end + end respond_to do |format| - if @user.update(user_params) + if ok format.html { redirect_to @user, notice: 'User was successfully updated.' } format.json { head :no_content } else @@ -77,19 +94,6 @@ class UsersController < ApplicationController end end - def set_remote - game = Game.find_by_name("League of Legends") - - remote_username = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/by-name/#{@name.downcase}?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") - - remote = @user.find_remote_username(game) - if remote.nil? - @user.remote_username.create(game: game, value: remote_username) - else - remote.value = remote_username - remote.save - end - end private # Use callbacks to share common setup or constraints between actions. -- cgit v1.2.3-2-g168b From 19b04a49d01af1917385c166501ef086eddae437 Mon Sep 17 00:00:00 2001 From: guntasgrewal Date: Wed, 23 Apr 2014 22:50:29 -0400 Subject: The users with permissions to send alerts can now create new alerts. --- app/controllers/alerts_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/alerts_controller.rb b/app/controllers/alerts_controller.rb index 333022a..6ab3663 100644 --- a/app/controllers/alerts_controller.rb +++ b/app/controllers/alerts_controller.rb @@ -23,7 +23,7 @@ class AlertsController < ApplicationController # POST /alerts.json def create @alert = Alert.new(alert_params) - + @alert.author = current_user respond_to do |format| if @alert.save format.html { redirect_to @alert, notice: 'Alert was successfully created.' } -- cgit v1.2.3-2-g168b