1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Added spot to control a match

This commit is contained in:
2015-11-05 09:05:44 -05:00
parent 5173f8209a
commit 5b497e9cf9
4 changed files with 54 additions and 6 deletions

View File

@@ -1,10 +1,14 @@
class MatsController < ApplicationController
before_action :set_mat, only: [:show, :edit, :update, :destroy]
before_filter :check_access, only: [:new,:create,:update,:destroy,:edit]
before_filter :check_access, only: [:new,:create,:update,:destroy,:edit,:show]
# GET /mats/1
# GET /mats/1.json
def show
@match = @mat.unfinishedMatches.first
@w1 = @match.wrestler1
@w2 = @match.wrestler2
@wrestlers = [@w1,@w2]
end
# GET /mats/new

View File

@@ -0,0 +1,37 @@
<%= form_for(@match) do |f| %>
<% if @match.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@match.errors.count, "error") %> prohibited this match from being saved:</h2>
<ul>
<% @match.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<h4>Bout <%= @match.bout_number %> <%= @w1.name %> VS. <%= @w2.name %></h4>
<br>
<div class="field">
<%= f.label "Win Type" %><br>
<%= f.select(:win_type, Match::WIN_TYPES) %>
</div>
<div class="field">
<%= f.label "Winner" %> Please put in the id of the winner<br>
<%= f.collection_select :winner_id, @wrestlers, :id, :name %>
</div>
<div class="field">
<%= f.label "Score" %> Also put pin time here if applicable. If default or forfeit, leave blank<br>
<%= f.text_field :score %>
</div>
<%= f.hidden_field :finished, :value => 1 %>
<%= f.hidden_field :round, :value => @match.round %>
<br>
<div class="actions">
<%= f.submit data: { confirm: "Did you confirm the winner before submitting? If not, please hit cancel."}, :class=>"btn btn-success" %>
</div>
<% end %>

View File

@@ -1,13 +1,19 @@
<p id="notice"><%= notice %></p>
<%= link_to "Back to #{@mat.tournament.name}", "/tournaments/#{@mat.tournament.id}", :class=>"btn btn-default" %>
<br>
<br>
<p>
<strong>Name:</strong>
<%= @mat.name %>
<strong>Mat <%= @mat.name %></strong>
</p>
<p>
<strong>Tournament:</strong>
<%= @mat.tournament_id %>
<%= @mat.tournament.name %>
</p>
<%= link_to 'Edit', edit_mat_path(@mat) %> |
<br>
<br>
<%= render 'match_edit_form' %>

View File

@@ -128,7 +128,8 @@
<td><%= mat.name %></td>
<td>
<% if tournament_permissions(@tournament) %>
<%= link_to 'Destroy', mat, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger" %>
<%= link_to 'Show', mat, :class=>"btn btn-default" %>
<%= link_to 'Destroy', mat, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger" %>
<% end %>
</td>
</tr>