Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' into favicon-test

  • Loading branch information...
commit 1f2a7d820af6a4ae04a0182e1c5cb762968aa244 2 parents 91ff2cd + b4a61fa
@adahmash adahmash authored
View
1  app/controllers/admin/view_objects_controller.rb
@@ -3,7 +3,6 @@ class Admin::ViewObjectsController < AdminController
admin_scaffold :view_object do |config|
config.index_fields = [:name, :view_object_template_id]
- #config.show_fields = [:name, :view_object_template_id]
config.actions = [:index]
config.associations = { :belongs_to => { :view_object_template => :view_object_template_id } }
config.order_by = "name asc"
View
2  app/controllers/admin/widgets_controller.rb
@@ -47,7 +47,7 @@ def newer_widgets
]
@page = ViewObject.find_by_name("home--index")
@view_objects = ViewObject.find(:all, :conditions => ["view_object_template_id is not null"])
- @editable_view_objects = ["v2_double_col_feature_triple_item", "v2_double_col_triple_item", "v2_triple_col_large_2"].map {|name| ViewObjectTemplate.find_by_name(name) }.map(&:view_objects).flatten.select {|vo| vo.setting.kommands.empty? }
+ #@editable_view_objects = ["v2_double_col_feature_triple_item", "v2_double_col_triple_item", "v2_triple_col_large_2"].map {|name| ViewObjectTemplate.find_by_name(name) }.map(&:view_objects).flatten.select {|vo| vo.setting.kommands.empty? }
@main = Widget.main
@sidebar = Widget.sidebar
if @page.present? and @page.edge_children.present?
View
6 app/controllers/admin_controller.rb
@@ -160,7 +160,11 @@ def find_moderatable_item
if name =~ /(.+)_id$/
# switch story requests to use the content model
klass = $1 == 'story' ? 'content' : $1
- return klass.classify.constantize.find(value)
+ if klass.classify == "CustomWidget"
+ return Metadata::CustomWidget.find(value)
+ else
+ return klass.classify.constantize.find(value)
+ end
end
end
nil
View
3  app/models/metadata/custom_widget.rb
@@ -1,4 +1,7 @@
class Metadata::CustomWidget < Metadata
+
+ acts_as_moderatable
+
metadata_keys :title, :custom_data, :content_type
scope :key_sub_type_name, lambda { |*args| { :conditions => ["key_sub_type = ? AND key_name = ?", args.first, args.second] } }
View
2  app/models/view_object.rb
@@ -1,5 +1,7 @@
class ViewObject < ActiveRecord::Base
+ acts_as_moderatable
+
belongs_to :view_object_template
belongs_to :parent, :class_name => "ViewObject", :foreign_key => :parent_id
has_one :setting, :class_name => "Metadata", :as => :metadatable
View
1  app/views/admin/view_objects/edit.html.haml
@@ -100,6 +100,7 @@
= label_tag 'view_object_setting[cache_disabled]', 'Disable Caching', :class => "label" do
= check_box_tag 'view_object_setting[cache_disabled]', 1, @view_object_setting.cache_disabled
Disable Caching
+ %li= link_to(@view_object.blocked? ? 'UnBlock' : 'Block', admin_block_path(@view_object.class.name.foreign_key.to_sym => @view_object))
= field_set_tag nil, :class => 'buttons' do
%ol
View
4 app/views/admin/view_objects/show.html.haml
@@ -9,7 +9,7 @@
%p== Locale Title Text: #{t(@view_object_setting.locale_title.try(:to_sym)) || @view_object_setting.locale_title}
- if @view_object_setting.locale_subtitle.present?
%p== Locale Subtitle Text: #{t(@view_object_setting.locale_subtitle.to_sym) || @view_object_setting.locale_subtitle}
- - unless @view_object_setting.is_curated
+ - unless @view_object_setting.is_curated or @view_object_setting.kommands.empty?
%p== Model Resource: #{@view_object_setting.klass_name.tableize.titleize}
- kommand = @view_object_setting.kommands.first
%p== Model Method: #{kommand[:method_name].titleize}
@@ -33,6 +33,8 @@
- else
= link_to "Edit", edit_admin_view_object_path(@view_object)
|
+ = link_to(@view_object.blocked? ? 'UnBlock' : 'Block', admin_block_path(@view_object.class.name.foreign_key.to_sym => @view_object))
+ |
= link_to "Clone", clone_admin_view_object_path(@view_object)
-#
%h2 Update View Object
View
17 db/migrate/20120408023719_change_view_object_template_names.rb
@@ -0,0 +1,17 @@
+class ChangeViewObjectTemplateNames < ActiveRecord::Migration
+ def up
+ ViewObjectTemplate.all.each do |t|
+ pn = String.new(t.pretty_name)
+ pn = pn.replace(pn[10..100] + "(#{pn[0..8]})") unless !pn.match(/^Version.*/)
+ t.update_attribute :pretty_name, pn unless pn.nil?
+ end
+ end
+
+ def down
+ ViewObjectTemplate.all.each do |t|
+ pn = String.new(t.pretty_name)
+ pn = pn.replace(pn[(pn.length-10)..(pn.length-2)] + " " + pn[0,(pn.length-11)]) unless !pn.match(/.?\(Version 2|3\)$/)
+ t.update_attribute :pretty_name, pn unless pn.nil?
+ end
+ end
+end
View
20 db/migrate/20120409185035_remove_old_vo_templates.rb
@@ -0,0 +1,20 @@
+class RemoveOldVoTemplates < ActiveRecord::Migration
+ def up
+ template_names = ["v2_single_col_list",
+ "v2_triple_col_large_2",
+ "v2_double_col_feature",
+ "v2_single_col_small_list",
+ "v2_single_col_item",
+ "v2_double_col_item",
+ "v2_double_col_item_list",
+ "v2_double_col_triple_item",
+ "v2_double_col_feature_triple_item"]
+ template_names.each do |tn|
+ tn = ViewObjectTemplate.find_by_name(tn)
+ tn.destroy
+ end
+ end
+
+ def down
+ end
+end
View
6 db/migrate/20120409195722_add_is_blockable_to_view_objects.rb
@@ -0,0 +1,6 @@
+class AddIsBlockableToViewObjects < ActiveRecord::Migration
+ def change
+ add_column :view_objects, :is_blocked, :boolean, :default => false
+ add_index :view_objects, :is_blocked
+ end
+end
View
6 db/migrate/20120409203626_add_is_blockable_to_metadatas.rb
@@ -0,0 +1,6 @@
+class AddIsBlockableToMetadatas < ActiveRecord::Migration
+ def change
+ add_column :metadatas, :is_blocked, :boolean, :default => false
+ add_index :metadatas, :is_blocked
+ end
+end
View
115 db/seeds.rb
@@ -495,108 +495,49 @@
[
{
:name => "v2_welcome_panel",
- :pretty_name => "Version 2 Welcome Panel",
+ :pretty_name => "Welcome Panel (Version 2)",
:template => "shared/templates/single_col_welcome_panel",
:min_items => nil,
:max_items => nil
},
{
- :name => "v2_single_col_list",
- :pretty_name => "Version 2 Single Column List",
- :template => "shared/templates/single_col_list",
- :min_items => 1
- },
- {
:name => "v2_single_col_list_with_profile",
- :pretty_name => "Version 2 Single Column List With Profile",
+ :pretty_name => "Single Column List With Profile (Version 2)",
:template => "shared/templates/single_col_list_with_profile",
:min_items => 1
},
{
:name => "v2_single_facebook_widget",
- :pretty_name => "Version 2 Single Column Facebook Widget",
+ :pretty_name => "Single Column Facebook Widget (Version 2)",
:template => "shared/templates/single_col_facebook_widget",
:min_items => nil,
:max_items => nil
},
{
- :name => "v2_triple_col_large_2",
- :pretty_name => "Version 2 Triple Column Large Feature With 2 Sub Items",
- :template => "shared/templates/triple_col_large_2",
- :min_items => 3,
- :max_items => 3
- },
- {
- :name => "v2_double_col_feature",
- :pretty_name => "Version 2 Double Column Feature",
- :template => "shared/templates/double_col_feature",
- :min_items => 1,
- :max_items => 1
- },
- {
:name => "v2_single_col_user_list",
- :pretty_name => "Version 2 Single Column User List",
+ :pretty_name => "Single Column User List (Version 2)",
:template => "shared/templates/single_col_user_list",
:min_items => 1
},
{
- :name => "v2_single_col_small_list",
- :pretty_name => "Version 2 Single Column Small List",
- :template => "shared/templates/single_col_small_list",
- :min_items => 1
- },
- {
:name => "v2_single_col_gallery_strip",
- :pretty_name => "Version 2 Single Column Gallery Strip",
+ :pretty_name => "Single Column Gallery Strip (Version 2)",
:template => "shared/templates/single_col_gallery_strip",
:min_items => 1
},
{
- :name => "v2_single_col_item",
- :pretty_name => "Version 2 Single Column Item",
- :template => "shared/templates/single_col_item",
- :min_items => 1,
- :max_items => 1
- },
- {
- :name => "v2_double_col_item",
- :pretty_name => "Version 2 Double Column Item",
- :template => "shared/templates/double_col_item",
- :min_items => 1,
- :max_items => 1
- },
- {
- :name => "v2_double_col_item_list",
- :pretty_name => "Version 2 Double Column Item List",
- :template => "shared/templates/double_col_item_list",
- :min_items => 1
- },
- {
:name => "v2_single_col_gallery_big_image",
- :pretty_name => "Version 2 Single Column Gallery Big Image",
+ :pretty_name => "Single Column Gallery Big Image (Version 2)",
:template => "shared/templates/single_col_gallery_big_image",
:min_items => 1
},
{
:name => "v2_double_col_gallery_strip",
- :pretty_name => "Version 2 Double Column Gallery Strip",
+ :pretty_name => "Double Column Gallery Strip (Version 2)",
:template => "shared/templates/double_col_gallery_strip",
:min_items => 1
},
{
- :name => "v2_double_col_triple_item",
- :pretty_name => "Version 2 Double Column Triple Item",
- :template => "shared/templates/double_col_triple_item",
- :min_items => 3,
- :max_items => 3
- },
- {
- :name => "v2_double_col_feature_triple_item",
- :pretty_name => "Version 2 Double Column Feature With Triple Item",
- :template => "shared/templates/double_col_feature_triple_item",
- :min_items => 1
- },
- {
:name => "twitter_standard_list",
:pretty_name => "Twitter Standard List",
:template => "shared/sidebar/twitter_standard_list",
@@ -626,28 +567,28 @@
},
{
:name => "v2_ad_template",
- :pretty_name => "Version 2 Ad Template",
+ :pretty_name => "Ad Template (Version 2)",
:template => "shared/templates/ad_template",
:min_items => nil,
:max_items => nil
},
{
:name => "v2_single_col_custom_widget",
- :pretty_name => "Version 2 Single Column Custom Widget",
+ :pretty_name => "Single Column Custom Widget (Version 2)",
:template => "shared/templates/single_col_custom_widget",
:min_items => nil,
:max_items => nil
},
{
:name => "v2_double_col_custom_widget",
- :pretty_name => "Version 2 Double Column Custom Widget",
+ :pretty_name => "Double Column Custom Widget (Version 2)",
:template => "shared/templates/double_col_custom_widget",
:min_items => nil,
:max_items => nil
},
{
:name => "v2_triple_col_custom_widget",
- :pretty_name => "Version 2 Triple Column Custom Widget",
+ :pretty_name => "Triple Column Custom Widget (Version 2)",
:template => "shared/templates/triple_col_custom_widget",
:min_items => nil,
:max_items => nil
@@ -655,115 +596,115 @@
# V3 widgets
{
:name => "v3_triple_col_1_large_4_small",
- :pretty_name => "Version 3 Triple Column 1 Large 4 Small Widget",
+ :pretty_name => "Triple Column 1 Large 4 Small Widget (Version 3)",
:template => "shared/templates/v3/triple_col_1_large_4_small",
:min_items => 5,
:max_items => 5
},
{
:name => "v3_triple_col_2_large",
- :pretty_name => "Version 3 Triple Column 2 Large Widget",
+ :pretty_name => "Triple Column 2 Large Widget (Version 3)",
:template => "shared/templates/v3/triple_col_2_large",
:min_items => 2,
:max_items => 2
},
{
:name => "v3_triple_col_1_large_2_small_3_links",
- :pretty_name => "Version 3 Triple Column 1 Large 2 Small 3 Links Widget",
+ :pretty_name => "Triple Column 1 Large 2 Small 3 Links Widget (Version 3)",
:template => "shared/templates/v3/triple_col_1_large_2_small_3_links",
:min_items => 6,
:max_items => 6
},
{
:name => "v3_triple_col_2_medium_2_links",
- :pretty_name => "Version 3 Triple Column 2 medium 2 links",
+ :pretty_name => "Triple Column 2 medium 2 links (Version 3)",
:template => "shared/templates/v3/triple_col_2_medium_2_links",
:min_items => 4,
:max_items => 4
},
{
:name => "v3_double_col_1_large_2_small",
- :pretty_name => "Version 3 Double Column 1 Large 2 Small",
+ :pretty_name => "Double Column 1 Large 2 Small (Version 3)",
:template => "shared/templates/v3/double_col_1_large_2_small",
:min_items => 3,
:max_items => 3
},
{
:name => "v3_double_col_2_medium",
- :pretty_name => "Version 3 Double Column 2 Medium",
+ :pretty_name => "Double Column 2 Medium (Version 3)",
:template => "shared/templates/v3/double_col_2_medium",
:min_items => 2,
:max_items => 2
},
{
:name => "v3_double_col_2_small_3_medium_links",
- :pretty_name => "Version 3 Double Column 2 small 3 medium links",
+ :pretty_name => "Double Column 2 small 3 medium links (Version 3)",
:template => "shared/templates/v3/double_col_2_small_3_medium_links",
:min_items => 5,
:max_items => 5
},
{
:name => "v3_double_col_3_medium_links_2_small",
- :pretty_name => "Version 3 Double Column 3 Medium Links 2 Small",
+ :pretty_name => "Double Column 3 Medium Links 2 Small (Version 3)",
:template => "shared/templates/v3/double_col_3_medium_links_2_small",
:min_items => 5,
:max_items => 5
},
{
:name => "v3_double_col_2_medium_links_1_medium",
- :pretty_name => "Version 3 Double Column 2 Medium Links 1 Medium",
+ :pretty_name => "Double Column 2 Medium Links 1 Medium (Version 3)",
:template => "shared/templates/v3/double_col_2_medium_links_1_medium",
:min_items => 3,
:max_items => 3
},
{
:name => "v3_double_col_1_medium_2_medium_links",
- :pretty_name => "Version 3 Double Column 1 Medium 2 Medium Links",
+ :pretty_name => "Double Column 1 Medium 2 Medium Links (Version 3)",
:template => "shared/templates/v3/double_col_1_medium_2_medium_links",
:min_items => 3,
:max_items => 3
},
{
:name => "v3_double_col_item_list",
- :pretty_name => "Version 3 Double Column Item List",
+ :pretty_name => "Double Column Item List (Version 3)",
:template => "shared/templates/v3/double_col_item_list",
:min_items => 5
},
{
:name => "v3_single_col_featured_item",
- :pretty_name => "Version 3 Single Column Featured Item",
+ :pretty_name => "Single Column Featured Item (Version 3)",
:template => "shared/templates/v3/single_col_featured_item",
:min_items => 1,
:max_items => 1
},
{
:name => "v3_single_col_medium",
- :pretty_name => "Version 3 Single Column Medium",
+ :pretty_name => "Single Column Medium (Version 3)",
:template => "shared/templates/v3/single_col_medium",
:min_items => 1,
:max_items => 1
},
{
:name => "v3_single_col_item_list",
- :pretty_name => "Version 3 Single Column Item List",
+ :pretty_name => "Single Column Item List (Version 3)",
:template => "shared/templates/v3/single_col_item_list",
:min_items => 1
},
{
:name => "v3_single_col_post_story",
- :pretty_name => "Version 3 Single Column Post Story",
+ :pretty_name => "Single Column Post Story (Version 3)",
:template => "shared/templates/v3/single_col_post_story"
},
{
:name => "v3_triple_col_3_medium",
- :pretty_name => "Version 3 Triple Column 3 Medium Skybox",
+ :pretty_name => "Triple Column 3 Medium Skybox (Version 3)",
:template => "shared/templates/v3/triple_col_3_medium",
:min_items => 3,
:max_items => 3
},
{
:name => "v3_triple_col_4_small",
- :pretty_name => "Version 3 Triple Column 4 Small Skybox",
+ :pretty_name => "Triple Column 4 Small Skybox (Version 3)",
:template => "shared/templates/v3/triple_col_4_small",
:min_items => 4,
:max_items => 4
View
4 lib/view_tree.rb
@@ -73,11 +73,11 @@ def render_string
end
def render
- if @cache and out = Newscloud::Redcloud.redis.get(@cache_key_name) and out.present?
+ if @cache and out = Newscloud::Redcloud.redis.get(@cache_key_name) and out.present? and !out.is_blocked?
return out
else
load_view_object
- return '' unless @view_object
+ return '' unless @view_object and !@view_object.is_blocked?
uncache_it
end
Please sign in to comment.
Something went wrong with that request. Please try again.