1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-10 23:53:06 +00:00

Added a feature to generate uuid links for coaches to submit their school lineups.

This commit is contained in:
2025-02-18 16:39:10 -05:00
parent 934b34d0b7
commit 91e1939e69
20 changed files with 725 additions and 272 deletions

View File

@@ -21,6 +21,10 @@
<% end %>
<br>
<% if params[:school_permission_key].present? %>
<%= f.hidden_field :school_permission_key, value: params[:school_permission_key] %>
<% end %>
<div class="actions">
<%= f.submit 'Submit', :class=>"btn btn-success" %>
</div>

View File

@@ -1,68 +1,115 @@
<p>
<strong>Name:</strong>
<%= @school.name %>
<% if can? :manage, @school %><%= link_to " Edit", edit_school_path(@school),:class=>"fas fa-edit" %><% end %>
</p>
<p>
<strong>Name:</strong>
<%= @school.name %>
<% if can? :manage, @school %>
<% edit_school_path_with_key = edit_school_path(@school) %>
<% edit_school_path_with_key += "?school_permission_key=#{params[:school_permission_key]}" if params[:school_permission_key].present? %>
<%= link_to " Edit", edit_school_path_with_key, class: "fas fa-edit" %>
<% end %>
</p>
<p>
<strong>Team Points Deducted:</strong>
<%= @school.total_points_deducted %>
</p>
<p>
<strong>Score:</strong>
<%= @school.score %>
</p>
<p>
<strong>Team Points Deducted:</strong>
<%= @school.total_points_deducted %>
</p>
<p>
<strong>Tournament:</strong>
<%= @school.tournament.name %>
</p>
<%= link_to "#{@school.name} Stat Summary", "/schools/#{@school.id}/stats",:class=>"btn btn-sm btn-primary" %>
<br>
<br>
<h3>Roster</h3>
<p>(Click wrestler to see their score breakdown and match list)</p>
<table class="table table-hover table-condensed">
<thead>
<tr>
<th>Name</th>
<th>Weight</th>
<th>Record/Seed Criteria</th>
<th>Seed</th>
<th>Team Points Scored</th>
<th>Extra?</th>
<th>Next Bout/Mat</th>
<% if can? :manage, @school %><th><%= link_to " New Wrestler" , "/wrestlers/new?school=#{@school.id}", :class=>"fas fa-plus"%></th><% end %>
</tr>
</thead>
<p>
<strong>Score:</strong>
<%= @school.score %>
</p>
<tbody>
<% @wrestlers.sort_by{|w| w.weight.max}.each do |wrestler| %>
<p>
<strong>Tournament:</strong>
<%= @school.tournament.name %>
</p>
<% stat_summary_path_with_key = "/schools/#{@school.id}/stats" %>
<% stat_summary_path_with_key += "?school_permission_key=#{params[:school_permission_key]}" if params[:school_permission_key].present? %>
<%= link_to "#{@school.name} Stat Summary", stat_summary_path_with_key, class: "btn btn-sm btn-primary" %>
<br><br>
<h3>Roster</h3>
<p>(Click wrestler to see their score breakdown and match list)</p>
<table class="table table-hover table-condensed">
<thead>
<tr>
<th>Name</th>
<th>Weight</th>
<th>Record/Seed Criteria</th>
<th>Seed</th>
<th>Team Points Scored</th>
<th>Extra?</th>
<th>Next Bout/Mat</th>
<% new_wrestler_path_with_key = new_wrestler_path(school: @school.id) %>
<% new_wrestler_path_with_key += "&school_permission_key=#{params[:school_permission_key]}" if params[:school_permission_key].present? %>
<% if can? :manage, @school %>
<th><%= link_to " New Wrestler", new_wrestler_path_with_key, class: "fas fa-plus" %></th>
<% end %>
</tr>
</thead>
<tbody>
<% @wrestlers.sort_by { |w| w.weight.max }.each do |wrestler| %>
<% if params[:school_permission_key].present? %>
<!-- No caching when school_permission_key is present -->
<tr>
<td>
<% wrestler_path_with_key = wrestler_path(wrestler) %>
<% wrestler_path_with_key += "?school_permission_key=#{params[:school_permission_key]}" if params[:school_permission_key].present? %>
<%= link_to wrestler.name, wrestler_path_with_key %>
</td>
<td><%= wrestler.weight.max %></td>
<td><%= wrestler.season_win %>-<%= wrestler.season_loss %> <%= wrestler.criteria %></td>
<td><%= wrestler.original_seed %></td>
<td><%= wrestler.total_team_points - wrestler.total_points_deducted %></td>
<td><%= "Yes" if wrestler.extra? %></td>
<td><%= wrestler.next_match_bout_number %> <%= wrestler.next_match_mat_name %></td>
<% if can? :manage, wrestler.school %>
<td>
<% edit_wrestler_path_with_key = edit_wrestler_path(wrestler) %>
<% edit_wrestler_path_with_key += "?school_permission_key=#{params[:school_permission_key]}" if params[:school_permission_key].present? %>
<% delete_wrestler_path_with_key = wrestler_path(wrestler) %>
<% delete_wrestler_path_with_key += "?school_permission_key=#{params[:school_permission_key]}" if params[:school_permission_key].present? %>
<%= link_to '', edit_wrestler_path_with_key, class: "fas fa-edit" %>
<%= link_to '', delete_wrestler_path_with_key, method: :delete, data: { confirm: "Are you sure you want to delete #{wrestler.name}? This will delete all of his matches." }, class: "fas fa-trash-alt" %>
</td>
<% end %>
</tr>
<% else %>
<!-- Use caching only when school_permission_key is NOT present -->
<% cache ["#{wrestler.id}_school_show", @school] do %>
<tr>
<td><%= link_to "#{wrestler.name}", wrestler %></td>
<td><%= link_to wrestler.name, wrestler_path(wrestler) %></td>
<td><%= wrestler.weight.max %></td>
<td><%= wrestler.season_win %>-<%= wrestler.season_loss %> <%= wrestler.criteria %></td>
<td>
<%= wrestler.original_seed %>
</td>
<td><%= wrestler.original_seed %></td>
<td><%= wrestler.total_team_points - wrestler.total_points_deducted %></td>
<td><% if wrestler.extra? == true %>
Yes
<% end %>
</td>
<td><%= "Yes" if wrestler.extra? %></td>
<td><%= wrestler.next_match_bout_number %> <%= wrestler.next_match_mat_name %></td>
<% end %>
<td><%= wrestler.next_match_bout_number %> <%= wrestler.next_match_mat_name %></td>
<% if can? :manage, wrestler.school %>
<td>
<%= link_to '', edit_wrestler_path(wrestler),:class=>"fas fa-edit" %>
<%= link_to '', wrestler, method: :delete, data: { confirm: "Are you sure you want to delete #{wrestler.name}? This will delete all of his matches." }, :class=>"fas fa-trash-alt" %>
<% edit_wrestler_path_with_key = edit_wrestler_path(wrestler) %>
<% edit_wrestler_path_with_key += "?school_permission_key=#{params[:school_permission_key]}" if params[:school_permission_key].present? %>
<% delete_wrestler_path_with_key = wrestler_path(wrestler) %>
<% delete_wrestler_path_with_key += "?school_permission_key=#{params[:school_permission_key]}" if params[:school_permission_key].present? %>
<%= link_to '', edit_wrestler_path_with_key, class: "fas fa-edit" %>
<%= link_to '', delete_wrestler_path_with_key, method: :delete, data: { confirm: "Are you sure you want to delete #{wrestler.name}? This will delete all of his matches." }, class: "fas fa-trash-alt" %>
</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
<% end %>
</tbody>
</table>
<% if can? :manage, @school %>
<%= render 'baums_roster_import' %>

