Permalink
Browse files

updated for #bctampa 2010

  • Loading branch information...
1 parent 780ecb4 commit b52976c429e661f35407d8ef56435b9f33eab3f8 @btedev committed Sep 15, 2010
Showing with 1,176 additions and 18 deletions.
  1. +2 −0 .gitignore
  2. +5 −2 app/controllers/talks_controller.rb
  3. +7 −0 app/models/talk.rb
  4. +15 −0 app/views/talks/index.html.haml
  5. +1 −15 app/views/talks/index.json.erb
  6. +2 −0 config/environment.rb
  7. +8 −0 db/migrate/20100912002200_add_day_to_talk.rb
  8. +8 −0 db/migrate/20100912011427_add_deleted_at_to_talks.rb
  9. +3 −1 db/schema.rb
  10. +79 −0 vendor/plugins/acts_as_paranoid/CHANGELOG
  11. +20 −0 vendor/plugins/acts_as_paranoid/MIT-LICENSE
  12. +5 −0 vendor/plugins/acts_as_paranoid/README
  13. +10 −0 vendor/plugins/acts_as_paranoid/RUNNING_UNIT_TESTS
  14. +180 −0 vendor/plugins/acts_as_paranoid/Rakefile
  15. +34 −0 vendor/plugins/acts_as_paranoid/init.rb
  16. +14 −0 vendor/plugins/acts_as_paranoid/lib/caboose/acts/belongs_to_with_deleted_association.rb
  17. +27 −0 vendor/plugins/acts_as_paranoid/lib/caboose/acts/has_many_through_without_deleted_association.rb
  18. +208 −0 vendor/plugins/acts_as_paranoid/lib/caboose/acts/paranoid.rb
  19. +94 −0 vendor/plugins/acts_as_paranoid/lib/caboose/acts/paranoid_find_wrapper.rb
  20. +18 −0 vendor/plugins/acts_as_paranoid/test/database.yml
  21. +19 −0 vendor/plugins/acts_as_paranoid/test/fixtures/categories.yml
  22. +12 −0 vendor/plugins/acts_as_paranoid/test/fixtures/categories_widgets.yml
  23. +9 −0 vendor/plugins/acts_as_paranoid/test/fixtures/taggings.yml
  24. +6 −0 vendor/plugins/acts_as_paranoid/test/fixtures/tags.yml
  25. +8 −0 vendor/plugins/acts_as_paranoid/test/fixtures/widgets.yml
  26. +287 −0 vendor/plugins/acts_as_paranoid/test/paranoid_test.rb
  27. +30 −0 vendor/plugins/acts_as_paranoid/test/schema.rb
  28. +47 −0 vendor/plugins/acts_as_paranoid/test/test_helper.rb
  29. +18 −0 vendor/plugins/haml/init.rb
