diff --git a/.gitignore b/.gitignore index 96be7ae..c88cbe3 100644 --- a/.gitignore +++ b/.gitignore @@ -60,6 +60,11 @@ pickle-email-*.html # Sublime *.sublime* +# Vscode +.vscode/ +.rakeTasks +.generators + # Gemtags *.tags *.gemtags diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index a15fa57..975a5a2 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -17,7 +17,8 @@ Just run and open http://localhost:4000/ sudo echo `docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ensl_dev_db` db >> /etc/hosts 1. VS Code and RubyMine are great IDE's/editors. -1. To run VS Code plugin Ruby Test Explorer in docker container you need to create path to custom +1. To run VS Code plugin Ruby Test Explorer in docker container you need to create path to custom path, copy the formatter and it whines about +and it still fails a bit. https://github.com/connorshea/vscode-ruby-test-adapter/issues/21 1. Do not commit too much without testing. Also keep commits small for documentation and reversability issues. 1. You need to rebuild the docker image when you change gems. @@ -41,7 +42,7 @@ FIXME, TODO, EXPLAIN, OBSOLETE ## Handy commands Build or rebuild - + docker-compose -f docker-compose.dev.yml build` To get inside docker web+test containers: diff --git a/app/assets/stylesheets/themes/default/layout/_sidebar.scss b/app/assets/stylesheets/themes/default/layout/_sidebar.scss index 0260bed..7da7b4f 100644 --- a/app/assets/stylesheets/themes/default/layout/_sidebar.scss +++ b/app/assets/stylesheets/themes/default/layout/_sidebar.scss @@ -29,9 +29,14 @@ font-weight: normal; text-align: center; margin-bottom: 25px; + margin-top: 20px; color: $light-blue; text-transform: uppercase; } + + h4:first-child { + margin-top: 0px; + } .widget-content-wrapper { @include span-columns(12); @@ -70,6 +75,10 @@ text-align: center; } + div.controls, div.fields, div.select-wrapper { + width: 100%; + } + .button, .controls input { @include linear-gradient(#585858, #585858); @@ -81,6 +90,7 @@ border: 0; line-height: 30px; height: 30px; + padding: 1px 0px 0px 5px; width: 175px; margin-left: auto; margin-right: auto; @@ -90,10 +100,15 @@ float: none; } - .button { + .button.big { + height: 62px; + } + + .button, .select { clear: both; display: block; - margin: 0 auto; + margin-left: auto; + margin-right: auto; } &:last-child { diff --git a/app/assets/stylesheets/themes/flat/layout/_sidebar.scss b/app/assets/stylesheets/themes/flat/layout/_sidebar.scss index 6123e5e..98e15a7 100644 --- a/app/assets/stylesheets/themes/flat/layout/_sidebar.scss +++ b/app/assets/stylesheets/themes/flat/layout/_sidebar.scss @@ -14,9 +14,14 @@ h4 { @include span-columns(12); margin-bottom: 20px; + margin-top: 20px; color: $light-blue; } + h4:first-child { + margin-top: 0px; + } + .widget-content-wrapper { @include span-columns(12); font-size: 12px; diff --git a/app/controllers/brackets_controller.rb b/app/controllers/brackets_controller.rb index 56db789..f4ea409 100644 --- a/app/controllers/brackets_controller.rb +++ b/app/controllers/brackets_controller.rb @@ -20,11 +20,11 @@ class BracketsController < ApplicationController def update raise AccessError unless @bracket.can_update? cuser - if @bracket.update_attributes(Bracket.params(params, cuser)) and @bracket.update_cells(params.permit(:cell)[:cell]) + if @bracket.update_attributes(Bracket.params(params, cuser)) and @bracket.update_cells(params.permit(:cell)) flash[:notice] = t(:brackets_update) end - render :edit + render :edit, layout: 'full' end def destroy diff --git a/app/models/bracket.rb b/app/models/bracket.rb index c5a9fc2..ebd5d81 100644 --- a/app/models/bracket.rb +++ b/app/models/bracket.rb @@ -23,7 +23,11 @@ class Bracket < ActiveRecord::Base has_many :bracketers def to_s - "#" + self.id.to_s + if name + name + else + "Bracket #%d" % [id] + end end def get_bracketer row, col diff --git a/app/models/contest.rb b/app/models/contest.rb index e32f59f..f7b6094 100644 --- a/app/models/contest.rb +++ b/app/models/contest.rb @@ -42,7 +42,7 @@ class Contest < ActiveRecord::Base scope :active, -> { where.not(status: STATUS_CLOSED) } scope :inactive, -> { where(status: STATUS_CLOSED) } - scope :joinable, -> { where(status: STATUS_OPEN) } + scope :joinable, -> { where(table[:status].eq(STATUS_OPEN).and(table[:end].gt(Time.now.utc))) } scope :with_contesters, -> { includes(:contesters) } scope :ordered, -> { order("start DESC") } scope :nsls1, -> { where("name LIKE ?", "NSL S1:%") } @@ -132,6 +132,12 @@ class Contest < ActiveRecord::Base c.uniq.pluck(:score).count == c.count end + def can_join?(cuser) + byebug + cuser and !cuser&.banned?(Ban::TYPE_LEAGUE) and \ + (cuser&.lead_teams.not_in_contest(self).exists?) and \ + Contest.joinable.where(id: self).exists? + end def can_create? cuser cuser and cuser.admin? diff --git a/app/models/map.rb b/app/models/map.rb index eebdee1..1998803 100644 --- a/app/models/map.rb +++ b/app/models/map.rb @@ -18,6 +18,7 @@ class Map < ActiveRecord::Base #attr_protected :id, :updated_at, :created_at, :deleted has_and_belongs_to_many :contests + has_many :matches, -> (map){ unscope(:where).where("map1_id = :id OR map2_id = :id", id: map.id) } scope :basic, -> { where(deleted: false).order("name") } scope :with_name, -> (name) { where(name: name) } diff --git a/app/models/match.rb b/app/models/match.rb index 25e09a2..967bab5 100755 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -164,6 +164,7 @@ class Match < ActiveRecord::Base matchers.where(contester_id: contester2_id) end + # FIXME: this is a view helper and doesn't belong here def get_friendly(param = nil) if param.nil? friendly == contester1.team ? contester1 : contester2 @@ -174,6 +175,7 @@ class Match < ActiveRecord::Base end end + # FIXME: this is a view helper and doesn't belong here def get_opponent(param = nil) if param.nil? friendly == contester1.team ? contester2 : contester1 diff --git a/app/models/team.rb b/app/models/team.rb index 9d027a6..05582a5 100644 --- a/app/models/team.rb +++ b/app/models/team.rb @@ -49,6 +49,7 @@ class Team < ActiveRecord::Base scope :inactive, -> { where(active: false) } scope :ordered, -> { order("name") } scope :recruiting, -> { where("recruiting IS NOT NULL AND recruiting != ''") } + scope :not_in_contest, -> (contest) { joins(:contests).where.not('contests.id': contest.id) } belongs_to :founder, :class_name => "User", :optional => true diff --git a/app/models/user.rb b/app/models/user.rb index 5245ec5..45a747a 100755 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -68,6 +68,8 @@ class User < ActiveRecord::Base has_many :teamers, :dependent => :destroy has_many :active_teams, -> { where("teamers.rank >= ? AND teams.active = ?", Teamer::RANK_MEMBER, true) }, \ :through => :teamers, :source => "team" + has_many :lead_teams, -> { where("teamers.rank >= ? AND teams.active = ?", Teamer::RANK_DEPUTEE, true) }, \ + :through => :teamers, :source => "team" has_many :active_contesters, -> { where("contesters.active = ?", true) }, \ :through => :active_teams, :source => "contesters" has_many :active_contests, -> { where("contests.status != ?", Contest::STATUS_CLOSED) }, \ diff --git a/app/views/brackets/_bracket.html.erb b/app/views/brackets/_bracket.html.erb index 850a963..49b693f 100644 --- a/app/views/brackets/_bracket.html.erb +++ b/app/views/brackets/_bracket.html.erb @@ -1,3 +1,7 @@ +
<% if element_class == "team" %>
- <% if params[:action] == "edit" %>
+ <% if defined? edit %>
<%= select_tag "cell[#{row}][#{col}]", options_for_select(bracket.options, :selected => bracket.default(row, col)) %>
<% elsif bracketer %>
<% if bracketer.match %>
diff --git a/app/views/brackets/edit.html.erb b/app/views/brackets/edit.html.erb
index 09c3a08..cda75dc 100644
--- a/app/views/brackets/edit.html.erb
+++ b/app/views/brackets/edit.html.erb
@@ -4,12 +4,17 @@
<%= form_for(@bracket) do |f| %>
<%= render 'shared/errors', messages: @bracket.errors.full_messages %>
+
+ <%= f.label :name %>
+ <%= f.text_field :name %>
+
+
<%= f.label :slots %>
<%= f.text_field :slots %>
- <%= render partial: "bracket", locals: { bracket: @bracket } %>
+ <%= render partial: "bracket", locals: { bracket: @bracket, edit: true } %>
<%= f.submit 'Update' %>
diff --git a/app/views/contests/edit.html.erb b/app/views/contests/edit.html.erb
index 2bbea40..283c38c 100644
--- a/app/views/contests/edit.html.erb
+++ b/app/views/contests/edit.html.erb
@@ -110,7 +110,10 @@
<%= hidden_field_tag :type, 'contest' %>
<%= f.hidden_field :contest_id %>
-
+
+ <%= f.label :name %>
+ <%= f.text_field :name %>
+
<%= f.label :slots %>
<%= f.text_field :slots %>
diff --git a/app/views/contests/show.html.erb b/app/views/contests/show.html.erb
index e61fe73..8891aa3 100644
--- a/app/views/contests/show.html.erb
+++ b/app/views/contests/show.html.erb
@@ -20,11 +20,27 @@
<% end %>
diff --git a/app/views/maps/show.html.erb b/app/views/maps/show.html.erb
index 6122bb5..9032693 100644
--- a/app/views/maps/show.html.erb
+++ b/app/views/maps/show.html.erb
@@ -14,6 +14,11 @@
Join Contest+ + <% if @contest.can_join?(cuser) %> + <%= form_for @contest.contesters.build, html: { class: 'square' } do |f| %> + <%= f.hidden_field :contest_id %> + +
+ <%= f.collection_select :team_id, cuser.lead_teams, :id, :name %>
+
+
+
+ <%= f.submit "Join Contest" %>
+
+ <% end %>
+ <% end %>
<%= link_to (h @map.download), (h @map.download) %> <% end %> +Played in these matches (<%= @map.matches.count %>):+
Played in Contests
|