View File

@@ -1,4 +1,7 @@
<%= link_to "Back to #{@school.name}", "/schools/#{@school.id}", :class=>"btn btn-default" %>
<% back_to_school_path = school_path(@school) %>
<% back_to_school_path += "?school_permission_key=#{params[:school_permission_key]}" if params[:school_permission_key].present? %>
<%= link_to "Back to #{@school.name}", back_to_school_path, class: "btn btn-default" %>
<% cache ["#{@school.id}_Stats", @school] do %>
<br>
<br>

View File

@@ -17,6 +17,7 @@
<% @winner_place = "1st" %>
<%= render 'bracket_final' %>
</div>
<! -- Only use a 2nd page for consolation bracket if bracket is bigger than 16 -->
<% if @weight.wrestlers.size > 16 %>
</div>
</div>
@@ -24,6 +25,7 @@
<div class="page">
<div class="bracket-container">
<% end %>
<! -- End if for only use a 2nd page for consolation bracket if bracket is bigger than 16 -->
<h4><%= @tournament.name %> - <%= @weight.max %> Bracket</h4>
<h4>Consolation Bracket</h4>
<div class="bracket">
@@ -41,13 +43,15 @@
<% @winner_place = "3rd" %>
<%= render 'bracket_final' %>
</div>
<% if @weight.wrestlers.size >= 6 && @tournament.number_of_placers >= 6 %>
<h4>5/6 place match</h4>
<div class="bracket">
<% @final_match = @matches.select{|m|m.bracket_position == "5/6"} %>
<% @winner_place = "5th" %>
<%= render 'bracket_final' %>
</div>
<% if @tournament.number_of_placers >= 8 %>
<% end %>
<% if @weight.wrestlers.size >= 8 && @tournament.number_of_placers >= 8 %>
<h4>7/8 place match</h4>
<div class="bracket">
<% @final_match = @matches.select{|m|m.bracket_position == "7/8"} %>

View File

