summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authornfoy <nfoy@purdue.edu>2014-04-28 19:39:36 -0400
committernfoy <nfoy@purdue.edu>2014-04-28 19:39:36 -0400
commit87530c5bca7062ed18badf98bcb4b63529607ecd (patch)
tree29f2da66af99fbf05726ae9f4fa4bd78d910a763 /app
parent3a4412f08bed438ebf14f6cdfa5bb6eb4d239138 (diff)
parent8dade78c49ad03085166c41d8b334a6ade3a287e (diff)
Merge branch 'master' of https://github.com/LukeShu/leaguer
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/application/scaffolds.css.scss4
-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.rb16
-rw-r--r--app/models/match.rb7
-rw-r--r--app/models/statistic.rb23
7 files changed, 87 insertions, 27 deletions
diff --git a/app/assets/stylesheets/application/scaffolds.css.scss b/app/assets/stylesheets/application/scaffolds.css.scss
index ae26907..703e3d6 100644
--- a/app/assets/stylesheets/application/scaffolds.css.scss
+++ b/app/assets/stylesheets/application/scaffolds.css.scss
@@ -115,6 +115,10 @@ fieldset {
}
}
+form ul {
+ list-style: none;
+}
+
a, button, input[type="submit"] {
@extend .btn;
&.user { @extend .btn-info; }
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..5745ac9 100644
--- a/app/controllers/matches_controller.rb
+++ b/app/controllers/matches_controller.rb
@@ -45,18 +45,10 @@ class MatchesController < ApplicationController
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
+ # 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")
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