Permalink
Browse files

added flags, is_blocked to models

  • Loading branch information...
1 parent fa56927 commit 83600816049b2e49765e2f9dc28427adafaba3d5 Jeff Reifman committed Feb 5, 2010
View
2 app/models/comment.rb
@@ -1,6 +1,6 @@
class Comment < ActiveRecord::Base
belongs_to :user
belongs_to :commentable, :polymorphic => true, :counter_cache => true
-
+ named_scope :active, { :conditions => ["is_blocked = 0"] }
named_scope :newest, lambda { |*args| { :order => ["created_at desc"], :limit => (args.first || 5)} }
end
View
2 app/models/content.rb
@@ -11,7 +11,7 @@ class Content < ActiveRecord::Base
has_friendly_id :title, :use_slug => true
- named_scope :active, { :conditions => ["isBlocked = 0"] }
+ named_scope :active, { :conditions => ["is_blocked = 0"] }
named_scope :newest, lambda { |*args| { :order => ["created_at desc"], :limit => (args.first || 5)} }
named_scope :newest_stories, lambda { |*args| { :conditions => ["article_id IS NULL"], :order => ["created_at desc"], :limit => (args.first || 5)} }
named_scope :newest_articles, lambda { |*args| { :conditions => ["article_id IS NOT NULL"], :order => ["created_at desc"], :limit => (args.first || 5)} }
View
4 app/models/flag.rb
@@ -0,0 +1,4 @@
+class Flag < ActiveRecord::Base
+ belongs_to :user
+ belongs_to :flagable, :polymorphic => true, :counter_cache => true
+end
View
2 app/views/admin/users/show.html.haml
@@ -1,7 +1,7 @@
= gen_show_page @user, [:name, :fb_user_id, :email, :is_admin, :is_blocked, :cached_slug, :karma_score, :user_info], :associations => { :has_one => { :user_info => :user_info } }
%h2== Contents for this User (#{@user.contents.size})
-= gen_table @user.contents, Content, [:title, :comments_count, :isBlocked, :created_at]
+= gen_table @user.contents, Content, [:title, :comments_count, :is_blocked, :created_at]
%hr
%br
%h2== Ideas for this User (#{@user.ideas.size})
View
16 db/migrate/20100204221559_create_flags.rb
@@ -0,0 +1,16 @@
+class CreateFlags < ActiveRecord::Migration
+ def self.up
+ create_table :flags do |t|
+ t.string :flag_type
+ t.integer :user_id
+ t.string :flagable_type
+ t.integer :flagable_id
+ t.timestamps
+ end
+ add_index :flags, [:flagable_type, :flagable_id]
+ end
+
+ def self.down
+ drop_table :flags
+ end
+end
View
11 db/migrate/20100204232503_add_featured_to_ideas.rb
@@ -0,0 +1,11 @@
+class AddFeaturedToIdeas < ActiveRecord::Migration
+ def self.up
+ add_column :ideas, :is_featured, :boolean, :default => false
+ add_column :ideas, :featured_at, :datetime
+ end
+
+ def self.down
+ remove_column :ideas, :is_featured
+ remove_column :ideas, :featured_at
+ end
+end
View
15 db/migrate/20100204233243_add_flag_counts.rb
@@ -0,0 +1,15 @@
+class AddFlagCounts < ActiveRecord::Migration
+ def self.up
+ add_column :ideas, :flags_count, :integer, :default => 0
+ add_column :comments, :flags_count, :integer, :default => 0
+ add_column :contents, :flags_count, :integer, :default => 0
+ add_column :resources, :flags_count, :integer, :default => 0
+ end
+
+ def self.down
+ remove_column :ideas, :flags_count
+ remove_column :comments, :flags_count
+ remove_column :contents, :flags_count
+ remove_column :resources, :flags_count
+ end
+end
View
9 db/migrate/20100205014711_change_blocked_content.rb
@@ -0,0 +1,9 @@
+class ChangeBlockedContent < ActiveRecord::Migration
+ def self.up
+ rename_column :contents, :isBlocked, :is_blocked
+ end
+
+ def self.down
+ rename_column :contents, :is_blocked, :isBlocked
+ end
+end
View
9 db/migrate/20100205015017_change_blocked_comments.rb
@@ -0,0 +1,9 @@
+class ChangeBlockedComments < ActiveRecord::Migration
+ def self.up
+ rename_column :comments, :isBlocked, :is_blocked
+ end
+
+ def self.down
+ rename_column :comments, :is_blocked, :isBlocked
+ end
+end
View
9 db/migrate/20100205015709_add_blocked_to_ideas.rb
@@ -0,0 +1,9 @@
+class AddBlockedToIdeas < ActiveRecord::Migration
+ def self.up
+ add_column :ideas, :is_blocked, :boolean, :default => false
+ end
+
+ def self.down
+ remove_column :ideas, :is_blocked
+ end
+end
View
7 test/fixtures/flags.yml
@@ -0,0 +1,7 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+# one:
+# column: value
+#
+# two:
+# column: value
View
8 test/unit/flag_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class FlagTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end

0 comments on commit 8360081

Please sign in to comment.