Editing Contest

<%= form_for @contest, html: { class: 'square' } do |f| %> <%= render 'shared/errors', messages: @contest.errors.full_messages %> <%= hidden_field_tag :type, 'contest' %>
<%= f.label :name %> <%= f.text_field :name %>
<%= f.label :short_name %> <%= f.text_field :short_name %>
<%= f.label :start %> <%= f.datetime_select :start, datetime_separator: '', time_separator: '' %>
<%= f.label :end %> <%= f.datetime_select :end, datetime_separator: '', time_separator: '' %>
<%= f.label :status %> <%= f.select :status, @contest.statuses.invert %>
<%= f.label :demos_id %> <%= f.select :demos_id, Directory.all.collect{|d| [d, d.id]} %>
<%= f.label :default_time %> <%= f.time_select :default_time, time_separator: '' %>
<%= f.label :winner_id %> <%= f.select :winner_id, @contest.contesters.collect { |t| [t.team, t.id] }, include_blank: true %>
<%= f.label :rules_id %> <%= f.select :rules_id, Category.find(Category::RULES).articles.collect { |a| [a, a.id] }, include_blank: true %>
<% if @contest.contest_type == Contest::TYPE_LADDER %>
<%= f.label :weight %> <%= f.text_field :weight %>
<%= f.label :modulus_base %> <%= f.text_field :modulus_base %>
<%= f.label :modulus_even %> <%= f.text_field :modulus_even %>
<%= f.label :modulus_3to1 %> <%= f.text_field :modulus_3to1 %>
<%= f.label :modulus_4to0 %> <%= f.text_field :modulus_4to0 %>
<% end %>
<%= f.submit 'Save Contest' %>
<% end %>
<% if @contest.contest_type == Contest::TYPE_BRACKET %>
<% @contest.brackets.each do |bracket| %> <% end %>
Bracket Slots
<%= namelink bracket %> <%= bracket.slots %> <%= link_to icon('pencil'), edit_bracket_path(bracket) %> <%= link_to icon('times'), bracket, confirm: 'Are you sure?', method: :delete %>
<%= form_for @contest.brackets.build, html: { class: 'square' } do |f| %> <%= render 'shared/errors', messages: @contest.brackets.last.errors.full_messages %> <%= hidden_field_tag :type, 'contest' %> <%= f.hidden_field :contest_id %>
<%= f.label :slots %> <%= f.text_field :slots %>
<%= f.submit 'Add Bracket' %>
<% end %>
<% end %>
<% @contest.maps.basic.each do |map| %> <% end %>
Name Download
<%= namelink map %> <%= h map.download %> <%= link_to icon('pencil'), edit_map_path(map) %> <%= link_to icon('times'), action: "del_map", id: @contest.id, id2: map.id %>
<%= form_for @contest do |f| %> <%= render 'shared/errors', messages: @contest.errors.full_messages %> <%= hidden_field_tag :type, 'map' %>
<%= select_tag :map, options_from_collection_for_select(Map.basic, :id, :name) %>
<%= f.submit 'Add map' %>
<% end %>
<% @contest.contesters.each do |contester| %> <% end %>
Team Score Status
<%= link_to (h contester.team), contester %> <%= h contester.score %> <%= contester.statuses[contester.active] %> <% if contester.active %> <%= link_to icon('pencil'), edit_contester_path(contester) %> <%= link_to icon('times'), contester, confirm: 'Are you sure?', method: :delete %> <% else %> <%= form_for contester do |c| %> <%= c.hidden_field :active, { value: 1 } %> <%= link_to icon('pencil'), edit_contester_path(contester) %> <%= link_to icon('rotate-left'), "#form_submit" %> <% end %> <% end %>
<%= form_for @contest.contesters.build do |f| %> <%= render 'shared/errors', messages: @contest.contesters.last.errors.full_messages %> <%= hidden_field_tag :type, 'team' %> <%= f.hidden_field :contest_id %>
<%= f.select :team_id, Team.active.ordered.collect{|t| [t, t.id]} %>
<%= f.submit 'Add Team' %>
<% end %>
<% @contest.weeks.each do |week| %> <% end %>
Name Start date Map1 Map2
<%= h week.name %> <%= week.start_date.strftime("%d %B %y") %> <%= h week.map1 %> <%= h week.map2 %> <%= link_to icon('pencil'), edit_week_path(week) %> <%= link_to icon('times'), week, confirm: 'Are you sure?', method: :delete %>
<%= link_to "New Week", { controller: :weeks, action: :new, id: @contest }, { class: 'button' } %>
<% @contest.matches.each do |match| %> <% end %>
Teams Date Score
<%= namelink match.contester1.team %> vs <%= namelink match.contester2.team %> <%= link_to (longtime match.match_time), match %> <% link_to match do %> <%= h match.score1 %> - <%= h match.score2 %> <% end %> <%= link_to icon('flag-checkered'), controller: :matches, action: :ref, id: match %> <%= link_to icon('pencil'), edit_match_path(match) %> <%= link_to icon('times'), match, confirm: 'Are you sure?', method: :delete %>
<%= link_to "New Match", { controller: :matches, action: :new, id: @contest }, { class: 'button' } %>