Permalink
Browse files

Bug on content show

  • Loading branch information...
1 parent 4a6294e commit 5a1eaa5e9281081e94005c0333e8ccfa14ea62af @anupnivargi anupnivargi committed Feb 16, 2010
@@ -17,10 +17,8 @@ def index
def analytics_datas
websites = Website.allowed_user_with_permission(@current_user, "website_show", 'website')
-
@websites_datas = []
website_datas = {}
-
if File.exist?("#{RAILS_ROOT}/config/customs/google_analytics.yml")
analytic_config = YAML.load_file("#{RAILS_ROOT}/config/customs/google_analytics.yml")
if Analytic.setup(analytic_config['sa_analytic_login'], analytic_config['sa_analytic_password'])
@@ -72,4 +70,4 @@ def error
end
-end
+end
@@ -1,4 +1,6 @@
module ApplicationHelper
+ #include TagLib
+
def layout(website)
if WEBSITE_TEMPLATES.include?(website.template)
render :file => WEBSITE_TEMPLATES_FOLDER + "/" + website.template + "/layout.html.erb"
@@ -8,4 +10,10 @@ def layout(website)
render :text => "No Layout Defined"
end
end
+
+# def liquidize(content)
+# @template = Liquid::Template.parse(content)
+# @template.render('page_title' => page_title,
+# 'page_body' => (render :partial => 'page'))
+# end
end
View
@@ -58,12 +58,13 @@ def acts_as_authorizable
named_scope :matching_user_with_permission_in_containers, lambda { |user, permission, container_ids, container|
# Check if these workspace are matching the really authorized ones, and set 'nil for all' condition
#@container_ids ||= container.classify.constantize.allowed_user_with_permission(user, self.to_s.underscore + '_' + permission, container).find(:all, :select => "#{container.pluralize}.id, #{container.pluralize}.title").map{ |e| e.id.to_i }
- @container_ids ||= container.classify.constantize.find_by_container_and_permissions(user, self.to_s.underscore + '_' + permission, container).map{ |e| e.id.to_i }
+ container_ids ||= container.classify.constantize.find_by_container_and_permissions(user, self.to_s.underscore + '_' + permission, container).map{ |e| e.id.to_i }
+ container_ids = container_ids.map{|w_id| w_id.to_i} & container.classify.constantize.find_by_container_and_permissions(user, self.to_s.underscore + '_' + permission, container).map{ |e| e.id.to_i }
# So we can retrieve directly as the workspaces are checked, hihihi
- if @container_ids.first
+ if container_ids.first
{ :select => "DISTINCT #{self.to_s.underscore.pluralize}.*",
:joins => "LEFT JOIN items_#{container.pluralize} ON #{self.to_s.underscore.pluralize}.id = items_#{container.pluralize}.itemable_id AND items_#{container.pluralize}.itemable_type='#{self.to_s}'",
- :conditions => "items_#{container.pluralize}.#{container}_id IN (#{@container_ids.join(',')})"}
+ :conditions => "items_#{container.pluralize}.#{container}_id IN (#{container_ids.join(',')})"}
else
# In order to return nothing ...
{ :conditions => "1=2"}
@@ -73,14 +74,15 @@ def acts_as_authorizable
elsif CONTAINERS.include?(self.to_s.underscore)
named_scope :matching_user_with_permission_in_containers, lambda { |user, permission, container_ids, container|
# Check if these workspace are matching the really authorized ones, and set 'nil for all' condition
- @container_ids ||= container.classify.constantize.find_by_container_and_permissions(user, container + '_' + permission, container).map{ |e| e.id.to_i }
+ container_ids ||= container.classify.constantize.find_by_container_and_permissions(user, container + '_' + permission, container).map{ |e| e.id.to_i }
+ container_ids = container_ids.map{|w_id| w_id.to_i} & container.classify.constantize.find_by_container_and_permissions(user, self.to_s.underscore + '_' + permission, container).map{ |e| e.id.to_i }
# In case of system permission
if user.has_system_permission(container, permission)
{ }
# So we can retrieve directly as the workspaces are checked, hihihi
- elsif @container_ids.first
+ elsif container_ids.first
{
- :conditions => "id IN (#{@container_ids.join(',')})"
+ :conditions => "id IN (#{container_ids.join(',')})"
}
else
# In order to return nothing ...
@@ -119,15 +121,16 @@ def acts_as_authorizable
elsif ['user'].include?(self.to_s.underscore)
named_scope :matching_user_with_permission_in_containers, lambda { |user, permission, container_ids, container|
# Check if these workspace are matching the really authorized ones, and set 'nil for all' condition
- @container_ids ||= container.classify.constantize.find_by_container_and_permissions(user, self.to_s.underscore+'_'+permission, container).map{ |e| e.id.to_i }
+ container_ids ||= container.classify.constantize.find_by_container_and_permissions(user, self.to_s.underscore+'_'+permission, container).map{ |e| e.id.to_i }
+ container_ids = container_ids.map{|w_id| w_id.to_i} & container.classify.constantize.find_by_container_and_permissions(user, self.to_s.underscore + '_' + permission, container).map{ |e| e.id.to_i }
# In case of system permission
if user.has_system_permission(self.to_s.underscore, permission)
{}
# So we can retrieve directly as the workspaces are checked, hihihi
- elsif @container_ids.first
+ elsif container_ids.first
{ :select => "DISTINCT #{self.to_s.underscore.pluralize}.*",
:joins => "LEFT JOIN users_containers ON #{self.to_s.underscore.pluralize}.id = users_containers.user_id",
- :conditions => "users_containers.#{container}_id IN (#{@container_ids.join(',')})" }
+ :conditions => "users_containers.#{container}_id IN (#{container_ids.join(',')})" }
else
# In order to return nothing ...
{ :conditions => "1=2"}
View
@@ -25,7 +25,7 @@ module InstanceMethods
# Usage :
# <tt>user.system_role</tt>
def system_role
- @role ||= Role.find(self.system_role_id, :include => :permissions)
+ @role ||= Role.find(self.system_role_id)
end
# Method returning true if the user has the system role passed in params, false else
View
@@ -1,5 +1,19 @@
module TagLib
+# class Item < Liquid::Tag
+# def initialize(tag_name, markup, tokens)
+# super
+# p markup
+# @args = markup
+# end
+
+# def render(context)
+# articles(:field => @field, :order => @order, :limit => @limit)
+# end
+# end
+# Liquid::Template.register_tag('items', Item)
+
+
def page_title
result ||= @site_page || @item || @current_website
return result.title
@@ -68,5 +82,4 @@ def build_params(options)
:containers => {:website => [@current_website.id.to_s]}
}
end
-
end
@@ -105,15 +105,11 @@ def acts_as_item &block
# Makes `current_user` as author for the current_object
before :create do
# Trick used in case there is no params (meaning none is selected)
- p ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>."
- p params
params[@current_object.class.to_s.underscore][:keywords_field] ||= []
current_object.user_id = current_user.id
end
# Filter setting the keywords value in case the list is empty (else the application will think there is no field ...)
before :update do
- p ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>."
- p params
params[@current_object.class.to_s.underscore][:keywords_field] ||= []
end
#

0 comments on commit 5a1eaa5

Please sign in to comment.