View
@@ -5,3 +5,5 @@ doc/app/*
log/*.log
tmp/**/*
config/deploy.rb
+deploy.rb
+
@@ -2,10 +2,13 @@ class TalksController < ApplicationController
before_filter :login_required, :except => :index
def index
- @talks = Talk.all
+
+ conditions = (params[:day] ? ["day = ?", params[:day]] : nil)
+ @talks = Talk.all(:conditions => conditions, :include => :room, :with_deleted => true)
respond_to do |format|
- format.json {}
+ format.html
+ format.json
end
end
View
@@ -1,4 +1,6 @@
class Talk < ActiveRecord::Base
+ acts_as_paranoid
+
belongs_to :room
named_scope :by_time, :order => "time(start_time)"
@@ -12,6 +14,11 @@ class Talk < ActiveRecord::Base
validates_presence_of :name, :room_id, :start_time, :end_time
validate :timecheck
+ #to make talk.room.name easily accessible to to_json calls
+ def room_name
+ room.name
+ end
+
def timecheck
min = Date.new(2000,1,1)
if start_time && end_time
@@ -0,0 +1,15 @@
+%table
+ %thead
+ %tr
+ %th Time
+ %th Talk
+ %th Room
+ %tbody
+ - @talks.each do |t|
+ %tr
+ %td
+ = talk_time(t)
+ %td
+ = t.name
+ %td
+ = t.room.name
@@ -1,15 +1 @@
-{"talks":[
- <% @talks.each do |t| %>
- {
- "id": "<%=t.id%>",
- "name": "<%=t.name%>",
- "description": "<%=t.description%>",
- "who": "<%=t.who%>",
- "link": "<%=t.url%>",
- "start_time": "<%=t.start_time.hour%>:<%=t.start_time.min%>",
- "end_time": "<%=t.end_time.hour%>:<%=t.end_time.min%>",
- "room_id": "<%=t.room.id%>",
- "room_name": "<%=t.room.name%>"
- }<%= "," unless t == @talks.last %>
- <%end%>
-]}
+{ "talks": <%= @talks.to_json :methods => [ :room_name ] %> }
@@ -9,6 +9,8 @@
Rails::Initializer.run do |config|
config.time_zone = 'UTC'
+ config.gem "haml"
+
config.action_controller.session = {
:session_key => '_barcamp_session',
:secret => 'aef25c44352947a8ba3d0dbf06c874e72a03c8d0c76dce0b0fef3c06274dcfb19792cb96a7d32cfe4f22c511293a8544998561fa19ca2a800cb7f5b65cd8bc3f'
@@ -0,0 +1,8 @@
+class AddDayToTalk < ActiveRecord::Migration
+ def self.up
+ add_column :talks, :day, :date
+ end
+
+ def self.down
+ end
+end
@@ -0,0 +1,8 @@
+class AddDeletedAtToTalks < ActiveRecord::Migration
+ def self.up
+ add_column :talks, :deleted_at, :datetime
+ end
+
+ def self.down
+ end
+end
View
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20081008132251) do
+ActiveRecord::Schema.define(:version => 20100912011427) do
create_table "rooms", :force => true do |t|
t.string "name"
@@ -36,6 +36,8 @@
t.datetime "created_at"
t.datetime "updated_at"
t.string "url"
+ t.date "day"
+ t.datetime "deleted_at"
end
create_table "users", :force => true do |t|
@@ -0,0 +1,79 @@
+* (16 Apr 2009)
+
+Allow :with_deleted and :only_deleted options to work with count and calculate.
+Fixes compatibility with will_paginate. [James Le Cuirot]
+
+* (4 Oct 2007)
+
+Update for Edge rails: remove support for legacy #count args
+
+* (2 Feb 2007)
+
+Add support for custom primary keys [Jeff Dean]
+
+* (2 July 2006)
+
+Add paranoid delete_all implementation [Marshall Roch]
+
+* (23 May 2006)
+
+Allow setting of future dates for content expiration.
+
+* (15 May 2006)
+
+Added support for dynamic finders
+
+* (28 Mar 2006)
+
+Updated for Rails 1.1. I love removing code.
+
+ Refactored #find method
+ Nested Scopes
+
+*0.3.1* (20 Dec 2005)
+
+* took out deleted association code for 'chainsaw butchery of base classes' [sorry Erik Terpstra]
+* verified tests pass on Rails 1.0
+
+*0.3* (27 Nov 2005)
+
+* Deleted models will find deleted associations by default now [Erik Terpstra]
+* Added :group as valid option for find [Michael Dabney]
+* Changed the module namespace to Caboose::Acts::Paranoid
+
+*0.2.0* (6 Nov 2005)
+
+* Upgrade to Rails 1.0 RC4. ActiveRecord::Base#constrain has been replaced with scope_with.
+
+*0.1.7* (22 Oct 2005)
+
+* Added :with_deleted as a valid option of ActiveRecord::Base#find
+
+*0.1.6* (25 Sep 2005)
+
+* Fixed bug where nested constrains would get clobbered after multiple queries
+
+*0.1.5* (22 Sep 2005)
+
+* Fixed bug where acts_as_paranoid would clobber other constrains
+* Simplified acts_as_paranoid mixin including.
+
+*0.1.4* (18 Sep 2005)
+
+* First RubyForge release
+
+*0.1.3* (18 Sep 2005)
+
+* ignore multiple calls to acts_as_paranoid on the same model
+
+*0.1.2* (18 Sep 2005)
+
+* fixed a bug that kept you from selecting the first deleted record
+
+*0.1.1* (18 Sep 2005)
+
+* Fixed bug that kept you from selecting deleted records by ID
+
+*0.1* (17 Sep 2005)
+
+* Initial gem
@@ -0,0 +1,20 @@
+Copyright (c) 2005 Rick Olson
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,5 @@
+= acts_as_paranoid
+
+Overrides some basic methods for the current model so that calling #destroy sets a 'deleted_at' field to the current timestamp. ActiveRecord is required.
+
+http://github.com/technoweenie/acts_as_paranoid
@@ -0,0 +1,10 @@
+1. Pick Rails version. Either dump this plugin in a Rails app and run it from there, or specify it as an ENV var:
+
+ RAILS=2.2.2 rake
+ RAILS=2.2.2 ruby test/paranoid_test.rb
+
+2. Setup your database. By default sqlite3 is used, and no further setup is necessary. You can pick any of the listed databases in test/database.yml. Be sure to create the database first.
+
+ DB=mysql rake
+
+3. Profit!!
Oops, something went wrong. Retry.

0 comments on commit b52976c

Please sign in to comment.