diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb
index 0db9b77..9da4c86 100644
--- a/app/controllers/static_pages_controller.rb
+++ b/app/controllers/static_pages_controller.rb
@@ -98,4 +98,31 @@ class StaticPagesController < ApplicationController
end
end
end
+
+ def weigh_in
+ if !user_signed_in?
+ redirect_to root_path
+ end
+ if params[:wrestler]
+ Wrestler.update(params[:wrestler].keys, params[:wrestler].values)
+ end
+ if params[:tournament]
+ @tournament = Tournament.find(params[:tournament])
+ @tournament_id = @tournament.id
+ @tournament_name = @tournament.name
+ end
+ if @tournament
+ @weights = Weight.where(tournament_id: @tournament.id)
+ @weights = @weights.sort_by{|x|[x.max]}
+ end
+ if params[:weight]
+ @weight = Weight.find(params[:weight])
+ @tournament_id = @weight.tournament_id
+ @tournament_name = Tournament.find(@tournament_id).name
+ end
+ if @weight
+ @wrestlers = @weight.wrestlers
+
+ end
+ end
end
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index 5830ad1..364e121 100644
--- a/app/controllers/tournaments_controller.rb
+++ b/app/controllers/tournaments_controller.rb
@@ -83,6 +83,6 @@ class TournamentsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def tournament_params
- params.require(:tournament).permit(:name, :address, :director, :director_email, :tournament_type)
+ params.require(:tournament).permit(:name, :address, :director, :director_email, :tournament_type, :weigh_in_ref)
end
end
diff --git a/app/controllers/wrestlers_controller.rb b/app/controllers/wrestlers_controller.rb
index 26188a2..be87ce9 100644
--- a/app/controllers/wrestlers_controller.rb
+++ b/app/controllers/wrestlers_controller.rb
@@ -102,6 +102,6 @@ class WrestlersController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def wrestler_params
- params.require(:wrestler).permit(:name, :school_id, :weight_id, :seed, :original_seed, :season_win, :season_loss,:criteria,:extra)
+ params.require(:wrestler).permit(:name, :school_id, :weight_id, :seed, :original_seed, :season_win, :season_loss,:criteria,:extra,:offical_weight)
end
end
diff --git a/app/views/static_pages/weigh_in.html.erb b/app/views/static_pages/weigh_in.html.erb
new file mode 100644
index 0000000..0d89037
--- /dev/null
+++ b/app/views/static_pages/weigh_in.html.erb
@@ -0,0 +1,63 @@
+<%= link_to "Back to #{@tournament_name}", "/tournaments/#{@tournament_id}", :class=>"btn btn-default" %>
+
+
+<% if @tournament %>
+ <% @weights.each do |weight| %>
+ <%= link_to "#{weight.max}" , "/static_pages/weigh_in?weight=#{weight.id}" %>
+
+ <% end %>
+
+ <% if user_signed_in? %>
+ <%= form_for(@tournament) do |f| %>
+
| Name | +School | +Seed | +Weight Class | +Offical Weight | +
|---|---|---|---|---|
| <%= wrestler.name %> | +<%= School.find(wrestler.school_id).name %> | +<%= wrestler.weight.max %> | +<%= wrestler.original_seed %> | ++ <% if user_signed_in? %> + <%= fields_for "wrestler[]", wrestler do |w| %> + <%= w.number_field :offical_weight, :step => 'any' %> + <% end %> + <% else %> + <%= wrestler.offical_weight %> + <% end %> + | +