Merge branch 'design_team' into ldap

Conflicts:
	app/controllers/admin/page_parts_controller.rb
	vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter.html.erb
	vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_sort_headers.html.erb
This commit is contained in:
Christophe Vilayphiou committed 2012-04-30 07:57:20 +08:00
commit 20504b2205
213 files changed
+5215 -779

No files matched your search

@@ -2,7 +2,7 @@ class Admin::ModuleAppsController < ApplicationController
before_filter :user_has_manager_privilege?, :only => [ :assign_manager, :remove_manager ]
before_filter :user_has_sub_manager_privilege?, :only => [ :assign_sub_manager, :remove_sub_manager ]
layout "admin"
layout "new_admin"
def index
@module_apps = ModuleApp.all.entries
@@ -1,6 +1,6 @@
class Admin::ObjectAuthsController < ApplicationController
include OrbitCoreLib::PermissionUnility
layout "admin"
layout "new_admin"
before_filter :force_order
# before_filter :is_admin? ,:only => :index
+11 -7
View File
@@ -27,8 +27,10 @@ class Admin::PagePartsController < ApplicationController
@r_tag = @part.public_r_tag.blank? ? LIST[:public_r_tags][0] : @part.public_r_tag
@tag_objects = @r_tag.classify.constantize.all rescue nil
case @module_app.key
when 'bulletin'
when 'announcement'
@categories = BulletinCategory.all
when 'news'
@categories = NewsBulletinCategory.all
when 'web_resource'
@categories = WebLinkCategory.all
end
@@ -65,12 +67,14 @@ class Admin::PagePartsController < ApplicationController
def reload_widgets
@categories =[]
@module_app = ModuleApp.find(params[:id])
unless (@module_app.category.nil? rescue true)
@module_app.category.each do |category|
@categories << eval(category).all.entries
end
@categories.flatten!
case @module_app.key
when 'announcement'
@categories = BulletinCategory.all
when 'news'
@categories = NewsBulletinCategory.all
when 'web_resource'
@categories = WebLinkCategory.all
end
respond_to do |format|
+12 -1
View File
@@ -31,7 +31,18 @@ class Admin::PagesController < ApplicationController
@designs = Design.all.entries
@design = @item.design ? @item.design : @designs.first
@app_frontend_urls = @item.module_app.app_pages if @item.module_app
@categories = BulletinCategory.all if @item.module_app && @item.module_app.key.eql?('announcement')
if @item.module_app
case @item.module_app.key
when 'announcement'
@categories = BulletinCategory.all
when 'news'
@categories = NewsBulletinCategory.all
when 'web_resource'
@categories = WebLinkCategory.all
end
else
@categories = nil
end
end
def create
+133 -2
View File
@@ -12,7 +12,7 @@ class OrbitBackendController< ApplicationController
@app_title = request.fullpath.split('/')[2]
@module_app = ModuleApp.first(conditions: {:key => @app_title} )
end
private
def force_order
@@ -22,8 +22,139 @@ class OrbitBackendController< ApplicationController
def check_user_can_use
unless check_permission
redirect_to polymorphic_path(['panel',@app_title,'back_end','public'])
#redirect_to polymorphic_path(['panel',@app_title,'back_end','public'])
render :text => '403 Forbidden'
end
end
def get_sorted_and_filtered(object_class)
object_class = object_class.classify.constantize
objects = object_class.all
if !params[:sort].blank?
options = params[:sort_options]
options = [options] if !options.class.eql?(Array)
options.each do |option|
if object_class.fields.include?(option)
case object_class.fields[option].type.to_s
when 'BigDecimal', 'Boolean', 'Date', 'DateTime', 'Float', 'Integer', 'String', 'Symbol', 'Time'
(objects = objects.order_by(option, params[:direction])) rescue nil
when 'Object'
objects = get_objects_from_referenced_objects(object_class.fields[option].options[:class_name].constantize, objects, option)
end
elsif object_class.relations.include?(option)
case object_class.relations[option].macro
when :references_one
a = Array.new
objects.each { |object| a << [get_string_value_from_object(object), object] }
sorted = params[:direction].eql?('asc') ? a.sort : a.sort.reverse!
objects = sorted.collect {|x| x[1] }
when :references_many, :references_and_referenced_in_many
objects = get_objects_from_self(object_class, objects, option)
when :referenced_in
objects = get_objects_from_referenced_objects(object_class.relations[option].class_name.constantize, objects, "#{option}_id")
end
end
end
end
if @filter
@filter.each do |key, value|
case key
when 'status'
a = Array.new
objects.each do |bulletin|
value.each do |v|
case v
when 'pending'
a << bulletin if bulletin.is_checked.nil?
when 'rejected'
a << bulletin if bulletin.is_checked.eql?(false)
else
a << bulletin if bulletin[v]
end
end
end
objects = a.uniq
when 'categories'
a = Array.new
objects.each do |bulletin|
a << bulletin if value.include?(bulletin.bulletin_category.id.to_s)
end
objects = a.uniq
when 'tags'
a = Array.new
objects.each do |bulletin|
bulletin.tags.each do |tag|
a << bulletin if value.include?(tag.id.to_s)
end
end
objects = a.uniq
end if value.size > 0
end
end
Kaminari.paginate_array(objects).page(params[:page]).per(10)
end
def get_string_value_from_object(object)
s = object[I18n.locale] rescue nil
s = object.i18n_variable unless s rescue nil
s = object.name unless s rescue nil
s = object.title unless s rescue nil
if s
case s.class.to_s
when "String"
s.downcase
when "I18nVariable"
s[I18n.locale].downcase
else
nil
end
end
end
def get_objects_from_referenced_objects(object_class, objects, option)
referer_ids = objects.distinct(option)
referenced_objects = object_class.find(referer_ids) rescue nil
if referenced_objects
a = Array.new
referenced_objects.each { |referer| a << [get_string_value_from_object(referer), referer.id] }
sorted = params[:direction].eql?('asc') ? a.sort : a.sort.reverse!
sorted_objects = sorted.collect {|x| objects.where(option => x[1]).entries }
sorted_objects.flatten!
sorted_objects.uniq!
get_with_nil(objects, option, sorted_objects)
else
objects
end
end
def get_objects_from_self(object_class, objects, option)
referenced_class = object_class.relations[option].class_name.constantize
referenced_objects = referenced_class.all rescue nil
if referenced_objects
reverse_relation = nil
referenced_class.relations.each { |relation| reverse_relation = relation[1].name.to_s if relation[1].class_name.eql?(object_class.to_s) }
a = Array.new
referenced_objects.each { |referenced_object| a << [get_string_value_from_object(referenced_object), referenced_object] }
a.compact!
sorted = params[:direction].eql?('asc') ? a.sort : a.sort.reverse!
sorted_objects = Array.new
sorted.each {|x| sorted_objects << x[1].send(reverse_relation) }
sorted_objects.flatten!
sorted_objects.uniq!
get_with_nil(objects, option, sorted_objects)
else
objects
end
end
def get_with_nil(objects, option, sorted_objects)
tmp = Array.new
objects.each { |object| tmp << [get_string_value_from_object(object), object] if (object.send(option).count == 0) }
sorted = params[:direction].eql?('asc') ? tmp.sort : tmp.sort.reverse!
sorted_tmp = sorted.collect {|a| a[1] }
a = params[:direction].eql?('asc') ? (sorted_tmp + sorted_objects) : (sorted_objects + sorted_tmp)
a.flatten
end
end
+6 -6
View File
@@ -33,9 +33,9 @@ class PagesController < ApplicationController
def index_from_link
if params[:page]
redirect_to "/#{@item.full_name}?page=#{params[:page]}"
redirect_to "/#{@item.full_name}?page=#{params[:page]}&category_id=#{params[:category_id]}&tag_id=#{params[:tag_id]}"
else
redirect_to "/#{@item.full_name}"
redirect_to "/#{@item.full_name}?category_id=#{params[:category_id]}&tag_id=#{params[:tag_id]}"
end
end
@@ -51,11 +51,11 @@ class PagesController < ApplicationController
def get_item
module_app = ModuleApp.first(:conditions => {:key => params[:app_name]})
if params[:category_id]
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id]})
else
# if params[:category_id]
# @item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id]})
# else
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action]})
end
# end
end
end