mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-30 11:04:56 +00:00
Added shell views and routes to swap wrestlers bracket positions
Still need to set permssions on swap controller method
This commit is contained in:
@@ -1,8 +1,17 @@
|
|||||||
class WrestlersController < ApplicationController
|
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]
|
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
|
||||||
# GET /wrestlers/1.json
|
# GET /wrestlers/1.json
|
||||||
def show
|
def show
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class Wrestler < ActiveRecord::Base
|
|||||||
has_one :tournament, through: :weight
|
has_one :tournament, through: :weight
|
||||||
has_many :matches, through: :weight
|
has_many :matches, through: :weight
|
||||||
has_many :deductedPoints, class_name: "Teampointadjust"
|
has_many :deductedPoints, class_name: "Teampointadjust"
|
||||||
attr_accessor :poolNumber, :poolAdvancePoints
|
attr_accessor :poolNumber, :poolAdvancePoints, :swapId
|
||||||
|
|
||||||
validates :name, :weight_id, :school_id, presence: true
|
validates :name, :weight_id, :school_id, presence: true
|
||||||
|
|
||||||
|
|||||||
@@ -53,4 +53,19 @@
|
|||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% if can? :manage, @wrestler.tournament %>
|
||||||
|
<br><br>
|
||||||
|
<h3>Swap Bracket Position</h3>
|
||||||
|
<%= form_for @wrestler, :url => url_for(:controller => 'wrestlers', :action => 'swap', :method => "post") do |f| %>
|
||||||
|
|
||||||
|
<div class="field">
|
||||||
|
<%= f.label 'Swap With' %><br>
|
||||||
|
<%= f.collection_select :swapId, @wrestler.weight.wrestlers, :id, :name %>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<%= submit_tag "Swap", :class=>"btn btn-success"%>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Wrestling::Application.routes.draw do
|
|||||||
|
|
||||||
post "/weights/:id" => "weights#show"
|
post "/weights/:id" => "weights#show"
|
||||||
|
|
||||||
|
patch "/wrestlers/:id/swap" => "wrestlers#swap"
|
||||||
|
|
||||||
# The priority is based upon order of creation: first created -> highest priority.
|
# The priority is based upon order of creation: first created -> highest priority.
|
||||||
# See how all your routes lay out with "rake routes".
|
# See how all your routes lay out with "rake routes".
|
||||||
|
|||||||
Reference in New Issue
Block a user