Skip to content

Commit

Permalink
Merge 6f7cba8 into 8c18932
Browse files Browse the repository at this point in the history
  • Loading branch information
notmarkmiranda committed Feb 15, 2019
2 parents 8c18932 + 6f7cba8 commit ebeacac
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/leagues/index.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.list-group-item.public-league {
a.list-group-item.public-league {
display: flex;
align-items: center;
justify-content: space-between;
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/leagues_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ def league_params
end

def league
@league ||= League.find(params[:id])
@league ||= League.find(params[:id]).decorate
end
end
1 change: 1 addition & 0 deletions app/controllers/memberships_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def show
def create
membership = league.memberships.new(membership_requestor_params)
if membership.save
flash[:notice] = "Your request to join #{league.name} has been sent to the admin!"
else
end
redirect_to request.referer
Expand Down
8 changes: 8 additions & 0 deletions app/decorators/league_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ def game_frequency_text
end
end

def location_text
if object.location.present?
h.content_tag :div, class: 'caption-text text-warning' do
league.location
end
end
end

def public_league_stats
"# of Games: #{object.games_count} | \
Average Players per Game: #{object.average_players_per_game} | \
Expand Down
3 changes: 3 additions & 0 deletions app/views/dashboard/_league.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
</li>
<% else %>
<% leagues.each do |league| %>
<%= link_to season_path(league.current_season), class: 'list-group-item list-group-item-action stat-line' do %>
<%= league.location_text %>
<%= league.name %>
<div class="caption-text <%= owned ? 'text-info' : 'text-danger' %>">
Next Game: <%= league.next_game %>
Expand All @@ -34,6 +36,7 @@
</div>
<% end %>
<% end %>
<% end %>
</ul>
</div>
Expand Down
8 changes: 3 additions & 5 deletions app/views/leagues/_league.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<li class="list-group-item public-league">
<%= link_to season_path(league.current_season), class: 'list-group-item public-league' do %>
<div>
<div class="caption-text text-primary">
Denver, Colorado
</div>
<%= league.location_text %>
<span class="stat-line">
<%= league.name %>
</span>
Expand All @@ -13,4 +11,4 @@
<% unless league.memberships.where(user: current_user, league: league).any? || current_user.nil? %>
<%= button_to 'Request Membership', memberships_path, params: { membership: { user_id: current_user.id, league_id: league.id } }, class: 'btn btn-outline-primary btn-sm' %>
<% end %>
</li>
<% end %>
2 changes: 1 addition & 1 deletion app/views/seasons/show.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<%= render partial: 'shared/statistics_page', locals: { league: @season.league, subject: @season } %>
<%= render partial: 'shared/statistics_page', locals: { league: @season.league.decorate, subject: @season } %>
1 change: 1 addition & 0 deletions app/views/shared/_statistics_page.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<div class="card-header league-name league-show-header">
<div>
<%= league.location_text %>
<%= league.name %>
<div class="caption-text text-primary">
<%= league.privated_text %>
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20190215222547_add_location_to_leagues.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddLocationToLeagues < ActiveRecord::Migration[5.2]
def change
add_column :leagues, :location, :string
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2019_02_06_051010) do
ActiveRecord::Schema.define(version: 2019_02_15_222547) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand All @@ -31,6 +31,7 @@
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "privated", default: true
t.string "location"
t.index ["user_id"], name: "index_leagues_on_user_id"
end

Expand Down

0 comments on commit ebeacac

Please sign in to comment.