Permalink
Browse files

"Show" page for events

Still got a long ways to go
  • Loading branch information...
1 parent d89c20c commit dad54d5dd281cd6f8d1ebec44fb42978b5b4d646 Joe Peck committed Oct 23, 2012
View
1 app/assets/stylesheets/application.css
@@ -11,3 +11,4 @@
*= require_self
*= require_tree .
*/
+//= require 'events'
View
26 app/assets/stylesheets/events.css.scss
@@ -1,3 +1,29 @@
// Place all the styles related to the events controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
+.timeslots {
+ list-style-type: none;
+ display: block;
+ clear: both;
+}
+
+.timeslots:after {
+ visibility: hidden;
+ display: block;
+ content: "";
+ clear: both;
+ height: 0;
+}
+
+.timeslots li {
+ display: block;
+ float:left;
+ margin-right: 8px;
+ height: 80px;
+ width: 80px;
+ border: 3px solid grey;
+ -moz-border-radius: 10px;
+ border-radius: 10px;
+ padding: 10px;
+ background-color: #A9F5F2;
+}
View
10 app/models/event.rb
@@ -3,6 +3,16 @@ class Event < ActiveRecord::Base
has_many :timeslots
has_many :votes
belongs_to :event_type
+
+ validates_presence_of :event_type
+
+ def to_s
+ "#{event_type}"
+ end
+
+ def starts_at
+ timeslots.order(:starts_at).first.starts_at
+ end
def calculate_event_details
calculate_event_time
View
4 app/models/event_type.rb
@@ -1,3 +1,7 @@
class EventType < ActiveRecord::Base
attr_accessible :name
+
+ def to_s
+ return "#{name}"
+ end
end
View
8 app/models/timeslot.rb
@@ -2,4 +2,12 @@ class Timeslot < ActiveRecord::Base
attr_accessible :ends_at, :event_id, :starts_at
belongs_to :event
has_many :votes
+
+ validates_presence_of :event_id, :starts_at
+
+ def to_s
+ range = starts_at.strftime("%A:%l%P")
+ range << " - #{ends_at.strftime("%A:%l%P")}" if ends_at
+ return range
+ end
end
View
4 app/models/user.rb
@@ -1,4 +1,7 @@
class User < ActiveRecord::Base
+ has_many :votes
+ validates_presence_of :email
+
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
@@ -7,5 +10,4 @@ class User < ActiveRecord::Base
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
- # attr_accessible :title, :body
end
View
12 app/views/events/show.html.erb
@@ -1,5 +1,17 @@
<p id="notice"><%= notice %></p>
+<h1><%= @event %></h1>
+<h2><%= @event.starts_at.strftime() %></h2>
+<% if @event.timeslots.empty? %>
+ No timeslots!
+<% else %>
+ <ul class="timeslots">
+ <% @event.timeslots.each do |timeslot| %>
+ <%# TODO: Determine li class based on if current user has voted for that day %>
+ <li><%= timeslot %></li>
+ <% end %>
+ </ul>
+<% end %>
<%= link_to 'Edit', edit_event_path(@event) %> |
<%= link_to 'Back', events_path %>

0 comments on commit dad54d5

Please sign in to comment.