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

Preliminary import/export feature

This commit is contained in:
2019-01-30 20:16:56 +00:00
parent 46b8888245
commit 2b92bdaf66
8 changed files with 228 additions and 3 deletions

View File

@@ -40,6 +40,7 @@
<li><%= link_to "Create High School Weights (106-285)" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=hs",data: { confirm: 'Are you sure? This will delete all current weights.' } %></li>
<li><strong>Tournament Actions</strong></li>
<li><%= link_to "Generate Brackets" , "/tournaments/#{@tournament.id}/generate_matches", data: { confirm: 'Are you sure? This will delete all current matches.' } %></li>
<li><%= link_to "Export Data" , "/tournaments/#{@tournament.id}/export?print=true", target: :_blank %></li>
</ul>
<% end %>
</ul>

View File

@@ -0,0 +1,11 @@
<% if can? :manage, @tournament %>
<br><br>
<h3>Import Data</h3>
<%= form_for(Tournament.new, url: import_url(@tournament)) do |f| %>
<div class="field">
<%= f.label 'Import text' %><br>
<%= f.text_area :import_text, cols: "30", rows: "20" %>
</div>
<%= submit_tag "Import", :class=>"btn btn-success", data: { confirm: 'Are you sure? This will delete everything for the current tournament and restore it with the backup text pasted below.' }%>
<% end %>
<% end %>

View File

@@ -0,0 +1,22 @@
--COPY AND PASTE ALL OF THIS TEXT INTO A FILE ON YOUR COMPUTER--<br>
--CLICK ANYWHERE ON THIS PAGE, PRESS CTRL + A (OR COMMAND + A ON MAC) TO SELECT ALL, THEN PRESS CTRL + C (OR COMMAND + C ON MAC) TO COPY--<br>
--THEN IN A DOCUMENT, RIGHT CLICK PASTE--<br>
--WE RECOMMEND USING NOTEPAD (NOT MICROSOFT WORD) TO SAVE THIS TEXT ON WINDOWS--<br>
<br>
<br>
--TO RESTORE PASTE THIS TEXT INTO THE FORM ON THE TOURNAMENT HOME PAGE--<br>
<br>
<br>
<% attribute_separator = ";;" %>
<% model_separator = ",," %>
--Tournament--<%= model_separator %><%= @tournament.name %><%= attribute_separator %><%= @tournament.address %><%= attribute_separator %><%= @tournament.director %><%= attribute_separator %><%= @tournament.director_email %><%= attribute_separator %><%= @tournament.tournament_type %><%= attribute_separator %><%= @tournament.weigh_in_ref %><%= attribute_separator %><%= @tournament.user_id %><%= attribute_separator %><%= @tournament.curently_generating_matches %><%= attribute_separator %><%= @tournament.date %>
<br>
--Schools--<% @tournament.schools.each do |school| %><%= model_separator %><%= school.name %><%= attribute_separator %><%= school.score %><% end %>
<br>
--Weights--<% @tournament.weights.each do |weight| %><%= model_separator %><%= weight.max %><% end %>
<br>
--Mats--<% @tournament.mats.each do |mat| %><%= model_separator %><%= mat.name %><% end %>
<br>
--Wrestlers--<% @tournament.wrestlers.each do |wrestler| %><%= model_separator %><%= wrestler.name %><%= attribute_separator %><%= wrestler.school.name %><%= attribute_separator %><%= wrestler.weight.max %><%= attribute_separator %><%= wrestler.bracket_line %><%= attribute_separator %><%= wrestler.original_seed %><%= attribute_separator %><%= wrestler.season_win %><%= attribute_separator %><%= wrestler.season_loss %><%= attribute_separator %><%= wrestler.criteria %><%= attribute_separator %><%= wrestler.extra %><%= attribute_separator %><%= wrestler.offical_weight %><%= attribute_separator %><%= wrestler.pool %><% end %>
<br>
--Matches--<% @tournament.matches.sort_by{|match| match.bout_number}.each do |match| %><%= model_separator %><%= Wrestler.where("id = ?",match.w1).first.name if match.w1 %><%= attribute_separator %><%= Wrestler.where("id = ?",match.w2).first.name if match.w2 %><%= attribute_separator %><%= match.w1_stat %><%= attribute_separator %><%= match.w2_stat %><%= attribute_separator %><%= Wrestler.where("id = ?",match.winner_id).first.name if match.winner_id %><%= attribute_separator %><%= match.win_type %><%= attribute_separator %><%= match.score %><%= attribute_separator %><%= match.round %><%= attribute_separator %><%= match.finished %><%= attribute_separator %><%= match.bout_number %><%= attribute_separator %><%= Weight.where("id = ?",match.weight_id).first.max if match.weight_id %><%= attribute_separator %><%= match.bracket_position %><%= attribute_separator %><%= match.bracket_position_number %><%= attribute_separator %><%= match.loser1_name %><%= attribute_separator %><%= match.loser2_name %><%= attribute_separator %><%= Mat.where("id = ?",match.mat_id).first.name if match.mat_id %><% end %>

View File

@@ -130,7 +130,8 @@
</table>
<% end %>
<br>
<%= render 'import_form' %>