Permalink
Browse files

Merge branch 'master' into favicon-test

  • Loading branch information...
2 parents 91ff2cd + b4a61fa commit 1f2a7d820af6a4ae04a0182e1c5cb762968aa244 @adahmash adahmash committed Apr 10, 2012
@@ -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"
@@ -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?
@@ -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
@@ -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] } }
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
Oops, something went wrong.

0 comments on commit 1f2a7d8

Please sign in to comment.