1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-02 04:35:26 +00:00

Added logic to delegate tournament access

This commit is contained in:
2016-01-06 18:38:02 +00:00
parent eb9037b078
commit f46029efaf
46 changed files with 417 additions and 121 deletions

View File

@@ -1,6 +0,0 @@
<%= link_to "Go to Schools", '/schools/' %>
<br>
<%= link_to "Go to Weights", '/weights/' %>
<br>
<%= link_to "Go to Wrestlers", '/wrestlers/' %>
<br>

View File

@@ -12,7 +12,7 @@
<li><%= link_to "Team Scores" , "/tournaments/#{@tournament.id}/team_scores" %></li>
</ul>
</div>
<% if tournament_permissions(@tournament) %>
<% if can? :manage, @tournament %>
<br><br>
<div class="" style="padding-right: 1%;">
<h4>Tournament Director Links</h4>

View File

@@ -1,7 +1,7 @@
<p id="notice"><%= notice %></p>
<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}",:class=>"btn btn-default" %>
<% if tournament_permissions(@school.tournament) %>
<% if can? :manage, @tournament %>
| <%= link_to "Edit #{@school.name}", edit_school_path(@school),:class=>"btn btn-primary" %>
<% end %>
@@ -19,7 +19,7 @@
<p>
<strong>Tournament:</strong>
<%= Tournament.find(@school.tournament_id).name %>
<%= @school.tournament.name %>
</p>
@@ -27,13 +27,13 @@
<br>
<% if tournament_permissions(@school.tournament) %>
<% if can? :manage, @tournament %>
<%= link_to "New #{@school.name} Wrestler" , "/wrestlers/new?school=#{@school.id}", :class=>"btn btn-success"%>
<% end %>
<br>
<br>
<% cache ["schools", @school] do %>
<table class="table table-striped table-bordered">
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>Name</th>
@@ -53,7 +53,7 @@
<% if wrestler.school_id == @school.id %>
<tr>
<td><%= wrestler.name %></td>
<td><%= Weight.find(wrestler.weight_id).max %></td>
<td><%= wrestler.weight.max %></td>
<td>
<%= wrestler.original_seed %>
</td>
@@ -65,10 +65,10 @@
<% end %></td>
<td><%= wrestler.nextMatchBoutNumber %> <%= wrestler.nextMatchMatName %></td>
<td>
<%= link_to 'Show', wrestler , :class=>"btn btn-default" %>
<% if tournament_permissions(@school.tournament) %>
<%= link_to 'Edit', edit_wrestler_path(wrestler),:class=>"btn btn-primary" %>
<%= link_to 'Destroy', wrestler, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger" %>
<%= link_to 'Show', wrestler , :class=>"btn btn-default btn-sm" %>
<% if can? :manage, @tournament %>
<%= link_to 'Edit', edit_wrestler_path(wrestler),:class=>"btn btn-primary btn-sm" %>
<%= link_to 'Destroy', wrestler, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %>
<% end %>
</td>
</tr>

View File

@@ -10,7 +10,7 @@
<% end %>
</br>
</br>
<table class="table table-striped table-bordered" id="tournamentList">
<table class="table table-striped table-bordered table-condensed" id="tournamentList">
<thead>
<tr>
<th>Name</th>
@@ -24,10 +24,10 @@
<tr>
<td><%= tournament.name %></td>
<td><%= tournament.date %></td>
<td><%= link_to 'Show', tournament, :class=>"btn btn-default" %>
<% if tournament_permissions(tournament) %>
<%= link_to 'Edit', edit_tournament_path(tournament), :class=>"btn btn-primary" %>
<%= link_to 'Destroy', tournament, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger" %>
<td><%= link_to 'Show', tournament, :class=>"btn btn-default btn-sm" %>
<% if can? :manage, tournament %>
<%= link_to 'Edit', edit_tournament_path(tournament), :class=>"btn btn-primary btn-sm" %>
<%= link_to 'Destroy', tournament, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %>
<% end %>
</td>
</tr>

View File

@@ -2,7 +2,7 @@
<% @pool = 1 %>
<% until @wrestlers.select{|w| w.generatePoolNumber == @pool}.blank? %>
<h5>Pool <%= @pool %></h5>
<table class="table table-striped table-bordered">
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>Name</th>

View File

@@ -5,6 +5,6 @@
<%= link_to "#{weight.max}" , "/tournaments/#{@tournament.id}/brackets/#{weight.id}" %>
<br>
<% end %>
<% if tournament_permissions(@tournament) %>
<% if can? :manage, @tournament %>
<%= link_to "All Brackets (Printable)", "/tournaments/#{@tournament.id}/all_brackets?print=true" %>
<% end %>

View File

