Permalink
Browse files

Merge remote-tracking branch 'origin/master'

Conflicts:
	app/models/user.rb
	db/seeds.rb
  • Loading branch information...
2 parents c5773fa + fb99966 commit bffd7c464e1ad66c7a967904ff3f276fd7c55d3f Derick Hitchcock committed Nov 16, 2012
View
@@ -14,3 +14,4 @@ capybara-*.html
**.orig
rerun.txt
pickle-email-*.html
+config/database.yml
View
@@ -7,7 +7,6 @@ gem 'rails', '3.2.8'
gem 'mysql2'
-
# Gems used only for assets and not required
# in production environments by default.
group :assets do
@@ -20,8 +19,6 @@ group :assets do
gem 'uglifier', '>= 1.0.3'
end
-
-
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
@@ -34,8 +31,9 @@ end
# Deploy with Capistrano
# gem 'capistrano'
-# To use debugger
-gem 'debugger'
+group :development, :test do
+ gem 'debugger'
+end
gem "jquery-rails"
gem "rspec-rails", ">= 2.0.1", :group => [:development, :test]
@@ -11,3 +11,4 @@
*= require_self
*= require_tree .
*/
+//= require 'events'
@@ -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
@@ -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
@@ -1,3 +1,7 @@
class EventType < ActiveRecord::Base
attr_accessible :name
+
+ def to_s
+ return "#{name}"
+ end
end
View
@@ -2,4 +2,12 @@ class Timeslot < ActiveRecord::Base
attr_accessible :event_id, :ends_at, :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
@@ -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
@@ -4,9 +4,9 @@
<h2><%= pluralize(@event.errors.count, "error") %> prohibited this event from being saved:</h2>
<ul>
- <% @event.errors.full_messages.each do |msg| %>
- <li><%= msg %></li>
- <% end %>
+ <% @event.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
</ul>
</div>
<% end %>
@@ -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 %>
@@ -1,14 +1,12 @@
<!DOCTYPE html>
<html>
-<head>
- <title>Temptd</title>
- <%= stylesheet_link_tag "application", :media => "all" %>
- <%= javascript_include_tag "application" %>
- <%= csrf_meta_tags %>
-</head>
-<body>
-
-<%= yield %>
-
-</body>
+ <head>
+ <title>Temptd</title>
+ <%= stylesheet_link_tag "application", :media => "all" %>
+ <%= javascript_include_tag "application" %>
+ <%= csrf_meta_tags %>
+ </head>
+ <body>
+ <%= yield %>
+ </body>
</html>
View
@@ -1,42 +0,0 @@
-# MySQL. Versions 4.1 and 5.0 are recommended.
-#
-# Install the MYSQL driver
-# gem install mysql2
-#
-# Ensure the MySQL gem is defined in your Gemfile
-# gem 'mysql2'
-#
-# And be sure to use new-style password hashing:
-# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
-development:
- adapter: mysql2
- encoding: utf8
- reconnect: false
- database: temptd_development
- pool: 5
- username: root
- password:
- socket: /tmp/mysql.sock
-
-# Warning: The database defined as "test" will be erased and
-# re-generated from your development database when you run "rake".
-# Do not set this db to the same as development or production.
-test:
- adapter: mysql2
- encoding: utf8
- reconnect: false
- database: temptd_test
- pool: 5
- username: root
- password:
- socket: /tmp/mysql.sock
-
-production:
- adapter: mysql2
- encoding: utf8
- reconnect: false
- database: temptd_production
- pool: 5
- username: root
- password:
- socket: /tmp/mysql.sock
@@ -0,0 +1,19 @@
+development:
+ adapter: mysql2
+ database: temptd_development
+ username: the_user
+ password: the_password
+ host: localhost
+
+# Warning: The database defined as 'test' will be erased and
+# re-generated from your development database when you run 'rake'.
+# Do not set this db to the same as development or production.
+test: &test
+ adapter: mysql
+ database: temptd_test
+ username: the_user
+ password: the_password
+ host: localhost
+
+cucumber:
+ <<: *test
View
@@ -1,9 +1,7 @@
Temptd::Application.routes.draw do
devise_for :users
-
resources :events
-
resources :votes
# The priority is based upon order of creation:
View
@@ -1,10 +1,17 @@
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
-# Examples:
-#
-# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
-# Mayor.create(name: 'Emanuel', city: cities.first)
+sports = EventType.find_or_create_by_name("Sports")
+sports_event = Event.find_or_create_by_event_type_id(sports.id)
+sports_event.timeslots.each &:destroy # to get rid of any timeslots from previous seeding
+
+# 5 timeslots, each starting at 5PM
+now = Time.now
+5.times do |counter|
+ slot_start = now + counter.days
+ starts_at = Time.mktime(slot_start.year, slot_start.month, slot_start.day, 17)
+ sports_event.timeslots.create!(starts_at: starts_at)
+end
EventType.destroy_all
@@ -32,3 +39,9 @@
Vote.create(user_id: test_user.id, event_id: test_event.id, timeslot_id: Timeslot.last.id)
Vote.create(user_id: 2, event_id: test_event.id, timeslot_id: Timeslot.first.id)
Vote.create(user_id: 3, event_id: test_event.id, timeslot_id: Timeslot.last.id)
+
+user = User.find_or_initialize_by_email("sports@scimedsolutions.com")
+user.nickname = "Sporty"
+user.password = "sporty"
+user.password_confirmation = "sporty"
+user.save!

0 comments on commit bffd7c4

Please sign in to comment.