summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorLuke Shumaker <shumakl@purdue.edu>2014-04-23 20:46:17 -0400
committerLuke Shumaker <shumakl@purdue.edu>2014-04-23 20:46:17 -0400
commit9003a9099719a771fbbb9d2e8a4bfb093f35929a (patch)
tree83c11934584978d84bf4c5ced57f9fc883e91b60 /app/controllers
parent66f225b6aef0946a79abee5e67f74afbf8ea9d1e (diff)
parent9afd5a4f7a86eeaab3fa8a0c25609ac7977e0489 (diff)
Merge branch 'master' of https://github.com/LukeShu/leaguer
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/pms_controller.rb6
-rw-r--r--app/controllers/search_controller.rb19
-rw-r--r--app/controllers/users_controller.rb17
3 files changed, 38 insertions, 4 deletions
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.' }
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
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index c3261b8..cfa5d67 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
@@ -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