Diff
Modified: trunk/app/models/blob.rb (2112 => 2113)
--- trunk/app/models/blob.rb 2009-02-24 14:07:34 UTC (rev 2112)
+++ trunk/app/models/blob.rb 2009-03-05 12:15:46 UTC (rev 2113)
@@ -4,13 +4,17 @@
# See license.txt for details.
require 'acts_as_contributable'
-require 'acts_as_contributable'
require 'acts_as_creditable'
require 'acts_as_attributor'
require 'acts_as_attributable'
class Blob < ActiveRecord::Base
acts_as_contributable
+
+ acts_as_bookmarkable
+ acts_as_commentable
+ acts_as_rateable
+ acts_as_taggable
acts_as_creditable
Modified: trunk/app/models/blog.rb (2112 => 2113)
--- trunk/app/models/blog.rb 2009-02-24 14:07:34 UTC (rev 2112)
+++ trunk/app/models/blog.rb 2009-03-05 12:15:46 UTC (rev 2113)
@@ -8,6 +8,11 @@
class Blog < ActiveRecord::Base
acts_as_contributable
+ acts_as_bookmarkable
+ acts_as_commentable
+ acts_as_rateable
+ acts_as_taggable
+
has_many :posts,
:class_name => "BlogPost",
:order => "blog_posts.created_at DESC",
Modified: trunk/app/models/pack.rb (2112 => 2113)
--- trunk/app/models/pack.rb 2009-02-24 14:07:34 UTC (rev 2112)
+++ trunk/app/models/pack.rb 2009-03-05 12:15:46 UTC (rev 2113)
@@ -13,6 +13,11 @@
class Pack < ActiveRecord::Base
acts_as_contributable
+ acts_as_bookmarkable
+ acts_as_commentable
+ acts_as_rateable
+ acts_as_taggable
+
validates_presence_of :title
format_attribute :description
@@ -42,7 +47,19 @@
self.find_by_sql("SELECT * FROM ((SELECT p.*, contrib.pack_id FROM packs p JOIN pack_contributable_entries contrib ON contrib.pack_id = p.id) UNION ALL (SELECT p.*, remote.pack_id FROM packs p JOIN pack_remote_entries remote ON remote.pack_id = p.id)) AS pack_items GROUP BY pack_id ORDER BY COUNT(pack_id) DESC, title LIMIT #{limit}")
end
+ # Returns all the Packs that a contributable is referred to in
+ def self.packs_with_contributable(contributable)
+ # Use a custom handcrafted sql query (for perf reasons):
+ sql = "SELECT packs.*
+ FROM packs
+ WHERE packs.id IN (
+ SELECT pack_id
+ FROM pack_contributable_entries
+ WHERE contributable_id = ? AND contributable_type = ? )"
+ return Pack.find_by_sql([ sql, contributable.id, contributable.class.to_s ])
+ end
+
def self.archive_folder
# single declaration point of where the zip archives for downloadable packs would live
return "tmp/packs"
Modified: trunk/app/models/workflow.rb (2112 => 2113)
--- trunk/app/models/workflow.rb 2009-02-24 14:07:34 UTC (rev 2112)
+++ trunk/app/models/workflow.rb 2009-03-05 12:15:46 UTC (rev 2113)
@@ -31,6 +31,11 @@
acts_as_contributable
+ acts_as_bookmarkable
+ acts_as_commentable
+ acts_as_rateable
+ acts_as_taggable
+
acts_as_creditable
acts_as_attributor
Modified: trunk/app/views/blobs/show.rhtml (2112 => 2113)
--- trunk/app/views/blobs/show.rhtml 2009-02-24 14:07:34 UTC (rev 2112)
+++ trunk/app/views/blobs/show.rhtml 2009-03-05 12:15:46 UTC (rev 2113)
@@ -23,7 +23,7 @@
|
<%= link_to "Tags <span id='mini_nav_tag_link'>(address@hidden)</span>", "#tags" %>
|
- <%= link_to "Featured in Packs (address@hidden)", "#featured_in_packs" %>
+ <%= link_to "Featured in Packs (#{Pack.packs_with_contributable(@blob).length})", "#featured_in_packs" %>
|
<%= link_to "Ratings (address@hidden)", "#ratings" %>
|
Modified: trunk/app/views/contributions/_in_packs_box.rhtml (2112 => 2113)
--- trunk/app/views/contributions/_in_packs_box.rhtml 2009-02-24 14:07:34 UTC (rev 2112)
+++ trunk/app/views/contributions/_in_packs_box.rhtml 2009-03-05 12:15:46 UTC (rev 2113)
@@ -1,4 +1,4 @@
-<% packs = contributable.in_packs -%>
+<% packs = Pack.packs_with_contributable(contributable) -%>
<div class="contribution_section_box">
<p class="heading">
<%= info_icon_with_tooltip("All the Packs that this item (or versions of this item [if available]) is referred to in") -%>
@@ -51,4 +51,4 @@
<% else -%>
<p><small><b><%= link_to "Log in", new_session_url -%></b> to add to one of your Packs</small></p>
<% end -%>
-</div>
\ No newline at end of file
+</div>
Modified: trunk/app/views/packs/show.rhtml (2112 => 2113)
--- trunk/app/views/packs/show.rhtml 2009-02-24 14:07:34 UTC (rev 2112)
+++ trunk/app/views/packs/show.rhtml 2009-03-05 12:15:46 UTC (rev 2113)
@@ -28,7 +28,7 @@
<% end %>
<%= link_to "Tags <span id='mini_nav_tag_link'>(address@hidden)</span>", "#tags" %>
|
- <%= link_to "Featured in Packs (address@hidden)", "#featured_in_packs" %>
+ <%= link_to "Featured in Packs (#{Pack.packs_with_contributable(@pack).length})", "#featured_in_packs" %>
|
<%= link_to "Favourited By (address@hidden)", "#favourited_by" %>
|
Modified: trunk/app/views/workflows/show.rhtml (2112 => 2113)
--- trunk/app/views/workflows/show.rhtml 2009-02-24 14:07:34 UTC (rev 2112)
+++ trunk/app/views/workflows/show.rhtml 2009-03-05 12:15:46 UTC (rev 2113)
@@ -40,7 +40,7 @@
|
<%= link_to "Tags <span id='mini_nav_tag_link'>(address@hidden)</span>", "#tags" %>
|
- <%= link_to "Featured in Packs (address@hidden)", "#featured_in_packs" %>
+ <%= link_to "Featured in Packs (#{Pack.packs_with_contributable(@workflow).length})", "#featured_in_packs" %>
|
<%= link_to "Ratings (address@hidden)", "#ratings" %>
|
Modified: trunk/lib/acts_as_contributable.rb (2112 => 2113)
--- trunk/lib/acts_as_contributable.rb 2009-02-24 14:07:34 UTC (rev 2112)
+++ trunk/lib/acts_as_contributable.rb 2009-03-05 12:15:46 UTC (rev 2113)
@@ -18,17 +18,8 @@
:as => :contributable,
:dependent => :destroy
- acts_as_bookmarkable
- acts_as_commentable
- acts_as_rateable
- acts_as_taggable
-
after_save :save_contributable_record
- # NOTE: because we cannot do polymorphic nested resources with Rails 1.2.3,
- # the line below has been moved to the Workflow model class.
- #acts_as_reviewable
-
class_eval do
extend Mib::Acts::Contributable::SingletonMethods
end
@@ -90,19 +81,6 @@
contribution.save
end
end
-
- # Returns all the Packs that this contributable is referred to in
- def in_packs
- # Use a custom handcrafted sql query (for perf reasons):
- sql = "SELECT packs.*
- FROM packs
- WHERE packs.id IN (
- SELECT pack_id
- FROM pack_contributable_entries
- WHERE contributable_id = ? AND contributable_type = ? )"
-
- return Pack.find_by_sql([ sql, self.id, self.class.to_s ])
- end
end
end
end
Deleted: trunk/policy_fixer.rb (2112 => 2113)
--- trunk/policy_fixer.rb 2009-02-24 14:07:34 UTC (rev 2112)
+++ trunk/policy_fixer.rb 2009-03-05 12:15:46 UTC (rev 2113)
@@ -1,15 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/config/environment'
-# test methods are in /lib/policy_consistency_fixer.rb
-require File.dirname(__FILE__) + '/lib/maintenance/policy_consistency_fixer'
-
-include Maintenance
-
-# Policy sanity checks and fixes (where necessary)
-
-# NB! THIS SCRIPT WILL UPDATE THE STATE OF THE DATABASE,
-# IF ANY INCONSISTENCIES ARE FOUND
-# (see inside of the checker script for details)
-
-# run 'sanity_tests' and output the returned results string
-check_and_fix_policies()