@@ -14,7 +14,7 @@
<% end %>
</br>
</br>
<table class="table table-striped table-bordered" id="tournamentList">
<table class="table table-striped table-bordered table-condensed" id="tournamentList">
<thead>
<tr>
<th>Name</th>
@@ -28,10 +28,10 @@
<tr>
<td><%= tournament.name %></td>
<td><%= tournament.date %></td>
<td><%= link_to 'Show', tournament, :class=>"btn btn-default" %>
<% if tournament_permissions(tournament) %>
<%= link_to 'Edit', edit_tournament_path(tournament), :class=>"btn btn-primary" %>
<%= link_to 'Destroy', tournament, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger" %>
<td><%= link_to 'Show', tournament, :class=>"btn btn-default btn-sm" %>
<% if can? :manage, tournament %>
<%= link_to 'Edit', edit_tournament_path(tournament), :class=>"btn btn-primary btn-sm" %>
<%= link_to 'Destroy', tournament, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %>
<% end %>
</td>
</tr>

View File

@@ -12,7 +12,7 @@
</script>
</br>
</br>
<table class="table table-striped table-bordered" id="matchesList">
<table class="table table-striped table-bordered table-condensed" id="matchesList">
<thead>
<tr>
<th>Bout number</th>
@@ -28,8 +28,8 @@
<td><%= match.bout_number %></td>
<td><%= match.w1_name %> vs <%= match.w2_name %></td>
<td><%= match.finished %></td>
<td><%= link_to 'Show', match, :class=>"btn btn-default" %>
<%= link_to 'Edit', edit_match_path(match), :class=>"btn btn-primary" %>
<td><%= link_to 'Show', match, :class=>"btn btn-default btn-sm" %>
<%= link_to 'Edit', edit_match_path(match), :class=>"btn btn-primary btn-sm" %>
</td>
</tr>
<% end %>

View File

@@ -1,6 +1,6 @@
<p id="notice"><%= notice %></p>
<%= link_to 'Back to browse tournaments', '/tournaments', :class=>"btn btn-default" %>
<% if tournament_permissions(@tournament) %>
<% if can? :manage, @tournament %>
| <%= link_to "Edit #{@tournament.name}", edit_tournament_path(@tournament), :class=>"btn btn-primary" %>
<% end %>
@@ -34,12 +34,12 @@
<br>
<h3>School Lineups</h3>
<br>
<% if tournament_permissions(@tournament) %>
<%= link_to "New #{@tournament.name} School" , "/schools/new?tournament=#{@tournament.id}", :class=>"btn btn-success" %>
<% if can? :manage, @tournament %>
<%= link_to "New #{@tournament.name} School" , "/schools/new?tournament=#{@tournament.id}", :class=>"btn btn-success btn-sm" %>
<br>
<br>
<% end %>
<table class="table table-striped table-bordered">
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>Name</th>
@@ -52,10 +52,10 @@
<% @schools.each do |school| %>
<tr>
<td><%= school.name %></td>
<td><%= link_to 'Show', school, :class=>"btn btn-default" %>
<% if tournament_permissions(@tournament) %>
<%= link_to 'Edit', edit_school_path(school), :class=>"btn btn-primary" %>
<%= link_to 'Destroy', school, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger" %>
<td><%= link_to 'Show', school, :class=>"btn btn-default btn-sm" %>
<% if can? :manage, @tournament %>
<%= link_to 'Edit', edit_school_path(school), :class=>"btn btn-primary btn-sm" %>
<%= link_to 'Destroy', school, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %>
<% end %>
</td>
</tr>
@@ -68,12 +68,12 @@
<h3>Weight Class Seeds</h3>
<br>
<% if tournament_permissions(@tournament) %>
<%= link_to "New #{@tournament.name} Weight" , "/weights/new?tournament=#{@tournament.id}", :class=>"btn btn-success" %>
<% if can? :manage, @tournament %>
<%= link_to "New #{@tournament.name} Weight" , "/weights/new?tournament=#{@tournament.id}", :class=>"btn btn-success btn-sm" %>
<br>
<br>
<% end %>
<table class="table table-striped table-bordered">
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>Weight Class</th>
@@ -87,10 +87,10 @@
<tr>
<td><%= weight.max %></td>
<td><%= weight.bracket_size %></td>
<td><%= link_to 'Show', weight, :class=>"btn btn-default" %>
<% if tournament_permissions(@tournament) %>
<%= link_to 'Edit', edit_weight_path(weight), :class=>"btn btn-primary" %>
<%= link_to 'Destroy', weight, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger" %>
<td><%= link_to 'Show', weight, :class=>"btn btn-default btn-sm" %>
<% if can? :manage, @tournament %>
<%= link_to 'Edit', edit_weight_path(weight), :class=>"btn btn-primary btn-sm" %>
<%= link_to 'Destroy', weight, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %>
<% end %>
</td>
</tr>
@@ -98,15 +98,15 @@
</tbody>
</table>
<% if tournament_permissions(@tournament) %>
<% if can? :manage, @tournament %>
<br>
<br>
<h3>Mats</h3>
<br>
<%= link_to "New #{@tournament.name} Mat" , "/mats/new?tournament=#{@tournament.id}", :class=>"btn btn-success" %>
<%= link_to "New #{@tournament.name} Mat" , "/mats/new?tournament=#{@tournament.id}", :class=>"btn btn-success btn-sm" %>
<br>
<br>
<table class="table table-striped table-bordered">
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>Name</th>
@@ -119,9 +119,9 @@
<tr>
<td><%= mat.name %></td>
<td>
<% if tournament_permissions(@tournament) %>
<%= link_to 'Show', mat, :class=>"btn btn-default" %>
<%= link_to 'Destroy', mat, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger" %>
<% if can? :manage, @tournament %>
<%= link_to 'Show', mat, :class=>"btn btn-default btn-sm" %>
<%= link_to 'Destroy', mat, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %>
<% end %>
</td>
</tr>

