From c5e0aeb5a055797fe4f26fb9e6f9e163d5d7f718 Mon Sep 17 00:00:00 2001 From: DavisLWebb Date: Wed, 23 Apr 2014 20:21:54 -0400 Subject: Updated remote_usernames --- app/controllers/users_controller.rb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c3261b8..68c0743 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,5 +1,8 @@ class UsersController < ApplicationController + require 'httparty' + require 'json' + # GET /users # GET /users.json @@ -36,7 +39,7 @@ class UsersController < ApplicationController respond_to do |format| if @user.save sign_in @user - if @user.id == 1 + if @user.id == daft punk1 # This is the first user, so give them all the power @user.permissions = 0xFFFFFFFF @user.save @@ -74,6 +77,20 @@ 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. def set_user -- cgit v1.2.3-2-g168b From cba4c47e7cca06434742fc5fd282c40973c546d1 Mon Sep 17 00:00:00 2001 From: tkimia Date: Wed, 23 Apr 2014 20:26:37 -0400 Subject: started with advanced search --- app/controllers/search_controller.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 51aee9e..d312623 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,13 +1,28 @@ class SearchController < ApplicationController def go + stringMade = false; + @games = Game.all @query = params[:query] + @gametype = params[:game_type] - if (@query.nil?) then + if ( @gametype.nil? and (@query.nil? or @query.empty?)) then return end - @tournaments = Tournament.where("name LIKE '%#{@query}%'") + qstring = "" + if (!@query.empty?) + qstring += "name LIKE '%#{@query}%'" + stringMade = true + end + if (!@gametype.nil? and !@gametype.empty?) + if (stringMade) + qstring += " AND " + end + qstring += "game_id=#{@gametype}" + end + + @tournaments = Tournament.where(qstring) @players = User.where("name LIKE '%#{@query}%'") end -- cgit v1.2.3-2-g168b From a729106e956e051818bb2d37f1581f3bf3abcefd Mon Sep 17 00:00:00 2001 From: DavisLWebb Date: Wed, 23 Apr 2014 20:32:58 -0400 Subject: Fixed several user controller errors --- app/controllers/users_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 68c0743..cfa5d67 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -39,7 +39,7 @@ class UsersController < ApplicationController respond_to do |format| if @user.save sign_in @user - if @user.id == daft punk1 + if @user.id == 1 # This is the first user, so give them all the power @user.permissions = 0xFFFFFFFF @user.save -- cgit v1.2.3-2-g168b From 422a7b39a06e2fe54415f2be08548021a981e8a8 Mon Sep 17 00:00:00 2001 From: nfoy Date: Wed, 23 Apr 2014 20:40:56 -0400 Subject: Beginnings of actual messageboxer api --- app/controllers/pms_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/pms_controller.rb b/app/controllers/pms_controller.rb index 1279fdf..2cb55f8 100644 --- a/app/controllers/pms_controller.rb +++ b/app/controllers/pms_controller.rb @@ -24,10 +24,12 @@ class PmsController < ApplicationController def create @pm = Pm.new(pm_params) @pm.author = current_user - require 'pp' - pp pm_params['recipient_id'] + #require 'pp' + #pp pm_params['recipient_id'] @pm.recipient = User.find_by_user_name(pm_params['recipient_id']) + @pm.author.send_message(@pm.recipient, @pm.message, 'Default') + respond_to do |format| if @pm.save format.html { redirect_to @pm, notice: 'Pm was successfully created.' } -- cgit v1.2.3-2-g168b