diff options
Diffstat (limited to 'app/views')
48 files changed, 969 insertions, 462 deletions
diff --git a/app/views/alerts/_form.html.erb b/app/views/alerts/_form.html.erb index b60eaf2..e7a2444 100644 --- a/app/views/alerts/_form.html.erb +++ b/app/views/alerts/_form.html.erb @@ -10,11 +10,6 @@ </ul> </div> <% end %> - - <div class="field"> - <%= f.label :author_id %><br> - <%= f.text_field :author_id %> - </div> <div class="field"> <%= f.label :message %><br> <%= f.text_area :message %> diff --git a/app/views/alerts/index.html.erb b/app/views/alerts/index.html.erb index 458b951..c978bea 100644 --- a/app/views/alerts/index.html.erb +++ b/app/views/alerts/index.html.erb @@ -12,14 +12,18 @@ </thead> <tbody> - <% @alerts.each do |alert| %> - <tr> - <td><%= alert.author %></td> - <td><%= alert.message %></td> - <td><%= link_to 'Show', alert %></td> - <td><%= link_to 'Edit', edit_alert_path(alert) %></td> - <td><%= link_to 'Destroy', alert, method: :delete, data: { confirm: 'Are you sure?' } %></td> - </tr> + <% if !@alerts.nil? %> + <% @alerts.each do |alert| %> + <tr> + <td><%= alert.author.user_name %></td> + <td><%= alert.message %></td> + <td><%= link_to 'Show', alert %></td> + <td><%= link_to 'Edit', edit_alert_path(alert) %></td> + <td><%= link_to 'Destroy', alert, method: :delete, data: { confirm: 'Are you sure?' } %></td> + </tr> + <% end %> + <% else %> + <td><p>There are no alerts!</p></td> <% end %> </tbody> </table> diff --git a/app/views/alerts/show.html.erb b/app/views/alerts/show.html.erb index eeab7f7..398a10e 100644 --- a/app/views/alerts/show.html.erb +++ b/app/views/alerts/show.html.erb @@ -1,8 +1,6 @@ -<p id="notice"><%= notice %></p> - <p> <strong>Author:</strong> - <%= @alert.author %> + <%= @alert.author.user_name %> </p> <p> diff --git a/app/views/application/.keep b/app/views/application/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/views/application/.keep diff --git a/app/views/brackets/index.html.erb b/app/views/brackets/index.html.erb index 2195d69..9effe37 100644 --- a/app/views/brackets/index.html.erb +++ b/app/views/brackets/index.html.erb @@ -8,7 +8,6 @@ <th>Name</th> <th></th> <th></th> - <th></th> </tr> </thead> @@ -18,9 +17,8 @@ <td><%= bracket.user %></td> <td><%= bracket.tournament %></td> <td><%= bracket.name %></td> - <td><%= link_to 'Show', bracket %></td> - <td><%= link_to 'Edit', edit_bracket_path(bracket) %></td> - <td><%= link_to 'Destroy', bracket, method: :delete, data: { confirm: 'Are you sure?' } %></td> + <td><%= link_to 'Show', tournament_bracket_path(@tournament, bracket) %></td> + <td><%= link_to 'Edit', edit_tournament_bracket_path(@tournament, bracket) %></td> </tr> <% end %> </tbody> @@ -28,4 +26,3 @@ <br> -<%= link_to 'New Bracket', new_bracket_path %> diff --git a/app/views/brackets/new.html.erb b/app/views/brackets/new.html.erb index c379c15..91d0033 100644 --- a/app/views/brackets/new.html.erb +++ b/app/views/brackets/new.html.erb @@ -1,5 +1,3 @@ <h1>New bracket</h1> -<%= render 'form' %> - -<%= link_to 'Back', brackets_path %> +<%= link_to 'Back', tournament_brackets_path %> diff --git a/app/views/brackets/show.html.erb b/app/views/brackets/show.html.erb index 9c7c14b..75446f5 100644 --- a/app/views/brackets/show.html.erb +++ b/app/views/brackets/show.html.erb @@ -1,19 +1,83 @@ -<p id="notice"><%= notice %></p> +<h2><%= @bracket.name %></h2> -<p> - <strong>User:</strong> - <%= @bracket.user %> -</p> +<h4> Make your prediction for the tournament by clicking on the teams you think will win </h4> -<p> - <strong>Tournament:</strong> - <%= @bracket.tournament %> -</p> +<% @bracket.bracket_matches.each do |m| %> + <p><b><%= m.match.id %></b></p> +<% end %> -<p> - <strong>Name:</strong> - <%= @bracket.name %> -</p> +<svg version="1.1" baseProfile="full" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + width="100%" height=<%= "#{@height}"%>> + <defs> + <radialGradient id="gradMatch" cx="50%" cy="50%" r="80%" fx="50%" fy="50%"> + <stop offset="0%" style="stop-color:#fff; stop-opacity:1" /> + <stop offset="100%" style="stop-color:#ccc;stop-opacity:0" /> + </radialGradient> + </defs> + <script type="text/ecmascript"><![CDATA[ + function redirect(i){ + window.location.replace("<%= request.original_url %>"+"/"+i); + } + ]]> + </script> + + <% (1..@matches.count).each do |i| %> + <% matchDepth = Math.log(i*(@logBase-1), @logBase).floor+1 %> + <% if matchDepth > Math.log(@base*(@logBase-1), @logBase).floor+1 + @pBase = @base + @base = i + end %> + <g id="svg-match-<%= i %>"> + <rect height="<%= rh = 100 / (@logBase**(@depth-1)+1) - 100/@height %>%" + width="<%= rw = 100/(@depth+1) - 5 %>%" + x="<%= rx = 50/(@depth+1) + 100/(@depth+1)*(@depth-matchDepth) %>%" + y="<%= ry = 100/(@logBase**(matchDepth-1)+1) * (i-@base+1) - rh/2 %>%" + fill="url(#gradMatch)" + rx="5px" + stroke-width="2" + <% case @matches[i].status %> + <% when 0 %> + <% if @matches[i].teams.count < @tournament.min_teams_per_match %> + stroke="red" + fill-opacity="0.6" + <% else %> + stroke="green" + <% end %> + <% when 1 %> + stroke="orange" + <% when 2 %> + stroke="yellow" + <% when 3 %> + stroke="grey" + <% end %> + /> -<%= link_to 'Edit', edit_bracket_path(@bracket) %> | -<%= link_to 'Back', brackets_path %> + <% t = 1 + while t <= @numTeams %> + <rect width="<%= rw-5 %>%" height="<%= rh*Float(30)/(@matchHeight) %>%" x="<%= rx + 2.5 %>%" y="<%= ry + (Float(t-1)/@numTeams)*rh + 1 %>%" fill="<%= @matches[i].teams[t-1] and @matches[i].teams[t-1].include?(current_user) ? "#5BC0DE" : "white" %>" onclick="chooseWinner(<%= @matches[i].id, %>)" /> + <text x="<%= rx + rw/4 %>%" y="<%= ry + (Float(t-1)/@numTeams + Float(33)/(@matchHeight))*rh %>%" font-size="200%"> + <% if @matches[i].teams[t-1] %> + Team <%= @matches[i].teams[t-1].id %> + <% end %> + </text> + <% if (t < @numTeams) %> + <text x="<%= rx + 1.3*rw/3 %>%" y="<%= ry + (Float(t)/@numTeams)*rh + 1%>%" font-size="200%"> VS </text> + <% end %> + <% t = t + 1 %> + <% end %> + + <% if i > 1 %> + <% parent = (i+@logBase-2)/@logBase + pDepth = Math.log(parent*(@logBase-1), @logBase).floor+1 + lastrx = 50/(@depth+1) + 100/(@depth+1)*(@depth-pDepth) + lastry = 100/(@logBase**(pDepth-1)+1) * (parent-@pBase+1) - rh/2 %> + <line x1="<%= rx+rw %>%" y1="<%= ry+rh/2 %>%" x2="<%= lastrx%>%" y2="<%= lastry+rh/2%>%" stroke="white" stroke-width="2" > + <% end %> + </g> + + <% end %> +</SVG> + +<%= link_to 'Back', tournaments_path %> diff --git a/app/views/common/_error_messages.html.erb b/app/views/common/_error_messages.html.erb new file mode 100644 index 0000000..fdeaf65 --- /dev/null +++ b/app/views/common/_error_messages.html.erb @@ -0,0 +1,11 @@ +<%# http://railscasts.com/episodes/211-validations-in-rails-3 %> +<% if target.errors.any? %> +<div id="error_explanation"> + <h2><%= pluralize(target.errors.count, "error") %> prohibited this form from being submitted:</h2> + <ul> + <% target.errors.full_messages.each do |msg| %> + <li><%= msg %></li> + <% end %> + </ul> +</div> +<% end %> diff --git a/app/views/common/_show_tournament.html.erb b/app/views/common/_show_tournament.html.erb new file mode 100644 index 0000000..826eeaa --- /dev/null +++ b/app/views/common/_show_tournament.html.erb @@ -0,0 +1,43 @@ +<div class="row tournament-listing"> + <div class="col-md-2 col-sm-3 col-xs-6"> + <%= image_tag(target.game.name.parameterize.underscore + ".png", class: "t-image") %> + <p class="t-game"><%= Game.find(target.game_id).name %></p> + </div> + <div class="col-md-8 col-sm-7 col-xs-6"> + <%# "header" %> + <%= link_to(target) do %><h3><%= target.name %></h3><% end %> + <div class="row"> + <div class="col-md-4 host"> + <%= image_tag('http://www.gravatar.com/avatar/' + Digest::MD5.hexdigest(target.hosts.first.email) + '?s=45&d=identicon') %> + <%= target.hosts.first.name %>'s tournament + </div> + <div class="col-md-4 things"> + <p>Players per team: <%= target.min_players_per_team %></p> + <p>Players signed up: <%= target.players.count %></p> + </div> + <div class="col-md-4 things"> + <p><%# (target.randomized_teams)? "Teams are Random" : "Teams are Chosen" %></p> + <p>Players signed up: <%= target.players.count %></p> + </div> + </div> + </div> + <div class="col-md-2 col-sm-2 col-xs-2"> + <% if signed_in? %> + <% if !target.players.include?(current_user) && target.status == 0 %> + <%= form_tag(tournament_path(target), method: "put") do %> + <p> + <input type="hidden" name="update_action" value="join"> + <%= submit_tag("Join")%> + <% end %> + </p> + <% elsif target.players.include?(current_user)%> + <p class="message">You've signed up for this tournament!</p> + <% end %> + <% if target.status == 1 && target.stages.first.scheduling_method == "elimination" && target.stages.first.matches.first.status == 0 %> + <%= form_tag(tournament_brackets_path(target), method: "post") do %> + <%= submit_tag("Make Bracket") %> + <% end %> + <% end %> + <% end %> + </div> +</div> diff --git a/app/views/common/_show_user.html.erb b/app/views/common/_show_user.html.erb new file mode 100644 index 0000000..e442474 --- /dev/null +++ b/app/views/common/_show_user.html.erb @@ -0,0 +1,24 @@ +<div class="row user-listing"> + <div class="col-md-3 col-sm-4 col-xs-4"><%= image_tag ('http://www.gravatar.com/avatar/' + Digest::MD5.hexdigest(target.email) + '?s=100&d=mm') %></div> + + + <div class="col-md-9 col-sm-8 col-xs-8"> + <%# "header" %> + <%= link_to(target) do %><h3><%= target.user_name %></h3><% end %> + + <div class="row"> + <div class="col-md-6 things"> + <p> Preferred Name: </p> + <p> <%= target.name %></p> + </div> + <div class="col-md-6 things"> + <p>Latest Tournament: + <% if !target.tournaments_played.first.nil? %> + <%= target.tournaments_played.first.name %> + <% end %> + </p> + </div> + </div> + + </div> +</div> diff --git a/app/views/games/index.html.erb b/app/views/games/index.html.erb index 71e59a0..f12253c 100644 --- a/app/views/games/index.html.erb +++ b/app/views/games/index.html.erb @@ -1,6 +1,6 @@ <h1>Listing games</h1> -<table> +<table class="table table-hover"> <thead> <tr> <th>Parent</th> @@ -36,4 +36,6 @@ <br> -<%= link_to 'New Game', new_game_path %> + +<%= link_to 'New Game', new_game_path, {:class => "btn btn-warning"} %> + diff --git a/app/views/games/show.html.erb b/app/views/games/show.html.erb index 28da040..6184784 100644 --- a/app/views/games/show.html.erb +++ b/app/views/games/show.html.erb @@ -1,5 +1,3 @@ -<p id="notice"><%= notice %></p> - <p> <strong>Parent:</strong> <%= @game.parent %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index cefd1be..af26e29 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,14 +1,64 @@ <!DOCTYPE html> <html> <head> - <title>Leaguer</title> - <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> - <%= javascript_include_tag "application", "data-turbolinks-track" => true %> - <%= csrf_meta_tags %> + <title>Leaguer</title> + + <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> + <%= stylesheet_link_tag "#{params[:controller]}", media: "all", "data-turbolinks-track" => true %> + + <%= javascript_include_tag "application", "data-turbolinks-track" => true %> + <%= javascript_include_tag "#{params[:controller]}", "data-turbolinks-track" => true %> + <%= javascript_include_tag "#{params[:controller]}/#{params[:action]}", "data-turbolinks-track" => true %> + + <%= csrf_meta_tags %> + <%= yield :head %> </head> <body> +<header> + <nav> + <%# This is the logo %> + <div class="navbar-brand"><%= link_to('Leaguer', root_path) %></div> + + <%# This is the search bar #%> + <div> + <%= form_tag("/search", method: "get", :class => "search") do %> + <%= text_field_tag(:query, params[:query], type: "search") %> + <%= submit_tag("Search", :name=>nil) %> + <% end %> + </div> + + <%# these are the log in buttons #%> + <div id="log-buttons"> + <% if signed_in? %> + <%= link_to current_user.user_name, current_user, :class => "user" %> + <%= link_to "Messages", pms_path, :class => "signup" %> + <% if current_user.can? :edit_server %> + <%= link_to "Server settings", edit_server_path, :class => "server" %> + <% end %> + <% if current_user.can? :create_alert %> + <%= link_to "Create Alert", new_alert_path, :class => "create-alert" %> + <% end %> + <%= link_to "Sign out", session_path("current"), method: "delete", :class => "signout" %> + <%# if there is an unread alert then I wanna be able to show the notification icon by saying :style => display:inline. This will be Done by Guntas once he figures out how to get unread alerts. Psuedo if alerts.unread > 0 then display else don't.%> + <%= link_to "", alerts_path, :class => "alerts", :id => "alerts-ajax"%> + <% else %> + <%= link_to "Log in", new_session_path, :class => "signin" %> + <%= link_to "Sign up", new_user_path, :class => "signup" %> + <% end %> + </div> + </nav> +</header> + +<% if notice %><div id="notice"><p><%= notice %></p></div><% end %> + +<div class="wrapper"> + <%= yield %> +</div> -<%= yield %> +<footer> + <p>Leaguer © 2014, Tomer Kimia, Andrew Murrell, Luke Shumaker, Nathaniel Foy, Davis Webb, and Guntas Grewal</p> + <%= debug(params) if Rails.env.development? %> +</footer> </body> </html> diff --git a/app/views/main/homepage.html.erb b/app/views/main/homepage.html.erb new file mode 100644 index 0000000..3ca8176 --- /dev/null +++ b/app/views/main/homepage.html.erb @@ -0,0 +1,18 @@ +<div role="main" class="container theme-showcase"> + + <div class="jumbotron"> + <h1>Welcome to Leaguer</h1> + <p>This is a tournment management system designed to be used for any team sport. Our peer review system ensures that the best players move on to the next round! Try creating a new tournament and having people sign up for it. </p> + <p id="jumbo-buttons"> + <% if !signed_in? %> + <%= link_to 'Log In', new_session_path, :class => "btn btn-warning btn-lg", :role => "button" %> + <%= link_to 'Sign Up', new_user_path, :class => "btn btn-warning btn-lg", :role => "button" %> + <% else %> + <%= link_to 'Start a Tournament', new_tournament_path, :class => "btn btn-warning btn-lg", :role => "button" %> + <% end %> + <%= link_to 'See Ongoing Tournaments', tournaments_path, :class => "btn btn-warning btn-lg", :role => "button" %> + + </p> + </div> + + </div> diff --git a/app/views/matches/_form.html.erb b/app/views/matches/_form.html.erb index 9e09fd8..9d402b3 100644 --- a/app/views/matches/_form.html.erb +++ b/app/views/matches/_form.html.erb @@ -1,16 +1,5 @@ -<%= form_for(@match) do |f| %> - <% if @match.errors.any? %> - <div id="error_explanation"> - <h2><%= pluralize(@match.errors.count, "error") %> prohibited this match from being saved:</h2> - - <ul> - <% @match.errors.full_messages.each do |msg| %> - <li><%= msg %></li> - <% end %> - </ul> - </div> - <% end %> - +<%= form_for([@tournament, @tournament.matches.build]) do |f| %> + <div class="field"> <%= f.label :status %><br> <%= f.number_field :status %> diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index 766c3e8..784d7db 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -1,35 +1,40 @@ -<h1>Listing matches</h1> +<h1><%= @tournament.name %> - Matches</h1> -<table> - <thead> - <tr> - <th>Status</th> - <th>Tournament stage</th> - <th>Winner</th> - <th>Remote</th> - <th>Submitted peer evaluations</th> - <th></th> - <th></th> - <th></th> - </tr> - </thead> - <tbody> - <% @matches.each do |match| %> - <tr> - <td><%= match.status %></td> - <td><%= match.tournament_stage %></td> - <td><%= match.winner %></td> - <td><%= match.remote_id %></td> - <td><%= match.submitted_peer_evaluations %></td> - <td><%= link_to 'Show', match %></td> - <td><%= link_to 'Edit', edit_match_path(match) %></td> - <td><%= link_to 'Destroy', match, method: :delete, data: { confirm: 'Are you sure?' } %></td> - </tr> - <% end %> - </tbody> +<table id="matches-table" class="table"> + <thead> + <tr> + <th>Name</th> + <th>Status</th> + <th>Winner</th> + <th><!-- link to --></th> + <th><!-- start button --></th> + </tr> + </thead> + <tbody> + <% @tournament.stages.order(:id).each do |stage| %> + <% stage.matches_ordered.keys.sort.reverse.each do |match_key| %><tr> + <% match = stage.matches_ordered[match_key] %> + <td><%= "Match #{match.id}" %></td> + <td><%= match.status %></td> + <td><%= (match.winner.nil? ? "-" : "Team #{match.winner.id}") %></td> + <td><%= link_to "Show", tournament_match_path(@tournament, match) %> + <td> <%# If user is the host, let them start the tournment %> + <% if @tournament.hosts.include?(current_user) %> + <%= form_tag(tournament_match_path(@tournament, match), method: "put") do %> + <input type="hidden" name="update_action" value="start"> + <% @startable = (match.status == 0) and (match.teams.count >= @tournament.min_teams_per_match) %> + <%= submit_tag("Start Match", :disabled => ! @startable) %> + <% end %> + <% end %> + </td> + </tr><% end %> + <% end %> + </tbody> </table> <br> -<%= link_to 'New Match', new_match_path %> +<% @tournament.stages.order(:id).each do |stage| %> + <div class="graph"><%= raw stage.to_svg(current_user) %></div> +<% end %> diff --git a/app/views/matches/new.html.erb b/app/views/matches/new.html.erb index bd4c78c..74e7e3a 100644 --- a/app/views/matches/new.html.erb +++ b/app/views/matches/new.html.erb @@ -1,5 +1,3 @@ <h1>New match</h1> <%= render 'form' %> - -<%= link_to 'Back', matches_path %> diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb index 8384ff2..01484d3 100644 --- a/app/views/matches/show.html.erb +++ b/app/views/matches/show.html.erb @@ -1,29 +1,77 @@ -<p id="notice"><%= notice %></p> <p> - <strong>Status:</strong> - <%= @match.status %> + <strong>Status:</strong> + <%= @match.status %> </p> - <p> - <strong>Tournament stage:</strong> - <%= @match.tournament_stage %> + <strong>Tournament stage:</strong> + <%= @match.tournament_stage %> </p> -<p> - <strong>Winner:</strong> - <%= @match.winner %> -</p> +<%# + Match Status 0 => Created, waiting to be scheduled + Match Status 1 => Scheduled, waiting to start + Match Status 2 => Started, waiting to finish + Match Status 3 => Finished -<p> - <strong>Remote:</strong> - <%= @match.remote_id %> -</p> + Four views:- (status is Match status) + A. Pairings, when status is 1 for either Host or Player Or when status is 2 for player + B. A page the host will see if status is 2 OR 3 + C. The Peer review page that the players will see if status is 3. + D. The page everyone will see when status is 4. -<p> - <strong>Submitted peer evaluations:</strong> - <%= @match.submitted_peer_evaluations %> -</p> + Note: The change of status from 2 to 3 for League of Legends is coming from League Data Pull (RIOT API) +%> + +<div> + <h2>Teams/users</h2> + <ul> + <% @match.teams.each do |team| %> + <li>Team <%= team.id %><ul> + <% team.users.each do |user| %> + <% if @match.status <= 1 %> + <li><%= user.user_name %></li> + <% else %> + <% score = user.statistics.where(:name => "score", :match => @match).first %> + <li><%= user.user_name %> - SCORE: <%= score ? score.value : 0 %></li> + <% end %> + <% end %> + </ul></li> + <% end %> + </ul> +</div> + +<% unless @match.winner.nil? %> + <p> + <strong>Winner:</strong> + <%= @match.winner.users.collect{|u| u.user_name}.join(", ") %> + </p> +<% end %> -<%= link_to 'Edit', edit_match_path(@match) %> | -<%= link_to 'Back', matches_path %> +<div id="action"> + <%= form_tag(tournament_match_path(@tournament, @match), method: "put") do %> + <% case @match.status %> + <% when 0 %> + <!-- Created, waiting to be scheduled --> + <p>This match has not yet been scheduled.</p> + <% when 1 %> + <!-- Scheduled, waiting to start --> + <% if @tournament.hosts.include? current_user %> + <input type="hidden" name="update_action" value="start"> + <%= submit_tag("Start Match") %> + <% else %> + <p>Match is waiting to start.</p> + <% end %> + <% when 2 %> + <!-- Started, waiting to finish --> + <%= @match.render_sampling(current_user) %> + <% when 3 %> + <!-- Finished --> + <p>This match is finished.</p> + <% if @tournament.hosts.include? current_user %> + <input type="hidden" name="update_action" value="reset"> + <%= submit_tag("Reset Status") %> + <% end %> + <% end %> + <% end %> +</div> diff --git a/app/views/pms/_form.html.erb b/app/views/pms/_form.html.erb index 80781a5..b329e24 100644 --- a/app/views/pms/_form.html.erb +++ b/app/views/pms/_form.html.erb @@ -12,24 +12,16 @@ <% end %> <div class="field"> - <%= f.label :author_id %><br> - <%= f.text_field :author_id %> - </div> - <div class="field"> <%= f.label :recipient_id %><br> <%= f.text_field :recipient_id %> </div> - <div class="field"> - <%= f.label :message %><br> - <%= f.text_area :message %> - </div> - <div class="field"> + <div class="field"> <%= f.label :subject %><br> - <%= f.text_area :subject %> + <%= f.text_field :subject %> </div> <div class="field"> - <%= f.label :conversation_id %><br> - <%= f.text_field :conversation_id %> + <%= f.label :message %><br> + <%= f.text_area :message %> </div> <div class="actions"> <%= f.submit %> diff --git a/app/views/pms/index.html.erb b/app/views/pms/index.html.erb index b5169f5..fec6db2 100644 --- a/app/views/pms/index.html.erb +++ b/app/views/pms/index.html.erb @@ -1,35 +1,136 @@ -<h1>Listing pms</h1> +<h1> Your Conversations </h1> + +<%= link_to 'Start a new conversation', new_pm_path %> +<br> + +<h3>Unread Conversations</h3> +<% conversations = current_user.mailbox.conversations %> <table> - <thead> - <tr> - <th>Author</th> - <th>Recipient</th> - <th>Message</th> - <th>Subject</th> - <th>Conversation</th> - <th></th> - <th></th> - <th></th> - </tr> - </thead> + <col width="150"> + <col width="250"> + <col width="300"> + <tbody> + <%# if conversations.reject { |c| c.is_unread?(current_user) && (c.receipts_for current_user).last.message.sender != current_user }.empty? %> + <tr> + <tr> + <td><b>With</b></td> + <td><b>Subject</b></td> + <td><b>Body</b></td> + </tr> + <% conversations.each do |conversation| %> + <% receipts = conversation.receipts_for current_user %> + <% if conversation.is_unread?(current_user) && receipts.last.message.sender != current_user %> + <% message = receipts.last.message %> + <tr> + <% if conversation.subject == "Pay Attention!" %> + <% conversation.mark_as_read(current_user) %> + <% end %> + <td> + <% people = conversation.participants %> + <% people.each do |person| %> + <% unless person == current_user %> + <%= truncate(person.user_name, length: 20) %> + <% end %> + <% end %> + </td> + <td><%= truncate(conversation.subject, length: 30) %></td> + <td><%= truncate(message.body, length: 42) %></td> + <td><%= link_to 'View', @pms.find_by(conversation: conversation) %></td> + </tr> + <% end %> + <% end %> + </tr> + <%# else %> + + <%# end %> + </tbody> +</table> +<br> +<h3>Read Conversations</h3> +<% conversations = current_user.mailbox.conversations %> + +<table> + <col width="150"> + <col width="250"> + <col width="300"> <tbody> - <% @pms.each do |pm| %> + <%# if conversations.reject { |c| c.is_read?(current_user) || (c.receipts_for current_user).last.message.sender == current_user }.empty? %> <tr> - <td><%= pm.author %></td> - <td><%= pm.recipient %></td> - <td><%= pm.message %></td> - <td><%= pm.subject %></td> - <td><%= pm.conversation %></td> - <td><%= link_to 'Show', pm %></td> - <td><%= link_to 'Edit', edit_pm_path(pm) %></td> - <td><%= link_to 'Destroy', pm, method: :delete, data: { confirm: 'Are you sure?' } %></td> + <tr> + <td><b>With</b></td> + <td><b>Subject</b></td> + <td><b>Body</b></td> + </tr> + <% conversations.each do |conversation| %> + <% receipts = conversation.receipts_for current_user %> + <% if conversation.is_read?(current_user) || receipts.last.message.sender == current_user %> + <% message = receipts.last.message %> + <tr> + <% if conversation.subject != "Pay Attention!" %> + <td> + <% people = conversation.participants %> + <% people.each do |person| %> + <% unless person == current_user %> + <%= truncate(person.user_name, length: 20) %> + <% end %> + <% end %> + </td> + <td><%= truncate(conversation.subject, length: 30) %></td> + <td><%= truncate(message.body, length: 42) %></td> + <td><%= link_to 'View', @pms.find_by(conversation: conversation) %></td> + <% end %> + </tr> + <% end %> + <% end %> </tr> - <% end %> + <% #else %> + + <% #end %> </tbody> </table> <br> +<h3>Alerts</h3> +<% conversations = current_user.mailbox.conversations %> -<%= link_to 'New Pm', new_pm_path %> +<table> + <col width="150"> + <col width="250"> + <col width="300"> + <tbody> + <%# if conversations.reject { |c| c.is_read?(current_user) || (c.receipts_for current_user).last.message.sender == current_user }.empty? %> + <tr> + <tr> + <td><b>With</b></td> + <td><b>Subject</b></td> + <td><b>Body</b></td> + </tr> + <% conversations.each do |conversation| %> + <% receipts = conversation.receipts_for current_user %> + <% if conversation.is_read?(current_user) || receipts.last.message.sender == current_user %> + <% message = receipts.last.message %> + <tr> + <% if conversation.subject == "Pay Attention!" %> + <td> + <% people = conversation.participants %> + <% people.each do |person| %> + <% unless person == current_user %> + <%= truncate(person.user_name, length: 20) %> + <% end %> + <% end %> + </td> + <td><%= truncate(conversation.subject, length: 30) %></td> + <td><%= truncate(message.body, length: 42) %></td> + <td><%= link_to 'View', @pms.find_by(conversation: conversation) %></td> + <% end %> + </tr> + <% end %> + <% end %> + </tr> + <% #else %> + + <% #end %> + </tbody> +</table>
\ No newline at end of file diff --git a/app/views/pms/show.html.erb b/app/views/pms/show.html.erb index 2f3b944..2c93102 100644 --- a/app/views/pms/show.html.erb +++ b/app/views/pms/show.html.erb @@ -1,29 +1,48 @@ -<p id="notice"><%= notice %></p> - <p> - <strong>Author:</strong> - <%= @pm.author %> + <strong>Participants:</strong> + <% receps = @pm.conversation.participants %> + <% receps.each do |recep| %> + <% #unless recep == @pm.conversation.last_sender %> + <%= recep.user_name %> + <%= "," %> + <% #end %> + <% end %> + <%= "and the NSA" %> </p> <p> - <strong>Recipient:</strong> - <%= @pm.recipient %> + <strong>Subject:</strong> + <%= @pm.conversation.subject %> </p> -<p> - <strong>Message:</strong> - <%= @pm.message %> -</p> +<% receipts = @pm.conversation.receipts_for current_user %> +<% receipts.each do |receipt| %> + <% message = receipt.message %> -<p> - <strong>Subject:</strong> - <%= @pm.subject %> -</p> + <p> ________________________________________________ </p> -<p> - <strong>Conversation:</strong> - <%= @pm.conversation %> + <p> + <b><%= message.sender.user_name %></b> + <%= ":" %> + <%= message.body %> + </p> + +<% end %> + +<p> ________________________________________________ </p> +<p> + <% @pm.message = "" %> + <%= form_for(@pm) do |f| %> + <div class="field"> + <%= f.text_area :message %> + </div> + + <div class="actions"> + <%= submit_tag("Reply", :class => "signup") %> + </div> + + <% end %> </p> -<%= link_to 'Edit', edit_pm_path(@pm) %> | +<% @pm.conversation.mark_as_read(current_user) %> <%= link_to 'Back', pms_path %> diff --git a/app/views/search/go.html.erb b/app/views/search/go.html.erb new file mode 100644 index 0000000..ea2dabf --- /dev/null +++ b/app/views/search/go.html.erb @@ -0,0 +1,45 @@ +<div id="advanced_search" class="collapsible"> + <div class="collapsed"> + <h5><a href="#advanced_search">Advanced Search [show]</a></h5> + </div> + <div class="expanded"> + <h5><a href="#collapse">Advanced Search [hide]</a></h5> + <%= form_tag("/search", method: "get") do %> + <div class="form-group"> + <%= label_tag :query, 'Find:' %> + <%= text_field_tag(:query, params[:query]) %> + </div> + <div class="form-group"> + <%= label_tag :game_type, 'Game Type:' %> + <%= select_tag(:game_type, options_from_collection_for_select(@games, 'id', 'name'), :prompt => 'All Games') %> + </div> + <div> + <%= submit_tag("Search", :name=>nil) %> + </div> + <% end %> + </div> +</div> + +<%# Show search results if a query was not nill %> +<% if !@query.nil? and !@query.empty? %> + + <% if @tournaments.empty? and @players.empty? %> + <h3> No results found for "<%= @query %>" </h3> + <% else %> + <h3> Showing results for: <span><%= @query %></span></h3> + <% if @tournaments.length > 0 %> + <h4> Tournaments </h4> + <% end %> + <% @tournaments.each do |t| %> + <%= render "common/show_tournament", :target => t %> + <% end %> + + <% if @players.length > 0 %> + <h4> Players </h4> + <% end %> + <% @players.each do |p| %> + <%= render "common/show_user", :target => p %> + <% end %> + + <% end %> +<% end %> diff --git a/app/views/servers/_form.html.erb b/app/views/servers/_form.html.erb index 6211f9a..fd887f3 100644 --- a/app/views/servers/_form.html.erb +++ b/app/views/servers/_form.html.erb @@ -1,21 +1,16 @@ <%= form_for(@server) do |f| %> - <% if @server.errors.any? %> - <div id="error_explanation"> - <h2><%= pluralize(@server.errors.count, "error") %> prohibited this server from being saved:</h2> + <%= render "common/error_messages", :target => @server %> - <ul> - <% @server.errors.full_messages.each do |msg| %> - <li><%= msg %></li> - <% end %> - </ul> - </div> - <% end %> + <%= fields_for "server[default_user_abilities]", @server.default_user_abilities do |a| %> + <fieldset> + <legend>Default permissions for new users</legend> + <ul> + <% @server.default_user_abilities.keys.each do |ability| %> + <li><label><%= a.check_box(ability) %> <%= ability.to_s.humanize %></label></li> + <% end %> + </ul> + </fieldset> + <% end %> - <div class="field"> - <%= f.label :default_user_permissions %><br> - <%= f.number_field :default_user_permissions %> - </div> - <div class="actions"> - <%= f.submit %> - </div> + <%= f.submit %> <% end %> diff --git a/app/views/servers/edit.html.erb b/app/views/servers/edit.html.erb index a92cdb5..f29a65c 100644 --- a/app/views/servers/edit.html.erb +++ b/app/views/servers/edit.html.erb @@ -1,6 +1,3 @@ <h1>Editing server</h1> <%= render 'form' %> - -<%= link_to 'Show', @server %> | -<%= link_to 'Back', servers_path %> diff --git a/app/views/servers/index.html.erb b/app/views/servers/index.html.erb deleted file mode 100644 index b3064f4..0000000 --- a/app/views/servers/index.html.erb +++ /dev/null @@ -1,27 +0,0 @@ -<h1>Listing servers</h1> - -<table> - <thead> - <tr> - <th>Default user permissions</th> - <th></th> - <th></th> - <th></th> - </tr> - </thead> - - <tbody> - <% @servers.each do |server| %> - <tr> - <td><%= server.default_user_permissions %></td> - <td><%= link_to 'Show', server %></td> - <td><%= link_to 'Edit', edit_server_path(server) %></td> - <td><%= link_to 'Destroy', server, method: :delete, data: { confirm: 'Are you sure?' } %></td> - </tr> - <% end %> - </tbody> -</table> - -<br> - -<%= link_to 'New Server', new_server_path %> diff --git a/app/views/servers/index.json.jbuilder b/app/views/servers/index.json.jbuilder deleted file mode 100644 index 3c9df60..0000000 --- a/app/views/servers/index.json.jbuilder +++ /dev/null @@ -1,4 +0,0 @@ -json.array!(@servers) do |server| - json.extract! server, :id, :default_user_permissions - json.url server_url(server, format: :json) -end diff --git a/app/views/servers/new.html.erb b/app/views/servers/new.html.erb deleted file mode 100644 index 0422009..0000000 --- a/app/views/servers/new.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<h1>New server</h1> - -<%= render 'form' %> - -<%= link_to 'Back', servers_path %> diff --git a/app/views/servers/show.html.erb b/app/views/servers/show.html.erb index b18f09f..54aaf66 100644 --- a/app/views/servers/show.html.erb +++ b/app/views/servers/show.html.erb @@ -1,9 +1,6 @@ -<p id="notice"><%= notice %></p> - <p> <strong>Default user permissions:</strong> <%= @server.default_user_permissions %> </p> -<%= link_to 'Edit', edit_server_path(@server) %> | -<%= link_to 'Back', servers_path %> +<%= link_to 'Edit', edit_server_path %> diff --git a/app/views/sessions/_form.html.erb b/app/views/sessions/_form.html.erb deleted file mode 100644 index 90ad0ad..0000000 --- a/app/views/sessions/_form.html.erb +++ /dev/null @@ -1,25 +0,0 @@ -<%= form_for(@session) do |f| %> - <% if @session.errors.any? %> - <div id="error_explanation"> - <h2><%= pluralize(@session.errors.count, "error") %> prohibited this session from being saved:</h2> - - <ul> - <% @session.errors.full_messages.each do |msg| %> - <li><%= msg %></li> - <% end %> - </ul> - </div> - <% end %> - - <div class="field"> - <%= f.label :user_id %><br> - <%= f.text_field :user_id %> - </div> - <div class="field"> - <%= f.label :token %><br> - <%= f.text_field :token %> - </div> - <div class="actions"> - <%= f.submit %> - </div> -<% end %> diff --git a/app/views/sessions/edit.html.erb b/app/views/sessions/edit.html.erb deleted file mode 100644 index bbd8407..0000000 --- a/app/views/sessions/edit.html.erb +++ /dev/null @@ -1,6 +0,0 @@ -<h1>Editing session</h1> - -<%= render 'form' %> - -<%= link_to 'Show', @session %> | -<%= link_to 'Back', sessions_path %> diff --git a/app/views/sessions/index.html.erb b/app/views/sessions/index.html.erb deleted file mode 100644 index 43a7e1f..0000000 --- a/app/views/sessions/index.html.erb +++ /dev/null @@ -1,29 +0,0 @@ -<h1>Listing sessions</h1> - -<table> - <thead> - <tr> - <th>User</th> - <th>Token</th> - <th></th> - <th></th> - <th></th> - </tr> - </thead> - - <tbody> - <% @sessions.each do |session| %> - <tr> - <td><%= session.user %></td> - <td><%= session.token %></td> - <td><%= link_to 'Show', session %></td> - <td><%= link_to 'Edit', edit_session_path(session) %></td> - <td><%= link_to 'Destroy', session, method: :delete, data: { confirm: 'Are you sure?' } %></td> - </tr> - <% end %> - </tbody> -</table> - -<br> - -<%= link_to 'New Session', new_session_path %> diff --git a/app/views/sessions/index.json.jbuilder b/app/views/sessions/index.json.jbuilder deleted file mode 100644 index 5205ede..0000000 --- a/app/views/sessions/index.json.jbuilder +++ /dev/null @@ -1,4 +0,0 @@ -json.array!(@sessions) do |session| - json.extract! session, :id, :user_id, :token - json.url session_url(session, format: :json) -end diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index 55c9eca..ff27762 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -1,5 +1,23 @@ -<h1>New session</h1> +<h1>Sign in</h1> +<% if @user.nil? %> + <p class="errors"> The email/username or password is incorrect. Verify that CAPS LOCK is not on, and then retype the current email/username and password. </p> +<% end %> -<%= render 'form' %> + <div class="span6 offset3"> + <%= form_for(:session, url: sessions_path) do |f| %> + <p> + <%= f.label(:username_or_email, "Username/Email") %><br/> + <%= f.text_field :username_or_email%> + </p> + <p> + <%= f.label :password %><br/> + <%= f.password_field :password %> + </p> + <p> + <%= f.submit "Log in", class: "signin" %> + </p> + <% end %> + + <p>New user? <%= link_to("Sign up now!", new_user_path) %></p> + </div> -<%= link_to 'Back', sessions_path %> diff --git a/app/views/sessions/show.html.erb b/app/views/sessions/show.html.erb deleted file mode 100644 index 230e6bd..0000000 --- a/app/views/sessions/show.html.erb +++ /dev/null @@ -1,14 +0,0 @@ -<p id="notice"><%= notice %></p> - -<p> - <strong>User:</strong> - <%= @session.user %> -</p> - -<p> - <strong>Token:</strong> - <%= @session.token %> -</p> - -<%= link_to 'Edit', edit_session_path(@session) %> | -<%= link_to 'Back', sessions_path %> diff --git a/app/views/sessions/show.json.jbuilder b/app/views/sessions/show.json.jbuilder deleted file mode 100644 index c9efd3b..0000000 --- a/app/views/sessions/show.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.extract! @session, :id, :user_id, :token, :created_at, :updated_at diff --git a/app/views/teams/show.html.erb b/app/views/teams/show.html.erb index 5b18d33..ab49d65 100644 --- a/app/views/teams/show.html.erb +++ b/app/views/teams/show.html.erb @@ -1,4 +1,2 @@ -<p id="notice"><%= notice %></p> - <%= link_to 'Edit', edit_team_path(@team) %> | <%= link_to 'Back', teams_path %> diff --git a/app/views/tournaments/_form.html.erb b/app/views/tournaments/_form.html.erb index 340efab..f53927d 100644 --- a/app/views/tournaments/_form.html.erb +++ b/app/views/tournaments/_form.html.erb @@ -1,49 +1,108 @@ -<%= form_for(@tournament) do |f| %> - <% if @tournament.errors.any? %> - <div id="error_explanation"> - <h2><%= pluralize(@tournament.errors.count, "error") %> prohibited this tournament from being saved:</h2> - - <ul> - <% @tournament.errors.full_messages.each do |msg| %> - <li><%= msg %></li> - <% end %> - </ul> - </div> - <% end %> - - <div class="field"> - <%= f.label :game_id %><br> - <%= f.text_field :game_id %> - </div> - <div class="field"> - <%= f.label :status %><br> - <%= f.number_field :status %> - </div> - <div class="field"> - <%= f.label :name %><br> - <%= f.text_field :name %> - </div> - <div class="field"> - <%= f.label :min_players_per_team %><br> - <%= f.number_field :min_players_per_team %> - </div> - <div class="field"> - <%= f.label :max_players_per_team %><br> - <%= f.number_field :max_players_per_team %> - </div> - <div class="field"> - <%= f.label :min_teams_per_match %><br> - <%= f.number_field :min_teams_per_match %> - </div> - <div class="field"> - <%= f.label :max_teams_per_match %><br> - <%= f.number_field :max_teams_per_match %> - </div> - <div class="field"> - <%= f.label :scoring_method %><br> - <%= f.text_field :scoring_method %> - </div> - <div class="actions"> - <%= f.submit %> - </div> +<%= render "common/error_messages", :target => @tournament %> +<fieldset> + <legend>Game Type</legend> + <%= form_for(@tournament, url: new_tournament_path, method: "get") do |f| %> + <p> + <%= f.label :game_id, "Select a Game Type" %> + <%= f.select(:game_id, Game.all.map{|game| [game.name, game.id]}) %> + <%= f.submit("Select") %> + </p> + <% end %> + +</fieldset> +<% if @tournament.game %> + <%= form_for(@tournament, url: tournaments_path, method: "post") do |f| %> + <fieldset> + <legend>Attributes</legend> + + <%= f.hidden_field(:game_id) %> + <p> + <%= f.label :name %> + <%= f.text_field :name %> + </p> + + <table> + <tbody> + <tr> + <td></td> + <th>Minimum</th> + <th>Maximum</th> + </tr> + <tr> + <th>Players per Team: </th> + <td><%= f.text_field(:min_players_per_team, type: :number, min: 1) %></td> + <td><%= f.text_field(:max_players_per_team, type: :number, min: 1) %></td> + </tr> + <tr> + <th>Teams per Match: </th> + <td><%= f.text_field(:min_teams_per_match, type: :number, min: 1) %></td> + <td><%= f.text_field(:max_teams_per_match, type: :number, min: 1) %></td> + </tr> + </tbody> + </table> + + <p> + <%= f.label :scoring_method, :scoring_method.to_s.titleize %> + <%= f.select(:scoring_method, @tournament.scoring_methods.map{|method| [method.humanize.titleize, method]}) %> + </p> + </fieldset> + + <fieldset> + <legend>Settings</legend> + <%= f.fields_for :settings do |setting_fields| %> + <% @tournament.tournament_settings.each do |setting| %> + <p> + <%= setting_fields.label setting.name, setting.name.to_s.titleize %> + <br> + <% case setting.vartype %> + <% when 0 %> + <%= setting_fields.text_field( setting.name ) %> + <% when 1 %> + <%= setting_fields.text_area( setting.name ) %> + <% when 2 %> + <ul> + <% setting.type_opt.split(',').each do |option|%> + <li><label><%= setting_fields.radio_button( setting.name, option ) %><%= option.humanize.titleize %></label></li> + <% end %> + </ul> + <% when 3 %> + <ul> + <% setting.type_opt.split(',').each do |option|%> + <li><label><%= check_box_tag("tournament[settings][#{setting.name}][]", option, setting.value.split(',').include?(option)) %><%= option.humanize.titleize %></label></li> + <% end %> + </ul> + <% when 4 %> + <%= setting_fields.radio_button( setting.name, "true" ) %> <b>True</b> + <%= setting_fields.radio_button( setting.name, "false" ) %> <b>False</b> + <% when 5 %> + <%= setting_fields.select( setting.name, setting.type_opt.split(',').collect {|opt| opt.humanize.titleize} ) %> + <% end %> + </p> + <% end %> + <% end %> + </fieldset> + + <%= f.fields_for :stages do |stages_fields| %> + <fieldset> + <legend>Stages</legend> + <label for="num_stages">Number of Tournament Stages</label> + <input type="number" name="num_stages" min="1" value="<%= params[:num_stages].to_i %>"> + <%# stage_fields.submit("Set Stages") %> + <% for i in 1..(params[:num_stages].to_i) do %> + <%= stages_fields.fields_for i.to_s do |stage_fields| %> + <fieldset> + <legend>Stage <%= i %></legend> + <%= stage_fields.label :scheduling_method, :scheduling_method.to_s.titleize %> + <%= stage_fields.select(:scheduling_method, @tournament.scheduling_methods.map{|method| [method.humanize.titleize, method]}) %> + <%= stage_fields.label :seeding_method, :seeding_method.to_s.titleize %> + <%= stage_fields.select(:seeding_method, @tournament.seeding_methods.map{|method| [method.humanize.titleize, method]}) %> + </fieldset> + <% end %> + <% end %> + </fieldset> + <% end %> + + <%= f.submit %> + + <% end %> <% end %> diff --git a/app/views/tournaments/index.html.erb b/app/views/tournaments/index.html.erb index 7bf8aa0..06e1b25 100644 --- a/app/views/tournaments/index.html.erb +++ b/app/views/tournaments/index.html.erb @@ -1,41 +1,24 @@ -<h1>Listing tournaments</h1> +<h1>Listing Tournaments</h1> -<table> - <thead> - <tr> - <th>Game</th> - <th>Status</th> - <th>Name</th> - <th>Min players per team</th> - <th>Max players per team</th> - <th>Min teams per match</th> - <th>Max teams per match</th> - <th>Scoring method</th> - <th></th> - <th></th> - <th></th> - </tr> - </thead> +<div id="tournament-list"> + <% if @tournaments.length > 0 %> - <tbody> - <% @tournaments.each do |tournament| %> - <tr> - <td><%= tournament.game %></td> - <td><%= tournament.status %></td> - <td><%= tournament.name %></td> - <td><%= tournament.min_players_per_team %></td> - <td><%= tournament.max_players_per_team %></td> - <td><%= tournament.min_teams_per_match %></td> - <td><%= tournament.max_teams_per_match %></td> - <td><%= tournament.scoring_method %></td> - <td><%= link_to 'Show', tournament %></td> - <td><%= link_to 'Edit', edit_tournament_path(tournament) %></td> - <td><%= link_to 'Destroy', tournament, method: :delete, data: { confirm: 'Are you sure?' } %></td> - </tr> - <% end %> - </tbody> -</table> + <%# Each tournament has a div for its listing %> + <% @tournaments.each do |t| %> + <%= render "common/show_tournament", :target => t %> + <% end %> -<br> + <% else %> -<%= link_to 'New Tournament', new_tournament_path %> + <p class="no-entries"> No tournaments going on right now... + <% if current_user.can?(:create_tournament) %> + Why not start your own? + <% end %> + </p> + + <% end %> +</div> + +<% if current_user.can?(:create_tournament) %> + <div><%= link_to 'New Tournament', new_tournament_path, :class => "btn btn-warning btn-lg" %></div> +<% end %> diff --git a/app/views/tournaments/join.html.erb b/app/views/tournaments/join.html.erb new file mode 100644 index 0000000..1d38d68 --- /dev/null +++ b/app/views/tournaments/join.html.erb @@ -0,0 +1,2 @@ + <%= @user.name %> + diff --git a/app/views/tournaments/new.html.erb b/app/views/tournaments/new.html.erb index 2a60539..9c741e0 100644 --- a/app/views/tournaments/new.html.erb +++ b/app/views/tournaments/new.html.erb @@ -1,4 +1,4 @@ -<h1>New tournament</h1> +<h1>New Tournament</h1> <%= render 'form' %> diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb index ca65ac6..7e3fbae 100644 --- a/app/views/tournaments/show.html.erb +++ b/app/views/tournaments/show.html.erb @@ -1,44 +1,104 @@ -<p id="notice"><%= notice %></p> - -<p> - <strong>Game:</strong> - <%= @tournament.game %> -</p> - -<p> - <strong>Status:</strong> - <%= @tournament.status %> -</p> - -<p> - <strong>Name:</strong> - <%= @tournament.name %> -</p> - -<p> - <strong>Min players per team:</strong> - <%= @tournament.min_players_per_team %> -</p> - -<p> - <strong>Max players per team:</strong> - <%= @tournament.max_players_per_team %> -</p> - -<p> - <strong>Min teams per match:</strong> - <%= @tournament.min_teams_per_match %> -</p> - -<p> - <strong>Max teams per match:</strong> - <%= @tournament.max_teams_per_match %> -</p> - -<p> - <strong>Scoring method:</strong> - <%= @tournament.scoring_method %> -</p> - -<%= link_to 'Edit', edit_tournament_path(@tournament) %> | +<h2 id="tournament-name"> + <%= @tournament.name %> +</h2> + +<div class="progress"> + <%# FIXME: What's up with this? Hardcoded 60%? %> + <%= tag("div", {:id => "prog-bar", :class => "progress-bar progress-bar-warning", :style => "width: " +(@tournament.players.count * 100 / (@tournament.min_players_per_team * @tournament.min_teams_per_match)).to_s + "%", "aria-valuemax" => "100", "aria-valuemin" => "0", "aria-valuenow" => (@tournament.players.count * 100 / (@tournament.min_players_per_team * @tournament.min_teams_per_match)).to_s, "role" => "progressbar"}) %> + <span class="sr-only">60% Complete (warning)</span> + </div> +</div> + +<p id="players-needed"><%= pluralize(@tournament.players.count, "player has", "players have") %> signed up. <%= @tournament.min_players_per_team * @tournament.min_teams_per_match %> needed. </p> + +<div id="tournament-side-params"> + <p> + <strong>Status:</strong> + <% if @tournament.status == 0 %> + Waiting for players... + <% else %> + Started + <% end %> + </p> + + <p> + <strong>Name:</strong> + <%= @tournament.name %> + </p> + + <p> + <strong>Min players per team:</strong> + <%= @tournament.min_players_per_team %> + </p> + + <p> + <strong>Max players per team:</strong> + <%= @tournament.max_players_per_team %> + </p> + + <p> + <strong>Min teams per match:</strong> + <%= @tournament.min_teams_per_match %> + </p> + + <p> + <strong>Max teams per match:</strong> + <%= @tournament.max_teams_per_match %> + </p> + + <p> + <strong>Scoring method:</strong> + <%= @tournament.scoring_method.titleize %> + </p> + + <% @tournament.settings.each do |setting| %> + <p> + <strong><%= setting.name %></strong> + <%= setting.value %> + </p> + <% end %> +</div> + +<div> + <% if @tournament.players.length > 0 %> + <h3>Players Here:</h3> + <ul id="tournament-users"> + <% @tournament.players.each do |p| %> + <li><%= p.user_name %></li> + <% end %> + </ul> + <% else %> + <h3 div="players-needed">Hmmm.... nobody's here yet! You and your friends should join the tournament.</h3> + <% end %> +</div> + +<div class="leave-buttons"> + <%# If user can join, and user hasn't joined already, show the join tournment tag %> + <% if @tournament.joinable_by?(current_user) && !@tournament.players.include?(current_user) %> + <%= form_tag(tournament_path(@tournament), method: "put") do %> + <input type="hidden" name="update_action" value="join"> + <%= submit_tag("Join Tournament") %> + <% end %> + <% elsif @tournament.players.include?(current_user) %> + <%= form_tag(tournament_path(@tournament), method: "put") do %> + <input type="hidden" name="update_action" value="leave"> + <%= submit_tag("Leave Tournament") %> + <% end %> + <% end %> + + <%# If user is the host, let them start the tournment %> + <% if @tournament.hosts.include?(current_user) %> + <%= form_tag(tournament_path(@tournament), method: "put") do %> + <input type="hidden" name="update_action" value="start"> + <% if @tournament.players.count >= @tournament.min_players_per_team * @tournament.min_teams_per_match %> + <%= submit_tag("Start Tournament") %> + <% else %> + <%= submit_tag("Start Tournament", disabled: true) %> + <% end %> + <% end %> + <%= link_to 'Edit', edit_tournament_path(@tournament) %> | + <%= link_to 'Cancel Tournament', @tournament, method: :delete, data: { confirm: 'Are you sure?' } %> + <% end %> +</div> + <%= link_to 'Back', tournaments_path %> diff --git a/app/views/tournaments/standings.html.erb b/app/views/tournaments/standings.html.erb new file mode 100644 index 0000000..a04e132 --- /dev/null +++ b/app/views/tournaments/standings.html.erb @@ -0,0 +1,28 @@ +<% playerscores = @tournament.players.collect {|player| player => @tournament.statistics.where(match: player.matches.last, user: player, name: :score) } %> +<% teams = tournament_stage.matches.collect +{ |match| match.teams.collect { |team| team.id => team.players.collect +{ |player| player.user_name => @tournament.statistics.where(match: player.matches.last, user: player, name: :score } } } %> + +<table> + <tr> + <td>Standings:</td> + <% place = 0 %> + <% playerscores.sort {|player1, player2| playerscores[player1] <=> playerscores[player2] }.each |player| %> + <td><%= place.to_s + ":" %> <%= player.user_name %></td> + <% place += 1%> + <% end %> + </tr> +</table> + +<% teams.each do |team| %> + <table> + <tr> + <td>Standings:</td> + <% place = 0 %> + <% team.values.sort {|player1, player2| playerscores[player1] <=> playerscores[player2] }.each |player| %> + <td><%= place.to_s + ":" %> <%= player.user_name %></td> + <% place += 1%> + <% end %> + </tr> + </table> +<% end %>
\ No newline at end of file diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index 4d28738..1feebf8 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -1,29 +1,45 @@ <%= form_for(@user) do |f| %> - <% if @user.errors.any? %> - <div id="error_explanation"> - <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2> - - <ul> - <% @user.errors.full_messages.each do |msg| %> - <li><%= msg %></li> - <% end %> - </ul> - </div> - <% end %> + <%= render "common/error_messages", :target => @user %> <div class="field"> <%= f.label :name %><br> <%= f.text_field :name %> </div> + <div class="field"> <%= f.label :email %><br> - <%= f.text_field :email %> + <%= f.text_field(:email, type: "email") %> </div> + <div class="field"> <%= f.label :user_name %><br> <%= f.text_field :user_name %> </div> + + <div> + <%= f.label(:password, "New Password (or use old)") %><br> + <%= f.password_field :password %> + </div> + <div> + <%= f.label(:password_confirmation, "Confirm Password") %><br> + <%= f.password_field :password_confirmation %> + </div> + + <% if current_user.can? :edit_permissions %> + <fieldset> + <legend>User permissions</legend> + <ul> + <%= fields_for "user[abilities]", @user.abilities do |abilities_fields| %> + <% @user.abilities.keys.each do |ability| %> + <li><label><%= abilities_fields.check_box(ability) %> <%= ability.to_s.humanize %></label></li> + <% end %> + <% end %> + </ul> + </fieldset> + <% end %> + <div class="actions"> <%= f.submit %> </div> + <% end %> diff --git a/app/views/users/already_signed_in.html.erb b/app/views/users/already_signed_in.html.erb new file mode 100644 index 0000000..04b4248 --- /dev/null +++ b/app/views/users/already_signed_in.html.erb @@ -0,0 +1 @@ +<h1>You are currently signed in</h1> diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 99bd4cc..52f32a2 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -3,4 +3,4 @@ <%= render 'form' %> <%= link_to 'Show', @user %> | -<%= link_to 'Back', users_path %> +<%= link_to 'Users', users_path %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 3692112..e4251cd 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -1,8 +1,9 @@ <h1>Listing users</h1> -<table> +<table class="table table-hover"> <thead> <tr> + <th>Username</th> <th>Name</th> <th>Email</th> <th>User name</th> @@ -15,8 +16,9 @@ <tbody> <% @users.each do |user| %> <tr> + <td><%= image_tag('http://www.gravatar.com/avatar/' + Digest::MD5.hexdigest(user.email) + '?s=30&d=identicon') %> <%= link_to("#{user.user_name}", user, nil) %></td> <td><%= user.name %></td> - <td><%= user.email %></td> + <td> ******* </td> <td><%= user.user_name %></td> <td><%= link_to 'Show', user %></td> <td><%= link_to 'Edit', edit_user_path(user) %></td> diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index efc0404..5c88945 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -1,5 +1,34 @@ -<h1>New user</h1> +<h1> Sign Up </h1> -<%= render 'form' %> +<%= form_for @user do |f| %> + <%= render "common/error_messages", :target => @user %> + <p> + <%= f.label :name %><br> + <%= f.text_field :name %> + </p> + <p> + <%= f.label :email %><br> + <%= f.text_field(:email, type: "email") %> + </p> + <p> + <%= f.label :user_name %><br> + <%= f.text_field :user_name %> + </p> + <p> + <%= f.label :password %><br> + <%= f.password_field :password %> + </p> + <p> + <%= f.label(:password_confirmation, "Confirm Password") %><br> + <%= f.password_field :password_confirmation %> + </p> + <p> + <%= show_simple_captcha %> + + <%= f.submit("Be a Leaguer", :class => "signup") %> + </p> +<% end %> + + +<%= link_to 'Already Have an Account? Log in', new_session_path, :class => "signin" %> -<%= link_to 'Back', users_path %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 9455a3c..b247b7d 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -1,8 +1,8 @@ -<p id="notice"><%= notice %></p> + +<h1> <%= @user.user_name %>'s Profile </h1> <p> - <strong>Name:</strong> - <%= @user.name %> + <%= image_tag 'http://www.gravatar.com/avatar/' + Digest::MD5.hexdigest(@user.email) + '?s=100&d=identicon' %> </p> <p> @@ -11,9 +11,47 @@ </p> <p> - <strong>User name:</strong> + <strong>Preferred name:</strong> <%= @user.user_name %> </p> +<p> + <strong>Relationship Status:</strong> + too single +</p> + + +<p> +<% if @user.remote_usernames[0].nil? %> + <%= form_for @user do |f| %> + <label>Have a League of Legends Account? + <input type=text name="user[remote_usernames][League of Legends]"> + </label> + <%= f.submit "Add Username", :class => 'signup' %> + <% end %> +<% end %> +</p> + + +<div class="row"> + <div class="col-md-6"> + <h3> Recent Tournaments Played </h3> + <ul> + <% @user.tournaments_played.each do |t| %> + <li><%= t.name %></li> + <% end %> + </ul> + </div> + <div class="col-md-6"> + <h3> Recent Tournaments Hosted </h3> + <% if @user.tournaments_hosted.count == 0 %> <p> <%= @user.user_name %> has never hosted a tournament </p> <%end %> + <ul> + <% @user.tournaments_hosted.each do |t| %> + <li><%= t.name %></li> + <% end %> + </ul> + </div> +</div> + <%= link_to 'Edit', edit_user_path(@user) %> | -<%= link_to 'Back', users_path %> +<%= link_to 'All Users', users_path %> |