summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/images/ChessBlackKnightIcon.pngbin0 -> 893 bytes
-rw-r--r--app/assets/images/LOLG_icon_large.gifbin0 -> 8207 bytes
-rw-r--r--app/assets/stylesheets/application.css7
-rw-r--r--app/assets/stylesheets/scaffolds.css.scss13
-rw-r--r--app/assets/stylesheets/static.css.scss3
-rw-r--r--app/controllers/matches_controller.rb11
-rw-r--r--app/controllers/search_controller.rb13
-rw-r--r--app/controllers/tournaments_controller.rb25
-rw-r--r--app/models/tournament_stage.rb4
-rw-r--r--app/models/user.rb2
-rw-r--r--app/views/common/_show_tournament.html.erb32
-rw-r--r--app/views/layouts/application.html.erb12
-rw-r--r--app/views/matches/index.html.erb2
-rw-r--r--app/views/matches/show.html.erb4
-rw-r--r--app/views/search/go.html.erb24
-rw-r--r--app/views/tournaments/index.html.erb38
16 files changed, 116 insertions, 74 deletions
diff --git a/app/assets/images/ChessBlackKnightIcon.png b/app/assets/images/ChessBlackKnightIcon.png
new file mode 100644
index 0000000..6bcffe6
--- /dev/null
+++ b/app/assets/images/ChessBlackKnightIcon.png
Binary files differ
diff --git a/app/assets/images/LOLG_icon_large.gif b/app/assets/images/LOLG_icon_large.gif
new file mode 100644
index 0000000..1f0fa43
--- /dev/null
+++ b/app/assets/images/LOLG_icon_large.gif
Binary files differ
diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css
index ebb963c..677791c 100644
--- a/app/assets/stylesheets/application.css
+++ b/app/assets/stylesheets/application.css
@@ -22,10 +22,3 @@
padding: 0px 5px;
}
-footer {
- clear: both;
- margin: 0 auto;
- margin-top: 10px;
- color: white;
- width: 90%;
-} \ No newline at end of file
diff --git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss
index 509cb19..e8fe9c5 100644
--- a/app/assets/stylesheets/scaffolds.css.scss
+++ b/app/assets/stylesheets/scaffolds.css.scss
@@ -19,7 +19,7 @@ body {
height: 100%;
}
-h1, h2, h3, h4, h5, p{
+h1, h2, h3, h4, h5, p, li{
color: $orange;
}
@@ -96,20 +96,21 @@ div {
.wrapper {
width: 80%;
- margin: 0 auto;
margin-top: 10px;
+ min-height: 80%;
+ height: auto !important;
+ height: 99%;
+ margin: 0 auto;
}
button, input[type="submit"] {
@extend .btn;
}
-
-
footer {
clear: both;
border-top: solid 1px $orange;
- padding-top: 10px;
text-align: center;
- bottom: 0;
+ margin: 0 auto;
+ width: 90%;
} \ No newline at end of file
diff --git a/app/assets/stylesheets/static.css.scss b/app/assets/stylesheets/static.css.scss
index 14443f3..6732370 100644
--- a/app/assets/stylesheets/static.css.scss
+++ b/app/assets/stylesheets/static.css.scss
@@ -5,7 +5,8 @@
.jumbotron {
background-color: #FFF;
box-shadow: 1px 1px 20px black;
-
+ width: 93%;
+
p {
line-height: 1.5em;
}
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb
index 59f376a..b50aca5 100644
--- a/app/controllers/matches_controller.rb
+++ b/app/controllers/matches_controller.rb
@@ -1,6 +1,4 @@
class MatchesController < ApplicationController
- before_action :set_tournament, only: [:index, :update]
-
require 'httparty'
require 'json'
require 'delayed_job'
@@ -118,7 +116,7 @@ class MatchesController < ApplicationController
# GET /tournaments/1/matches/1
# GET /tournaments/1/matches/1.json
def show
- if Tournament.find_by_id(@match.tournament_id).game_id == 1
+ if @match.tournament_stage.tournament.game_id == 1
file_blue = "blue.yaml"
file_purple = "purple.yaml"
@blue2 = YAML.load_file(file_blue)
@@ -235,11 +233,8 @@ class MatchesController < ApplicationController
private
# Use callbacks to share common setup or constraints between actions.
def set_match
- set_tournament
- @match = @tournament.matches.find(params[:id])
- end
- def set_tournament
- @tournament = Tournament.find(params[:tournament_id])
+ @match = Match.find(params[:id])
+ @tournament = @match.tournament_stage.tournament
end
# Never trust parameters from the scary internet, only allow the white list through.
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index ee61487..51aee9e 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -1,2 +1,15 @@
class SearchController < ApplicationController
+
+ def go
+ @query = params[:query]
+
+ if (@query.nil?) then
+ return
+ end
+
+ @tournaments = Tournament.where("name LIKE '%#{@query}%'")
+ @players = User.where("name LIKE '%#{@query}%'")
+
+ end
+
end
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index 4b0e1af..03dc5b8 100644
--- a/app/controllers/tournaments_controller.rb
+++ b/app/controllers/tournaments_controller.rb
@@ -95,17 +95,24 @@ class TournamentsController < ApplicationController
end
when "start"
check_permission(:edit, @tournament)
- @tournament.status = 1
- ok =
- @tournament.save &&
- @tournament.tournament_stages.create(scheduling: "elimination") &&
- @tournament.tournament_stages.first.create_matches
respond_to do |format|
- if ok
- format.html { redirect_to @tournament, notice: 'You have started this tournament.' }
- format.json { head :no_content }
+ if @tournament.status == 0
+ @tournament.status = 1
+ success = true
+ ActiveRecord::Base.transaction do
+ success &= @tournament.save &&
+ success &= @tournament.tournament_stages.create(scheduling: "elimination")
+ success &= @tournament.tournament_stages.first.create_matches
+ end
+ if success
+ format.html { redirect_to @tournament, notice: 'You have started this tournament.' }
+ format.json { head :no_content }
+ else
+ format.html { redirect_to @tournament, notice: "You don't have permission to start this tournament." }
+ format.json { render json: "Permission denied", status: :forbidden }
+ end
else
- format.html { redirect_to @tournament, notice: "You don't have permission to start this tournament." }
+ format.html { redirect_to @tournament, notice: "This tournament is not in a state that it can be started." }
format.json { render json: "Permission denied", status: :forbidden }
end
end
diff --git a/app/models/tournament_stage.rb b/app/models/tournament_stage.rb
index a3ee7df..d5a5211 100644
--- a/app/models/tournament_stage.rb
+++ b/app/models/tournament_stage.rb
@@ -17,9 +17,9 @@ class TournamentStage < ActiveRecord::Base
@scheduling.create_matches
end
- def to_svg
+ def to_svg(current_user)
set_scheduling
- return @scheduling.graph
+ return @scheduling.graph(current_user)
end
def pair
diff --git a/app/models/user.rb b/app/models/user.rb
index 57746b7..aacd7b1 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -10,6 +10,8 @@ class User < ActiveRecord::Base
apply_simple_captcha
+ acts_as_messageable
+
before_save { self.email = email.downcase }
before_save { self.user_name = user_name }
diff --git a/app/views/common/_show_tournament.html.erb b/app/views/common/_show_tournament.html.erb
new file mode 100644
index 0000000..89d8f53
--- /dev/null
+++ b/app/views/common/_show_tournament.html.erb
@@ -0,0 +1,32 @@
+<div class="row tournament-listing">
+ <div class="col-md-2 col-sm-3 col-xs-6"><%= image_tag ('http://www.gravatar.com/avatar/' + Digest::MD5.hexdigest(target.hosts.first.email) + '?s=100&d=mm') %></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" style="margin-left:2%;">
+ <div class="col-md-4 host">
+ Hosted by: <%= target.hosts.first.name %>
+ </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) %>
+ <%= form_tag(tournament_path(target), method: "put") do %>
+ <input type="hidden" name="update_action" value="join">
+ <%= submit_tag("Join")%>
+ <% end %>
+ <% else %>
+ <p style="margin-top:10px;"> You've signed up for this tournament! </p>
+ <% end %>
+ <% end %>
+ </div>
+</div> \ No newline at end of file
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index e6b5b25..fb5c1c5 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -13,15 +13,20 @@
BetterDragSort.makeListSortable(document.getElementById("boxes"));
};
</script>
-<header><nav>
+<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, nil, :placeholder => "Search") %>
- <%= submit_tag("Go") %>
+ <%= submit_tag("Go", :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" %>
@@ -34,7 +39,8 @@
<%= link_to "Sign up", new_user_path, :class => "signup" %>
<% end %>
</div>
-</nav></header>
+ </nav>
+</header>
<% if notice %><div id="notice"><p><%= notice %></p></div><% end %>
diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb
index 058477a..fda8582 100644
--- a/app/views/matches/index.html.erb
+++ b/app/views/matches/index.html.erb
@@ -37,5 +37,5 @@
<br>
<% @tournament.stages_ordered.keys.sort.each do |stage_key| %>
- <div class="graph"><%= raw @tournament.stages_ordered[stage_key].to_svg %></div>
+ <div class="graph"><%= raw @tournament.stages_ordered[stage_key].to_svg(current_user) %></div>
<% end %>
diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb
index e7fe791..a1d82a3 100644
--- a/app/views/matches/show.html.erb
+++ b/app/views/matches/show.html.erb
@@ -7,10 +7,6 @@
<%= @match.tournament_stage %>
</p>
-<p>
- <strong>Name:</strong>
- <%= @match.name %>
-</p>
<!--
Match Status 0 => Created, waiting to start
Match Status 1 => Match is running, waiting to finish
diff --git a/app/views/search/go.html.erb b/app/views/search/go.html.erb
new file mode 100644
index 0000000..324fa48
--- /dev/null
+++ b/app/views/search/go.html.erb
@@ -0,0 +1,24 @@
+
+<%# Show search results if a query was not nill %>
+<% if !@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_player", :target => p %>
+ <% end %>
+
+ <% end %>
+<% end %> \ No newline at end of file
diff --git a/app/views/tournaments/index.html.erb b/app/views/tournaments/index.html.erb
index eef9577..06e1b25 100644
--- a/app/views/tournaments/index.html.erb
+++ b/app/views/tournaments/index.html.erb
@@ -2,48 +2,20 @@
<div id="tournament-list">
<% if @tournaments.length > 0 %>
+
<%# Each tournament has a div for its listing %>
<% @tournaments.each do |t| %>
- <div class="row tournament-listing">
- <div class="col-md-2 col-sm-3 col-xs-6"><%= image_tag 'http://www.gravatar.com/avatar/' + Digest::MD5.hexdigest(t.hosts.first.email) + '?s=100&d=mm' %></div>
- <div class="col-md-8 col-sm-7 col-xs-6">
- <%# "header" %>
- <%= link_to(t) do %><h3><%= t.name %></h3><% end %>
- <div class="row" style="margin-left:2%;">
- <div class="col-md-4 host">
- Hosted by: <%= t.hosts.first.name %>
- </div>
- <div class="col-md-4 things">
- <p> Players per team: <%= t.min_players_per_team %></p>
- <p> Players signed up: <%= t.players.count %> </p>
- </div>
- <div class="col-md-4 things">
- <p> <%= (t.randomized_teams)? "Teams are Random" : "Teams are Chosen" %></p>
- <p> Players signed up: <%= t.players.count %> </p>
- </div>
- </div>
- </div>
- <div class="col-md-2 col-sm-2 col-xs-2">
- <% if signed_in? %>
- <% if !t.players.include?(current_user) %>
- <%= form_tag(tournament_path(t), method: "put") do %>
- <input type="hidden" name="update_action" value="join">
- <%= submit_tag("Join")
- %>
- <% end %>
- <% else %>
- <p style="margin-top:10px;"> You've signed up for this tournament! </p>
- <% end %>
- <% end %>
- </div>
- </div>
+ <%= render "common/show_tournament", :target => t %>
<% end %>
+
<% else %>
+
<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>