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-2-g168b 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-2-g168b 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-2-g168b From 3a4412f08bed438ebf14f6cdfa5bb6eb4d239138 Mon Sep 17 00:00:00 2001 From: nfoy Date: Mon, 28 Apr 2014 19:39:32 -0400 Subject: Some more changes for alerts with messages. --- app/views/alerts/new.html.erb | 2 +- app/views/pms/index.html.erb | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'app') 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 @@ - - + <%# if conversations.reject { |c| c.is_read?(current_user) || (c.receipts_for current_user).last.message.sender == current_user }.empty? %> - <% conversations.each do |conversation| %> @@ -112,7 +110,7 @@ <% if conversation.is_read?(current_user) || receipts.last.message.sender == current_user %> <% message = receipts.last.message %> - <% if conversation.subject == "Pay Attention!" %> + <% if conversation.subject == "Pay Attention!" && message.sender != current_user %> - - + <% end %> @@ -133,4 +130,8 @@ <% #end %> -
WithSubject Body
<% people = conversation.participants %> <% people.each do |person| %> @@ -121,8 +119,7 @@ <% end %> <% end %> <%= truncate(conversation.subject, length: 30) %><%= truncate(message.body, length: 42) %><%= truncate(message.body, length: 80) %> <%= link_to 'View', @pms.find_by(conversation: conversation) %>
\ No newline at end of file + + +
+
+
\ No newline at end of file -- cgit v1.2.3-2-g168b From 1288b00d612d5969bfdde5b572cb7b6004b0cb66 Mon Sep 17 00:00:00 2001 From: guntasgrewal Date: Mon, 28 Apr 2014 19:47:48 -0400 Subject: Fixed multiple redirection error. --- app/assets/stylesheets/application/scaffolds.css.scss | 12 ++++++------ app/controllers/matches_controller.rb | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'app') diff --git a/app/assets/stylesheets/application/scaffolds.css.scss b/app/assets/stylesheets/application/scaffolds.css.scss index ae26907..cbe83bf 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%; } } @@ -144,7 +144,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 +153,7 @@ select { background-color: #333; padding: 5px; border: none; - color: $orange !important; + color: $orange; } pre { diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 5745ac9..81ffcd8 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -44,7 +44,7 @@ class MatchesController < ApplicationController end when 2 # Started, waiting to finish - @match.handle_sampling(params) + @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.' } @@ -69,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 -- cgit v1.2.3-2-g168b