Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .rvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rvm use --create 2.0.0-p0@capstone-deadsets
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ gem 'rails', '3.2.13'
gem 'pg'
gem 'devise'
gem 'nokogiri'
gem "decent_exposure", "~> 2.2.0"
gem 'simple_form'

# Gems used only for assets and not required
# in production environments by default.
Expand All @@ -25,6 +27,7 @@ group :test do
gem 'cucumber-rails'
gem 'database_cleaner'
gem 'rspec-rails'
gem 'pry'
end

gem 'jquery-rails'
Expand Down
7 changes: 7 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ GEM
nokogiri (>= 1.5.0)
rails (~> 3.0)
database_cleaner (1.0.1)
decent_exposure (2.2.0)
devise (2.2.4)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
Expand Down Expand Up @@ -133,6 +134,9 @@ GEM
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
simple_form (2.1.0)
actionpack (~> 3.0)
activemodel (~> 3.0)
slop (3.4.5)
sprockets (2.2.2)
hike (~> 1.2)
Expand Down Expand Up @@ -160,12 +164,15 @@ DEPENDENCIES
coffee-rails (~> 3.2.1)
cucumber-rails
database_cleaner
decent_exposure (~> 2.2.0)
devise
jquery-rails
nokogiri
pg
pry
pry-rails
rails (= 3.2.13)
rspec-rails
sass-rails (~> 3.2.3)
simple_form
uglifier (>= 1.0.3)
19 changes: 18 additions & 1 deletion app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,26 @@ p {
color: white;
}

ul {
list-style-type: none;
}

li {
font-family: 'RobotoThin', sans-serif;
font-size: 14px;
color: white;
}

.info_part {
font-size: 10px;
color: #FFEAB5;
padding-left: 10px;

}

