summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/alerts_controller.rb7
-rw-r--r--app/controllers/tournaments_controller.rb8
-rw-r--r--app/controllers/users_controller.rb15
-rw-r--r--app/models/tournament.rb25
-rw-r--r--app/models/tournament_stage.rb23
-rw-r--r--app/views/tournaments/_selected.html.erb38
-rw-r--r--app/views/tournaments/_stages.html.erb36
-rw-r--r--app/views/tournaments/new.html.erb6
8 files changed, 85 insertions, 73 deletions
diff --git a/app/controllers/alerts_controller.rb b/app/controllers/alerts_controller.rb
index 1d09864..77ca8b9 100644
--- a/app/controllers/alerts_controller.rb
+++ b/app/controllers/alerts_controller.rb
@@ -25,9 +25,12 @@ class AlertsController < ApplicationController
@alert = Alert.new(alert_params)
@alert.author = current_user
users = {}
- users = Users.all
+ users = User.all
- #current_user.send_message(users, @alert.message, "Pay Attention!")
+
+ for i in 0..users.length
+ current_user.send_message(users[i], @alert.message, "Pay Attention!")
+ end
respond_to do |format|
if @alert.save
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index 60f8789..734253a 100644
--- a/app/controllers/tournaments_controller.rb
+++ b/app/controllers/tournaments_controller.rb
@@ -67,6 +67,14 @@ class TournamentsController < ApplicationController
end
end
+ def create_stage
+
+ # stage = @tournament.stages.new
+ # stage.create(TODO:PARAMETERS)
+ # @tournament.stages.push(stage)
+
+ end
+
# PATCH/PUT /tournaments/1
# PATCH/PUT /tournaments/1.json
def update
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 27b3c61..767d992 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -62,20 +62,7 @@ class UsersController < ApplicationController
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.downcase}?api_key=ad539f86-22fd-474d-9279-79a7a296ac38")
-
- id = "#{remote_username["#{user_name.downcase}"]["id"]}".to_i
- username = "#{remote_username["#{user_name.downcase}"]["name"]}"
-
- hash = {:username => username, :id => id}
-
- remote = @user.remote_usernames.where(:game => game).first
- if remote.nil?
- ok &= @user.remote_usernames.create(game: game, value: hash)
- else
- remote.value = hash
- ok &= remote.save
- end
+ Sampling::RiotApi::set_remote_name(@user, game, user_name)
end
end
respond_to do |format|
diff --git a/app/models/tournament.rb b/app/models/tournament.rb
index 61b4700..2d4d6b6 100644
--- a/app/models/tournament.rb
+++ b/app/models/tournament.rb
@@ -93,4 +93,29 @@ class Tournament < ActiveRecord::Base
def sampling
@sampling ||= "Sampling::#{self.sampling_method.camelcase}".constantize
end
+
+ # YISSSSSS
+ def self.make_methods(dir)
+ @methods ||= {}
+ if @methods[dir].nil? or Rails.env.development?
+ @methods[dir] = Dir.glob("#{Rails.root}/lib/#{dir}/*.rb").map{|filename| File.basename(filename, ".rb").humanize }
+ end
+ return @methods[dir]
+ end
+
+ def self.scoring_methods
+ make_methods "scoring"
+ end
+
+ def self.sampling_methods
+ make_methods "sampling"
+ end
+
+ def self.scheduling_methods
+ make_methods "scheduling"
+ end
+
+ def self.seeding_methods
+ make_methods "seeding"
+ end
end
diff --git a/app/models/tournament_stage.rb b/app/models/tournament_stage.rb
index 84519b9..9352137 100644
--- a/app/models/tournament_stage.rb
+++ b/app/models/tournament_stage.rb
@@ -25,29 +25,6 @@ class TournamentStage < ActiveRecord::Base
return seeding.seed.pair(matches, players)
end
- def make_methods(dir)
- if @methods[dir].nil? or Rails.env.development?
- @methods[dir] = Dir.glob("#{Rails.root}/lib/#{dir}/*.rb").map{|filename| filename.sub(/.*\/(.*)\.rb/, /\1/)}
- end
- return @methods[dir]
- end
-
- def scoring_methods
- make_methods "scoring"
- end
-
- def sampling_methods
- make_methods "sampling"
- end
-
- def scheduling_methods
- make_methods "scheduling"
- end
-
- def seeding_methods
- make_methods "seeding"
- end
-
# Accessors to the configured methods
def scoring
diff --git a/app/views/tournaments/_selected.html.erb b/app/views/tournaments/_selected.html.erb
index 9240c49..e89550e 100644
--- a/app/views/tournaments/_selected.html.erb
+++ b/app/views/tournaments/_selected.html.erb
@@ -3,51 +3,21 @@
<%= f.hidden_field(:game_id) %>
<% @tournament.attributes.each do |name, value| %>
- <% if (name == "id") or (name =~ /.*_at$/) or (name == "game_id") or (name == "status") or (name == "set_rounds") %>
+ <% if (name == "randomized_teams") or(name == "max_teams_per_match") or (name == "max_players_per_team") or (name == "id") or (name =~ /.*_at$/) or (name == "game_id") or (name == "status") or (name == "set_rounds") %>
<% next %>
<% end %>
<p>
<%= f.label name %><br>
<% unless @tournament.game.attributes[name].nil? %>
<% if name == "sampling_method" %>
- <%= f.select( name, @tournament.game.sampling_method.split(',') ) %>
+ <%= f.select( name, Tournament.sampling_methods) %>
<% else %>
- <%= f.text_field(name, :value => @tournament.game.attributes[name] ) %>
+ <%= f.text_field(name, :value => @tournament.game.attributes[name] ) %>
<% end %>
<% else %>
- <%= f.text_field name %>
+ <%= f.select( name, Tournament.scoring_methods) %>
<% end %>
</p>
<% end %>
-
- <%= fields_for "tournament[settings]", @tournament.settings do |setting_fields| %>
- <% @tournament.game.settings.each do |setting| %>
- <p>
- <%= setting_fields.label setting.name %>
- <br>
- <% case setting.vartype %>
- <% when 0 %>
- <%= setting_fields.text_field( setting.name ) %>
- <% when 1 %>
- <%= setting_fields.text_area( setting.name ) %>
- <% when 2 %>
- <% setting.type_opt.split(',').each do |option|%>
- <%= setting_fields.radio_button( setting.name, option ) %> <%= option %> <br>
- <% end %>
- <% when 3 %>
- <% setting.type_opt.split(',').each do |option|%>
- <%= check_box_tag(setting.name, value = option, checked = false, options = {}) %> <%= option %> <br>
- <% end %>
- <% when 4 %>
- <%# setting_fields.label "true" %>
- <%= setting_fields.radio_button( setting.name, "true" ) %> True
- <%# setting_fields.label "false" %>
- <%= setting_fields.radio_button( setting.name, "false" ) %> False
- <% when 5 %>
- <%= setting_fields.select( setting.name, setting.type_opt.split(',') ) %>
- <% end %>
- <% end %>
- </p>
- <% end %>
<%= f.submit %>
<% end %>
diff --git a/app/views/tournaments/_stages.html.erb b/app/views/tournaments/_stages.html.erb
new file mode 100644
index 0000000..20c7b3f
--- /dev/null
+++ b/app/views/tournaments/_stages.html.erb
@@ -0,0 +1,36 @@
+ <%= form_for(@tournament) do |f| %>
+ <%= render "common/error_messages", :target => @tournament %>
+ <%= f.hidden_field(:game_id) %>
+ <%= fields_for "tournament[settings]", @tournament.settings do |setting_fields| %>
+
+ <% @tournament.game.settings.each do |setting| %>
+ <p>
+ <%= setting_fields.label setting.name %>
+ <br>
+ <% case setting.vartype %>
+ <% when 0 %>
+ <%= setting_fields.text_field( setting.name ) %>
+ <% when 1 %>
+ <%= setting_fields.text_area( setting.name ) %>
+ <% when 2 %>
+ <% setting.type_opt.split(',').each do |option|%>
+ <%= setting_fields.radio_button( setting.name, option ) %> <%= option %> <br>
+ <% end %>
+ <% when 3 %>
+ <% setting.type_opt.split(',').each do |option|%>
+ <%= check_box_tag(setting.name, value = option, checked = false, options = {}) %> <%= option %> <br>
+ <% end %>
+ <% when 4 %>
+ <%# setting_fields.label "true" %>
+ <%= setting_fields.radio_button( setting.name, "true" ) %> True
+ <%# setting_fields.label "false" %>
+ <%= setting_fields.radio_button( setting.name, "false" ) %> False
+ <% when 5 %>
+ <%= setting_fields.select( setting.name, setting.type_opt.split(',') ) %>
+ <% end %>
+ <% end %>
+ </p>
+ <% end %>
+
+ <%= f.submit %>
+<% end %>
diff --git a/app/views/tournaments/new.html.erb b/app/views/tournaments/new.html.erb
index 2837708..af74ea8 100644
--- a/app/views/tournaments/new.html.erb
+++ b/app/views/tournaments/new.html.erb
@@ -13,4 +13,10 @@
<% end %>
</div>
+<div id='ajax-form'>
+ <% if not @tournament.game.nil? %>
+ <%= render 'stages' %>
+ <% end %>
+</div>
+
<%= link_to 'Back', tournaments_path %>