View File

@@ -6,7 +6,7 @@
<br>
<% end %>
<br>
<% if tournament_permissions(@tournament) %>
<% if can? :manage, @tournament %>
<%= form_for(@tournament) do |f| %>
<div class="field">
<%= f.label :weigh_in_ref %><br>

View File

@@ -19,7 +19,7 @@
<% if wrestler.weight_id == @weight.id %>
<tr>
<td><%= wrestler.name %></td>
<td><%= School.find(wrestler.school_id).name %></td>
<td><%= wrestler.school.name %></td>
<td><%= wrestler.original_seed %></td>
<td><%= wrestler.weight.max %></td>
<td>
@@ -37,7 +37,7 @@
</tbody>
</table>
<%= hidden_field_tag :tournament, @tournament_id %>
<% if tournament_permissions(@tournament) %>
<% if can? :manage, @tournament %>
<%= submit_tag "Save", :class=>"btn btn-success"%>
<% end %>
<% end %>

View File

@@ -3,7 +3,7 @@
<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}", :class=>"btn btn-default" %>
<% if tournament_permissions(@tournament) %>
<% if can? :manage, @tournament %>
| <%= link_to "Edit #{@weight.max} Weight Class", edit_weight_path(@weight), :class=>"btn btn-primary" %>
<% end %>
@@ -11,7 +11,7 @@
<h1>Weight Class:<%= @weight.max %></h1>
<br>
<br>
<table class="table table-striped table-bordered">
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>Name</th>
@@ -20,7 +20,7 @@
<th>Record</th>
<th>Seed Criteria</th>
<th>Extra?</th>
<% if tournament_permissions(@tournament) %><th>Actions for wrestler</th><% end %>
<% if can? :manage, @tournament %> %><th>Actions for wrestler</th><% end %>
</tr>
</thead>
<tbody>
@@ -29,9 +29,9 @@
<% if wrestler.weight_id == @weight.id %>
<tr>
<td><%= wrestler.name %></td>
<td><%= School.find(wrestler.school_id).name %></td>
<td><%= wrestler.school.name %></td>
<td>
<% if tournament_permissions(@tournament) %>
<% if can? :manage, @tournament %>
<%= fields_for "wrestler[]", wrestler do |w| %>
<%= w.text_field :original_seed %>
<% end %>
@@ -44,9 +44,9 @@
<td><% if wrestler.extra? == true %>
Yes
<% end %></td>
<% if tournament_permissions(@tournament) %>
<td><%= link_to 'Show', wrestler , :class=>"btn btn-default" %>
<%= link_to 'Destroy', wrestler, method: :delete, data: { confirm: 'Are you sure?' } , :class=>"btn btn-danger" %></td>
<% if can? :manage, @tournament %>
<td><%= link_to 'Show', wrestler , :class=>"btn btn-default btn-sm" %>
<%= link_to 'Destroy', wrestler, method: :delete, data: { confirm: 'Are you sure?' } , :class=>"btn btn-danger btn-sm" %></td>
<% end %>
</tr>
<% end %>
@@ -54,7 +54,7 @@
</tbody>
</table>
<br><p>*All wrestlers without a seed (determined by tournament director) will be assigned a random seed.</p>
<% if tournament_permissions(@tournament) %>
<% if can? :manage, @tournament %>
<br>
<%= submit_tag "Save", :class=>"btn btn-success"%>
<% end %>

View File

@@ -30,10 +30,6 @@
<%= f.collection_select :weight_id, @weights, :id, :max %>
</div>
<div class="field">
<%= f.label :original_seed %><br>
<%= f.number_field :original_seed %>
</div>
<div class="field">
<%= f.label "Season Wins" %><br>
<%= f.number_field :season_win %>

View File

@@ -2,7 +2,7 @@
<p id="notice"><%= notice %></p>
<%= link_to "Back to #{@school.name}", "/schools/#{@school.id}", :class=>"btn btn-default" %>
<% if tournament_permissions(@wrestler.tournament) %>
<% if can? :manage, @tournament %>
| <%= link_to "Edit #{@wrestler.name}", edit_wrestler_path(@wrestler), :class=>"btn btn-primary" %>
<% end %>
<% cache ["wrestlers", @wrestler] do %>