a {
font-family: 'RobotoThin', sans-serif;
font-size: 12px;
font-size: 14px;
line-height: 20px;
color: #b0b0af;
text-decoration: none;
Expand Down
30 changes: 24 additions & 6 deletions app/controllers/concerts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
class ConcertsController < ApplicationController
expose(:concerts) do
if params[:search_by_date]
Concert.search_by_date(params[:search_by_date])
elsif params[:search_by_venue]
Concert.search_by_venue(params[:search_by_venue])
elsif params[:search_by_tour]
Concert.search_by_tour(params[:search_by_tour])
else
concerts = todays_concerts
end
end

expose(:concerts_count) { concerts.count }

def index
@concerts = Concert.search(params[:search])
if params[:search]
if concerts.blank?
flash[:notice] = "Please try again"
end
end


if @concerts.blank?
flash[:notice] = "Sorry, there's no concert for this date"
def todays_concerts
concert_collection = Concert.all
concert_collection.collect! do |concert|
if concert.date.strftime('%m/%d') == Time.now.strftime('%m/%d')
concert
end
end

concert_collection.reject! { |c| c.nil? }
end


end

13 changes: 13 additions & 0 deletions app/controllers/songs_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class SongsController < ApplicationController
expose(:song) { Song.find(params[:id]) }

def new
@song = Song.new
end

def create
@song.save!
end

end

34 changes: 33 additions & 1 deletion app/helpers/concerts_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,34 @@
module ConcertsHelper
end

def venue_options
concerts = Concert.all.map { |c| c }
concerts.uniq! { |c| c.venue }
concerts.sort_by { |c| c.venue }
end

def venues_count
venue_options.count
end

def songs_count
Song.all.count
end

def tour_options
concerts = Concert.all.map { |c| c }
concerts.uniq! { |c| c.tour }
end

def search_criteria
if params[:search_by_date]
params[:search_by_date]
elsif params[:search_by_venue]
params[:search_by_venue]
elsif params[:search_by_tour]
params[:search_by_tour]
else
"Today in Grateful Dead history"
end
end

end
56 changes: 53 additions & 3 deletions app/models/concert.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
class Concert < ActiveRecord::Base
attr_accessible :date, :details
attr_accessible :date, :venue, :tour
has_many :setlists
has_many :songs, through: :setlists
has_many :users, through: :favorites
has_many :favorites

def self.search(search)
def self.search_by_date(search)
if search
search_split = search.split("-")
search_split.each do |search|
Expand All @@ -12,10 +14,58 @@ def self.search(search)
end
end
search = search_split.join("-").to_s
where(:date => search).all
where(date: search).all
else
[]
flash[:notice] = "Sorry there is no match for your search criteria"
end
end

def self.search_by_venue(search)
if search
search_split = search.split("-")
search_split.each do |search|
if search.starts_with? "0"
search.slice!(0)
end
end
search = search_split.join("-").to_s
where(venue: search).all
else
[]
flash[:notice] = "Sorry there is no match for your search criteria"
end
end

def self.search_by_tour(search)
if search
search_split = search.split("-")
search_split.each do |search|
if search.starts_with? "0"
search.slice!(0)
end
end
search = search_split.join("-").to_s
where(tour: search).all
else
[]
flash[:notice] = "Sorry there is no match for your search criteria"
end
end

def first_set
self.setlists.where(group: "Set 1")
end

def second_set
self.setlists.where(group: "Set 2")
end

def third_set
self.setlists.where(group: "Set 3")
end

def encore
self.setlists.where(group: "Encore:")
end
end
7 changes: 6 additions & 1 deletion app/models/setlist.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
class Setlist < ActiveRecord::Base
attr_accessible :showdate, :deadset
attr_accessible :concert_id, :song_id, :order, :group
belongs_to :concert
belongs_to :song

delegate :group, to: :song, prefix: true

end
25 changes: 25 additions & 0 deletions app/models/song.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class Song < ActiveRecord::Base
attr_accessible :title, :media_link
has_many :setlists
has_many :concerts, through: :setlists


def times_played
self.concerts.count
end

def first_time_played
"#{self.concerts.last.date.strftime('%m/%d/%Y')} at #{self.concerts.last.venue}"
end

def last_time_played
"#{self.concerts.first.date.strftime('%m/%d/%Y')} at #{self.concerts.first.venue}"
end

def avg_times_played
concerts = Concert.where("date >= ?", self.concerts.last.date)
total = ((times_played.to_f/concerts.count.to_f)*100).round(2)
"#{total}% of concerts since it was introduced in #{self.concerts.last.date.strftime('%Y')}"
end

end
55 changes: 47 additions & 8 deletions app/views/concerts/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,54 @@
<% flash.discard(:notice) %>
</div>
<% end %>

<div class="content">u
<% if (@concerts) %>
<% @concerts.each do |concert| %>
<div class="content">
<%- if concerts.present? %>
<h1><%= search_criteria %> - <%= concerts_count %></h1>
<% concerts.each do |concert| %>
<%- if !concert.nil? %>
<p>
<%= simple_format(concert.details) %>
<%= link_to "#{concert.date.strftime('%m/%d/%Y')} - #{concert.venue}", "#", :class=>"setlist_button" %>
</p>

<div class="setlist">
<% if concert.first_set.present? %>
<ul>
<li>Set 1</li>
<% concert.first_set.each do |set| %>
<li><%= link_to set.song.title, "songs/#{set.song.id}" %><span class="info_part"><%= set.song.info %></span></li>
<% end %>
</ul>
<ul>
<li>Set 2</li>
<% concert.second_set.each do |set| %>
<li><%= link_to set.song.title, "songs/#{set.song.id}" %><span class="info_part"><%= set.song.info %></span></li>
<% end %>
</ul>
<% if concert.third_set.present? %>
<ul>
<li>Set 3</li>
<% concert.third_set.each do |set| %>
<li><%= link_to set.song.title, "songs/#{set.song.id}" %><span class="info_part"><%= set.song.info %></span></li>
<% end %>
</ul>
<% end %>
<ul>
<li>Encore</li>
<% concert.encore.each do |set| %>
<li><%= link_to set.song.title, "songs/#{set.song.id}" %><span class="info_part"><%= set.song.info %></span></li>
<% end %>
</ul>
<% else %>
<% if concert.setlists.empty? %>
<p>No songs have been recorded for this concert</p>
<% else %>
<ul>
<% concert.setlists.each do |set| %>
<li><%= link_to set.song.title, "songs/#{set.song.id}" %><span class="info_part"><%= set.song.info %></span></li>
<% end %>
</ul>
<% end %>
<% end %>
</div>
<% if user_signed_in? %>
<%= form_for concert.favorites.new do |f| %>
<%= f.label :favorite, :class=>"hidden_label" %>
Expand All @@ -21,7 +61,6 @@
<% end %>
<% end %>
<% end %>


<% end %>
</div>
</div>
1 change: 1 addition & 0 deletions app/views/concerts/songs/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= song.title %>
Loading