%
# Copyright (C) 2014 Andrew Murrell
# Copyright (C) 2014 Davis Webb
# Copyright (C) 2014 Guntas Grewal
# Copyright (C) 2014 Luke Shumaker
# Copyright (C) 2014 Nathaniel Foy
# Copyright (C) 2014 Tomer Kimia
#
# This file is part of Leaguer.
#
# Leaguer is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Leaguer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the Affero GNU General Public License
# along with Leaguer. If not, see .
%>
<%= link_to '« Back to all tournaments', tournaments_path, class: :breadcrumb %>
Hmmm.... nobody's here yet! You and your friends should join the tournament.
<% end %>
<%# If user can join, and user hasn't joined already, show a join tournment button %>
<% if @tournament.joinable_by?(current_user) && !@tournament.players.include?(current_user) %>
<%= form_tag(tournament_path(@tournament), method: "put", class: :button_to) do %>
<%= submit_tag("Join Tournament") %>
<% end %>
<% elsif @tournament.players.include?(current_user) %>
<%= form_tag(tournament_path(@tournament), method: "put", class: :button_to) do %>
<%= submit_tag("Leave Tournament") %>
<% end %>
<% end %>
<%# If user is the host, let them start the tournment %>
<% if @tournament.check_permission(current_user, :edit) %>
<%= form_tag(tournament_path(@tournament), method: "put", class: :button_to) do %>
<%= submit_tag("Start Tournament", disabled: (@tournament.players.count < @tournament.min_players_per_team * @tournament.min_teams_per_match)) %>
<% end %>
<%= link_to 'Edit Tournament', edit_tournament_path(@tournament), role: :button %>
<%= button_to 'Cancel Tournament', @tournament, method: :delete, data: { confirm: 'Are you sure?' } %>
<% end %>