From 5a7f5f6bc00d2abe2d5cd71363d4d5116bf4de51 Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Mon, 28 Apr 2014 18:27:52 -0400 Subject: Make Statistic#value a rich (JSON) object --- app/models/statistic.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'app') 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 -- cgit v1.2.3 From cd19b2591a52ac604632a70929448ee5e78c2568 Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Mon, 28 Apr 2014 18:29:01 -0400 Subject: Misc fixes. (This commit is from Luke on Andrew's box) --- app/controllers/matches_controller.rb | 16 ++++------------ app/models/match.rb | 7 ++----- 2 files changed, 6 insertions(+), 17 deletions(-) (limited to 'app') 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 -- cgit v1.2.3 From 8dade78c49ad03085166c41d8b334a6ade3a287e Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 28 Apr 2014 19:36:30 -0400 Subject: Hide the bullets for all unordered lists in forms --- .../stylesheets/application/scaffolds.css.scss | 4 ++ app/assets/stylesheets/patch | 54 ++++++++++++++++++++++ app/assets/stylesheets/servers.css.scss | 5 -- app/assets/stylesheets/users.css.scss | 5 -- 4 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 app/assets/stylesheets/patch (limited to 'app') 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 +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 +Date: Mon Mar 10 20:41:16 2014 -0400 + + Merge https://github.com/LukeShu/Leaguer + + Conflicts: + doc/Sprint1-Retrospective.md + +commit 1f00553cbc5d281efe3ac1b434d16537a17bc969 +Author: webb39 +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; - } -} -- cgit v1.2.3