diff --git a/app/controllers/wrestlers_controller.rb b/app/controllers/wrestlers_controller.rb
index afc2f09..5f3e1f4 100644
--- a/app/controllers/wrestlers_controller.rb
+++ b/app/controllers/wrestlers_controller.rb
@@ -1,8 +1,17 @@
class WrestlersController < ApplicationController
- before_action :set_wrestler, only: [:show, :edit, :update, :destroy]
+ before_action :set_wrestler, only: [:show, :edit, :update, :destroy, :swap]
before_filter :check_access, only: [:new,:create,:update,:destroy,:edit]
+ def swap
+ respond_to do |format|
+ if @wrestler.tournament.swapWrestlers(@wrestler.id, params[:wrestler][:swapId])
+ format.html { redirect_to @wrestler, notice: 'Wrestler was successfully swaped.' }
+ format.json { render action: 'show', status: :created, location: @wrestler }
+ end
+ end
+ end
+
# GET /wrestlers/1
# GET /wrestlers/1.json
def show
diff --git a/app/models/wrestler.rb b/app/models/wrestler.rb
index 0b91ce7..f4aa04b 100644
--- a/app/models/wrestler.rb
+++ b/app/models/wrestler.rb
@@ -4,7 +4,7 @@ class Wrestler < ActiveRecord::Base
has_one :tournament, through: :weight
has_many :matches, through: :weight
has_many :deductedPoints, class_name: "Teampointadjust"
- attr_accessor :poolNumber, :poolAdvancePoints
+ attr_accessor :poolNumber, :poolAdvancePoints, :swapId
validates :name, :weight_id, :school_id, presence: true
diff --git a/app/views/wrestlers/_form.html.erb b/app/views/wrestlers/_form.html.erb
index fa083e4..d166388 100644
--- a/app/views/wrestlers/_form.html.erb
+++ b/app/views/wrestlers/_form.html.erb
@@ -53,4 +53,19 @@
<% end %>
+<% if can? :manage, @wrestler.tournament %>
+
+