@@ -1,4 +1,35 @@
<h1>Search results</h1> <%= form_tag(school_delegate_path, :method => "get", id: "search-form") do %>
<h1>School Lineup Permission Links</h1>
<p>Instead of forcing coaches to log into the app, you can generate links for their school that you can email them to submit their lineups. Be sure to delete these after the deadline for lineup submissions.</p>
<%= button_to "Generate School Permission Key Links", generate_school_keys_tournament_path(@tournament), method: :post, class: "btn btn-success" %>
<%= button_to "Delete School Permission Key Links", delete_school_keys_tournament_path(@tournament), method: :post, class: "btn btn-danger" %>
<br><br>
<% if @tournament.schools.where.not(permission_key: nil).exists? %>
<h2>Links for Schools with Permission Keys</h2>
<table class="table table-striped">
<thead>
<tr>
<th>School Name</th>
<th>Permission Link</th>
</tr>
</thead>
<tbody>
<% @tournament.schools.where.not(permission_key: nil).each do |school| %>
<tr>
<td><%= school.name %></td>
<td>
<% full_url = "#{request.base_url}/schools/#{school.id}?school_permission_key=#{school.permission_key}" %>
<a href="<%= full_url %>"><%= full_url %></a>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<br><br>
<h1>School Delegation for User Accounts</h1>
<p>If you'd like coaches to have to log into the app, you can have them create an account first then search for that account here and assign their account to a school for lineup submission. Be sure to delete these after the deadline for lineup submissions.</p>
<h2>Search results</h2> <%= form_tag(school_delegate_path, :method => "get", id: "search-form") do %>
<%= text_field_tag :search, params[:search], placeholder: "Search users" %>
<%= submit_tag "Search" %>
<% end %>
@@ -33,7 +64,7 @@
<% end %>
<% if @users_delegates %>
<h1>Delegated users schools</h1>
<h2>Delegated users schools</h2>
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
@@ -53,4 +84,4 @@
<% end %>
</tbody>
</table>
<% end %>
<% end %>

View File

@@ -1,13 +1,11 @@
<%= form_for(@wrestler) do |f| %>
<% if @wrestler.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@wrestler.errors.count, "error") %> prohibited this wrestler from being saved:</h2>
<ul>
<% @wrestler.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
<% @wrestler.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
@@ -16,43 +14,37 @@
<%= f.label :name %><br>
<%= f.text_field :name %>
</div>
<% if can? :manage, @wrestler.tournament %>
<div class="field">
<%= f.label 'School' %><br>
<%= f.collection_select :school_id, @school.tournament.schools, :id, :name %>
</div>
<% if can? :manage, @wrestler.tournament %>
<div class="field">
<%= f.label 'School' %><br>
<%= f.collection_select :school_id, @school.tournament.schools, :id, :name %>
</div>
<% else %>
<%= f.hidden_field :school_id, :value => @school.id %>
<%= f.hidden_field :school_id, value: @school.id %>
<% end %>
<div class="field">
<%= f.label 'Weight Class' %><br>
<%= f.collection_select :weight_id, @weights, :id, :max %>
</div>
<div class="field">
<%= f.label "Season Wins" %><br>
<%= f.number_field :season_win %>
</div>
<div class="field">
<%= f.label "Season Losses" %><br>
<%= f.number_field :season_loss %>
</div>
<div class="field">
<%= f.label "Seed Criteria" %><br>
<%= f.text_field :criteria %>
</div>
<div class="field">
<%= f.label "Check box if extra" %> <%= f.check_box :extra %>
</div>
</br>
</br>
<!-- Render the hidden field if a permission key is present -->
<% if @school_permission_key.present? %>
<%= f.hidden_field :school_permission_key, value: @school_permission_key %>
<% end %>
<div class="actions">
<%= f.submit :class=>"btn btn-success"%>
<%= f.submit class: "btn btn-success" %>
</div>
<% end %>

View File

@@ -1,4 +1,7 @@
<%= link_to "Back to #{@school.name}", "/schools/#{@school.id}", :class=>"btn btn-default" %>
<% back_to_school_path = school_path(@school) %>
<% back_to_school_path += "?school_permission_key=#{params[:school_permission_key]}" if params[:school_permission_key].present? %>
<%= link_to "Back to #{@school.name}", back_to_school_path, class: "btn btn-default" %>
<br>
<br>
<h1>Editing wrestler</h1>

View File

@@ -1,4 +1,7 @@
<%= link_to "Back to #{@school.name}", "/schools/#{@school.id}", :class=>"btn btn-default" %>
<% back_to_school_path = school_path(@school) %>
<% back_to_school_path += "?school_permission_key=#{params[:school_permission_key]}" if params[:school_permission_key].present? %>
<%= link_to "Back to #{@school.name}", back_to_school_path, class: "btn btn-default" %>
<br>
<br>
<h1>New wrestler</h1>

View File

@@ -1,4 +1,7 @@
<%= link_to "Back to #{@school.name}", "/schools/#{@school.id}", :class=>"btn btn-sm btn-default" %>
<% back_to_school_path = school_path(@wrestler.school) %>
<% back_to_school_path += "?school_permission_key=#{params[:school_permission_key]}" if params[:school_permission_key].present? %>
<%= link_to "Back to #{@wrestler.school.name}", back_to_school_path, class: "btn btn-default" %>
<br>
<br>
<p>