summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authortkimia <tkimia@purdue.edu>2014-04-28 20:03:34 -0400
committertkimia <tkimia@purdue.edu>2014-04-28 20:03:34 -0400
commit1a6450ec1f5c538eff6dbf6f91582c47fb16e3cc (patch)
treedc1a9455fedb082a3be0bb36ac19aae5cbbe39fd /app
parent3992a2e52a950c644cfe56bc23991e3a03166568 (diff)
parent3ab30900798a838b399d06f28251b6cdd82a94de (diff)
Merge branch 'master' of https://github.com/LukeShu/leaguer
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/application/scaffolds.css.scss16
-rw-r--r--app/assets/stylesheets/patch54
-rw-r--r--app/assets/stylesheets/servers.css.scss5
-rw-r--r--app/assets/stylesheets/users.css.scss5
-rw-r--r--app/controllers/matches_controller.rb21
-rw-r--r--app/models/match.rb7
-rw-r--r--app/models/statistic.rb23
-rw-r--r--app/views/alerts/new.html.erb2
-rw-r--r--app/views/pms/index.html.erb15
9 files changed, 105 insertions, 43 deletions
diff --git a/app/assets/stylesheets/application/scaffolds.css.scss b/app/assets/stylesheets/application/scaffolds.css.scss
index ae26907..4f0c781 100644
--- a/app/assets/stylesheets/application/scaffolds.css.scss
+++ b/app/assets/stylesheets/application/scaffolds.css.scss
@@ -39,9 +39,6 @@ html {
form.search {
@extend .navbar-form;
float: right;
- input[type="submit"] {
- @extend .btn-warning;
- }
input[type="text"], input[type="search"] {
background-color: #303030;
border: 2px solid #ED9C28;
@@ -51,6 +48,9 @@ html {
height: 30px;
padding: 0px 5px;
}
+ input[type="submit"] {
+ @extend .btn-warning;
+ }
}
}
@@ -77,7 +77,7 @@ html {
clear: both;
border-top: solid 1px $orange;
text-align: center;
- margin: 0 auto;
+ margin: 1em auto 0;
width: 90%;
}
}
@@ -115,6 +115,10 @@ fieldset {
}
}
+form ul {
+ list-style: none;
+}
+
a, button, input[type="submit"] {
@extend .btn;
&.user { @extend .btn-info; }
@@ -144,7 +148,7 @@ input, textarea{
border: 3px inset #A5A5A5;
padding: 8px;
- color: $orange !important;
+ color: $orange;
background: rgba(0,0,0,0.5);
margin: 0 0 5px 0;
}
@@ -153,7 +157,7 @@ select {
background-color: #333;
padding: 5px;
border: none;
- color: $orange !important;
+ color: $orange;
}
pre {
diff --git a/app/assets/stylesheets/patch b/app/assets/stylesheets/patch
new file mode 100644
index 0000000..0997417
--- /dev/null
+++ b/app/assets/stylesheets/patch
@@ -0,0 +1,54 @@
+commit 10f01633176ca214e7aec6be61ed3344035ec77e
+Merge: 99dff7e 20f7b74
+Author: webb39 <webb39@purdue.edu>
+Date: Mon Mar 10 20:41:27 2014 -0400
+
+ Merge branch 'master' of https://github.com/LukeShu/Leaguer
+
+commit 99dff7e01a65986338824804651367e97a0d1923
+Merge: 1f00553 f0c03cd
+Author: webb39 <webb39@purdue.edu>
+Date: Mon Mar 10 20:41:16 2014 -0400
+
+ Merge https://github.com/LukeShu/Leaguer
+
+ Conflicts:
+ doc/Sprint1-Retrospective.md
+
+commit 1f00553cbc5d281efe3ac1b434d16537a17bc969
+Author: webb39 <webb39@purdue.edu>
+Date: Mon Mar 10 20:36:31 2014 -0400
+
+ added match controller information
+
+diff --git a/doc/Sprint1-Retrospective.md b/doc/Sprint1-Retrospective.md
+index 3da3669..ae1b07a 100644
+--- a/doc/Sprint1-Retrospective.md
++++ b/doc/Sprint1-Retrospective.md
+@@ -97,13 +97,24 @@ f
+ f
+
+ ## Login (UI) {#login-ui}
+-
++
+ ## Tournament settings {#tourney-settings}
+-
++
+ ## Tournament registration {#tourney-registration}
+
+ ## Match controller {#match-controller}
+
++The Match Controller creates the separate matches for a specific tournament.
++When a tournament is started, it begins with an initial match that contains
++no players. Currently, a player must join a match by entering the specific
++tournament (by clicking the 'show' button on the tournament),
++then they must enter the match (again by clicking the 'show' button but this
++time on the match they desire to participate in) and then finally clicking
++the 'join' button. This updates the match with the user as a participant in
++the matc and then finally clicking the 'join' button. This updates the match
++with the user as a participant in the match. A match can also be destroyed
++by clicking the 'delete' button on the no longer desired match on the page.
++
+ ## Permissions system {#permissions}
+
+ ## Tournament view {#tourney-view}
diff --git a/app/assets/stylesheets/servers.css.scss b/app/assets/stylesheets/servers.css.scss
index bb20956..e69de29 100644
--- a/app/assets/stylesheets/servers.css.scss
+++ b/app/assets/stylesheets/servers.css.scss
@@ -1,5 +0,0 @@
-.edit_server {
- li {
- list-style: none;
- }
-}
diff --git a/app/assets/stylesheets/users.css.scss b/app/assets/stylesheets/users.css.scss
index 790aa5f..e69de29 100644
--- a/app/assets/stylesheets/users.css.scss
+++ b/app/assets/stylesheets/users.css.scss
@@ -1,5 +0,0 @@
-.new_user, .edit_user {
- li {
- list-style: none;
- }
-}
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb
index bed06ba..81ffcd8 100644
--- a/app/controllers/matches_controller.rb
+++ b/app/controllers/matches_controller.rb
@@ -44,19 +44,11 @@ class MatchesController < ApplicationController
end
when 2
# Started, waiting to finish
- @match.handle_sampling(params)
- if @match.finished?
- @match.status = 3
- respond_to do |format|
- if @match.save
- format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Match has finished.' }
- format.json { head :no_content }
- else
- format.html { render action: 'show' }
- format.json { render json: @match.errors, status: :unprocessable_entity }
- end
- end
- return
+ @match.handle_sampling(@current_user, params)
+ # The @match.status will be updated by Statistic's after_save hook
+ respond_to do |format|
+ format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Match has finished.' }
+ format.json { head :no_content }
end
when 3
if (@tournament.hosts.include? current_user) and (params[:update_action] == "start")
@@ -77,8 +69,9 @@ class MatchesController < ApplicationController
end
return
end
+ else
+ redirect_to tournament_match_path(@tournament, @match)
end
- redirect_to tournament_match_path(@tournament, @match)
end
private
diff --git a/app/models/match.rb b/app/models/match.rb
index 4c7acbf..219e662 100644
--- a/app/models/match.rb
+++ b/app/models/match.rb
@@ -5,9 +5,6 @@ class Match < ActiveRecord::Base
belongs_to :winner, class_name: "Team"
- def setup()
- end
-
def finished?
ok = true
tournament_stage.scoring_method.stats_needed.each do |stat|
@@ -59,7 +56,7 @@ class Match < ActiveRecord::Base
method_class = "Sampling::#{method_name.camelcase}".constantize
needed.each do |stat|
data[stat] ||= {}
- data[stat][method] = method_class.can_get?(user, stat)
+ data[stat][method_class] = method_class.can_get?(stat)
end
end
@@ -83,7 +80,7 @@ class Match < ActiveRecord::Base
if @method_classes.nil?
data = Set.new
figure_sampling_methods.each do |stat,method|
- data.push(method)
+ data.add(method)
end
@method_classes = data
end
diff --git a/app/models/statistic.rb b/app/models/statistic.rb
index 341fd9d..b4608b8 100644
--- a/app/models/statistic.rb
+++ b/app/models/statistic.rb
@@ -1,4 +1,27 @@
class Statistic < ActiveRecord::Base
belongs_to :user
belongs_to :match
+
+ def value
+ begin
+ return JSON.parse(self.json_value)
+ rescue
+ return {}
+ end
+ end
+
+ def value=(v)
+ self.json_value = v.to_json
+ end
+
+ after_save :update_match
+ def update_match
+ if (self.name == "win") and (self.value > 0)
+ self.match.winner = self.match.teams.find{|t| t.users.include? self.user}
+ end
+ if (self.match.status == 2) and (self.match.finished?)
+ self.match.status = 3
+ end
+ self.match.save
+ end
end
diff --git a/app/views/alerts/new.html.erb b/app/views/alerts/new.html.erb
index 6d04589..db5af2d 100644
--- a/app/views/alerts/new.html.erb
+++ b/app/views/alerts/new.html.erb
@@ -2,4 +2,4 @@
<%= render 'form' %>
-<%= link_to 'Back', alerts_path %>
+<%= link_to 'See past Alerts', alerts_path %>
diff --git a/app/views/pms/index.html.erb b/app/views/pms/index.html.erb
index fec6db2..c823efb 100644
--- a/app/views/pms/index.html.erb
+++ b/app/views/pms/index.html.erb
@@ -97,14 +97,12 @@
<table>
<col width="150">
- <col width="250">
- <col width="300">
+ <col width="650">
<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| %>
@@ -112,7 +110,7 @@
<% if conversation.is_read?(current_user) || receipts.last.message.sender == current_user %>
<% message = receipts.last.message %>
<tr>
- <% if conversation.subject == "Pay Attention!" %>
+ <% if conversation.subject == "Pay Attention!" && message.sender != current_user %>
<td>
<% people = conversation.participants %>
<% people.each do |person| %>
@@ -121,8 +119,7 @@
<% end %>
<% end %>
</td>
- <td><%= truncate(conversation.subject, length: 30) %></td>
- <td><%= truncate(message.body, length: 42) %></td>
+ <td><%= truncate(message.body, length: 80) %></td>
<td><%= link_to 'View', @pms.find_by(conversation: conversation) %></td>
<% end %>
</tr>
@@ -133,4 +130,8 @@
<% #end %>
</tbody>
-</table> \ No newline at end of file
+</table>
+
+<br>
+<br>
+<br> \ No newline at end of file