Merge branch 'new_member' of github.com:Rulingcom/orbit into new_member
Conflicts: app/helpers/attribute_fields_helper.rb app/views/admin/infos/_form.html.erb config/locales/zh_tw.yml
This commit is contained in:
commit
b4a2737407
373 files changed
+10342
-6551
No files matched your search
@@ -41,7 +41,7 @@ class Admin::AdImagesController < OrbitBackendController
|
||||
@ad_banner = AdBanner.find params[:ad_banner_id]
|
||||
@ad_image = @ad_banner.ad_images.find params[:id]
|
||||
if @ad_image.destroy
|
||||
flash[:notice] = t('admin.success_destroy_ad_image')
|
||||
flash[:notice] = t('ad.success_destroy_ad_image')
|
||||
redirect_to admin_ad_banner_path @ad_banner
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,7 +25,7 @@ class Admin::AssetCategoriesController < OrbitBackendController
|
||||
|
||||
respond_to do |format|
|
||||
if @asset_category.save
|
||||
format.html { redirect_to(admin_asset_categories_url, :notice => t('announcement.create_asset_category_success')) }
|
||||
format.html { redirect_to(admin_asset_categories_url, :notice => t('create.success.asset_category')) }
|
||||
format.js
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
@@ -41,8 +41,8 @@ class Admin::AssetCategoriesController < OrbitBackendController
|
||||
|
||||
respond_to do |format|
|
||||
if @asset_category.update_attributes(params[:asset_category])
|
||||
# format.html { redirect_to(panel_announcement_back_end_asset_category_url(@asset_category), :notice => t('asset_category.update_asset_category_success')) }
|
||||
# format.html { redirect_to(panel_announcement_back_end_asset_categories_url, :notice => t('asset_category.update_asset_category_success')) }
|
||||
# format.html { redirect_to(panel_announcement_back_end_asset_category_url(@asset_category), :notice => t('create.success')) }
|
||||
# format.html { redirect_to(panel_announcement_back_end_asset_categories_url, :notice => t('create.success')) }
|
||||
# format.xml { head :ok }
|
||||
format.js
|
||||
else
|
||||
|
||||
@@ -44,7 +44,7 @@ class Admin::AssetsController < OrbitBackendController
|
||||
# render :json=>{"url"=>@asset.data.url,"title"=>"xxx","desc"=>"sss"}.to_json
|
||||
render :layout=>false
|
||||
else
|
||||
flash[:error] = t(:create_fail)
|
||||
flash[:error] = t('create.fail')
|
||||
@asset_categories = AssetCategory.all
|
||||
@tags = AssetTag.all
|
||||
respond_to do |format|
|
||||
@@ -67,7 +67,7 @@ class Admin::AssetsController < OrbitBackendController
|
||||
format.js { render 'js/remove_pop_up_and_reload_content', :locals => {:function => 'replaceWith', :id => "asset_#{@asset.id}", :value => @asset, :values => nil, :partial => 'admin/assets/asset', :locals => nil} }
|
||||
end
|
||||
else
|
||||
flash[:error] = t(:update_fail)
|
||||
flash[:error] = t('update.fail')
|
||||
@asset_categories = AssetCategory.all
|
||||
@tags = AssetTag.all
|
||||
respond_to do |format|
|
||||
@@ -105,4 +105,8 @@ class Admin::AssetsController < OrbitBackendController
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
def check_permission
|
||||
true
|
||||
end
|
||||
|
||||
end
|
||||
@@ -4,7 +4,6 @@ class Admin::ItemsController < ApplicationController
|
||||
|
||||
before_filter :authenticate_user!
|
||||
before_filter :find_parent_item
|
||||
before_filter :find_snippets, :only => :index
|
||||
before_filter :is_admin?
|
||||
before_filter :set_current_item
|
||||
|
||||
@@ -22,10 +21,4 @@ class Admin::ItemsController < ApplicationController
|
||||
render :nothing => true
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def find_snippets
|
||||
@snippets = Snippet.where( { :parent_id => @parent_item.id } ) rescue nil
|
||||
end
|
||||
|
||||
end
|
||||
@@ -23,7 +23,7 @@ class Admin::LinksController < ApplicationController
|
||||
@item = Link.new(params[:link])
|
||||
|
||||
if @item.save
|
||||
flash.now[:notice] = t('admin.create_success_link')
|
||||
flash.now[:notice] = t('create.success.link')
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
redirect_to admin_link_url(@item)
|
||||
@@ -31,7 +31,7 @@ class Admin::LinksController < ApplicationController
|
||||
format.js {}
|
||||
end
|
||||
else
|
||||
flash.now[:error] = t('admin.create_error_link')
|
||||
flash.now[:error] = t('create.error.link')
|
||||
render :action => "new"
|
||||
end
|
||||
end
|
||||
@@ -40,7 +40,7 @@ class Admin::LinksController < ApplicationController
|
||||
@item = Link.find(params[:id])
|
||||
|
||||
if @item.update_attributes(params[:link])
|
||||
flash.now[:notice] = t('admin.update_success_link')
|
||||
flash.now[:notice] = t('update.success.link')
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
redirect_to admin_link_url(@item)
|
||||
@@ -48,7 +48,7 @@ class Admin::LinksController < ApplicationController
|
||||
format.js {}
|
||||
end
|
||||
else
|
||||
flash.now[:error] = t('admin.update_error_link')
|
||||
flash.now[:error] = t('update.error.link')
|
||||
render :action => "edit"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -66,14 +66,14 @@ class Admin::ModuleAppsController < ApplicationController
|
||||
def assign_sub_manager
|
||||
unless @assign_to_user.nil? || @assign_to_user.admin?
|
||||
if @module_app.assign_sub_manager(@assign_to_user,current_user)
|
||||
flash[:notice] = t('admin.app_auth.assigning_manager.add_sub_manager_ok')
|
||||
flash[:notice] = t('app_auth.assigning_manager.add_manager_ok')
|
||||
else
|
||||
flash[:notice] = t('admin.app_auth.assigning_manager.add_sub_manager_fail')
|
||||
flash[:notice] = t('app_auth.assigning_manager.add_manager_fail')
|
||||
end
|
||||
else
|
||||
flash[:notice] = t('admin.app_auth.assigning_manager.failed_no_user')
|
||||
flash[:notice] = t('app_auth.failed_no_user')
|
||||
end
|
||||
flash[:notice] = t('admin.app_auth.can_not_add_this_user')
|
||||
flash[:notice] = t('app_auth.can_not_add_this_user')
|
||||
redirect_to :action => "edit"
|
||||
end
|
||||
|
||||
@@ -81,14 +81,14 @@ class Admin::ModuleAppsController < ApplicationController
|
||||
def assign_manager
|
||||
unless @assign_to_user.nil? || @assign_to_user.admin?
|
||||
if @module_app.assign_manager(@assign_to_user,current_user)
|
||||
flash[:notice] = t('admin.app_auth.assigning_sub_manager.add_manager_ok')
|
||||
flash[:notice] = t('app_auth.assigning_sub_manager.add_sub_manager_ok')
|
||||
else
|
||||
flash[:notice] = t('admin.app_auth.assigning_sub_manager.add_manager_fail')
|
||||
flash[:notice] = t('app_auth.assigning_sub_manager.add_sub_manager_fail')
|
||||
end
|
||||
else
|
||||
flash[:notice] = t('admin.app_auth.assigning_sub_manager.failed_no_user')
|
||||
flash[:notice] = t('app_auth.failed_no_user')
|
||||
end
|
||||
flash[:notice] = t('admin.app_auth.can_not_add_this_user')
|
||||
flash[:notice] = t('app_auth.can_not_add_this_user')
|
||||
redirect_to :action => "edit"
|
||||
end
|
||||
|
||||
@@ -96,9 +96,9 @@ class Admin::ModuleAppsController < ApplicationController
|
||||
def remove_manager
|
||||
@app_manager = AppManager.find(params[:app_manager_id])
|
||||
if @module_app.remove_manager(@app_manager.user)
|
||||
flash[:notice] = t('admin.app_auth.delete_manager.success')
|
||||
flash[:notice] = t('app_auth.delete_manager.success')
|
||||
else
|
||||
flash[:notice] = t('admin.app_auth.delete_manager.fail')
|
||||
flash[:notice] = t('app_auth.delete_manager.fail')
|
||||
end
|
||||
redirect_to :action => "edit"
|
||||
end
|
||||
@@ -107,9 +107,9 @@ class Admin::ModuleAppsController < ApplicationController
|
||||
def remove_sub_manager
|
||||
@app_sub_manager = AppManager.find(params[:app_sub_manager_id])
|
||||
if @module_app.remove_sub_manager(@app_sub_manager.user)
|
||||
flash[:notice] = t('admin.app_auth.delete_sub_manager.success')
|
||||
flash[:notice] = t('app_auth.delete_sub_manager.success')
|
||||
else
|
||||
flash[:notice] = t('admin.app_auth.delete_sub_manager.fail')
|
||||
flash[:notice] = t('app_auth.delete_sub_manager.fail')
|
||||
end
|
||||
redirect_to :action => "edit"
|
||||
end
|
||||
@@ -123,7 +123,7 @@ class Admin::ModuleAppsController < ApplicationController
|
||||
return
|
||||
end
|
||||
#user is not permited to do that
|
||||
flash[:notice] = t('admin.app_auth.operation_not_permitted')
|
||||
flash[:notice] = t('app_auth.operation_not_permitted')
|
||||
render :nothing => true, :status => 403
|
||||
end
|
||||
|
||||
@@ -135,7 +135,7 @@ class Admin::ModuleAppsController < ApplicationController
|
||||
return
|
||||
end
|
||||
#user is not permited to do that
|
||||
flash[:notice] = t('admin.app_auth.operation_not_permitted')
|
||||
flash[:notice] = t('app_auth.operation_not_permitted')
|
||||
render :nothing => true, :status => 403
|
||||
end
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ class Admin::ModuleAppsNewInterfaceController < OrbitBackendController
|
||||
def update_setting
|
||||
module_app = update_setting_by_params
|
||||
if module_app.save!
|
||||
flash[:notice] = t("admin.object_auth.update_done")
|
||||
flash[:notice] = t('update.success_')
|
||||
else
|
||||
flash[:notice] = t("admin.object_auth.update_failed")
|
||||
flash[:notice] = t('update.fail')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class Admin::ObjectAuthsController < ApplicationController
|
||||
if @object_auth.save
|
||||
redirect_to edit_admin_object_auth_path(@object_auth)
|
||||
else
|
||||
flash[:error] = t('admin.object.a_object_must_have_only_one_object_auth_profile_for_each_action')
|
||||
flash[:error] = t('object.a_object_must_have_only_one_object_auth_profile_for_each_action')
|
||||
redirect_to (:back)
|
||||
end
|
||||
end
|
||||
@@ -91,7 +91,8 @@ private
|
||||
|
||||
def check_if_user_can_do_object_auth
|
||||
unless check_permission(:manager)
|
||||
render :nothing => true, :status => 403
|
||||
#render :nothing => true, :status => 403
|
||||
redirect_to '/'
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -7,7 +7,7 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
|
||||
|
||||
@sys_users = User.all(conditions: {admin: false}).includes(:avatar)
|
||||
@ob_auth = ObjectAuth.find params[:object_auth_id]
|
||||
@options_from_collection_for_select_ob_auth = [@ob_auth].collect{|oa| [oa.auth_obj.pp_object,oa.id] }
|
||||
@options_from_collection_for_select_ob_auth = @ob_auth.siblings.collect{|oa| [oa.auth_obj.pp_object,oa.id] }
|
||||
@users_array = @ob_auth.privilege_users rescue []
|
||||
|
||||
respond_to do |format|
|
||||
@@ -19,9 +19,9 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
|
||||
def update_setting
|
||||
ob_auth = update_setting_by_params
|
||||
if ob_auth.save!
|
||||
flash[:notice] = t("admin.object_auth.update_done")
|
||||
flash[:notice] = t('update.success_')
|
||||
else
|
||||
flash[:notice] = t("admin.object_auth.update_failed")
|
||||
flash[:notice] = t('update.fail')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -38,10 +38,12 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
|
||||
users_to_remove = oa.auth_users - user_sat
|
||||
|
||||
users_to_new.each do |new_user|
|
||||
oa.privilege_users << new_user
|
||||
oa.add_user_to_privilege_list(new_user)
|
||||
end
|
||||
|
||||
users_to_remove.each do |remove_user|
|
||||
oa.privilege_users.delete_if{|user| user == remove_user}
|
||||
oa.remove_user_from_privilege_list(remove_user)
|
||||
end
|
||||
oa
|
||||
@@ -63,8 +65,26 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
|
||||
|
||||
def check_if_user_can_do_object_auth
|
||||
unless check_permission(:manager)
|
||||
render :nothing => true, :status => 403
|
||||
redirect_to '/'
|
||||
end
|
||||
end
|
||||
|
||||
def check_permission(var)
|
||||
#app = ModuleApp.first({conditions:{key: params[:module_app_key]}})
|
||||
# setup_vars
|
||||
@module_app.is_manager?(current_user) || current_user.admin?
|
||||
end
|
||||
|
||||
def setup_vars
|
||||
if request.env['HTTP_REFERER'].split('/')[4] == "object_auths"
|
||||
@app_key = params[:app_key]
|
||||
else
|
||||
@app_key = request.env['HTTP_REFERER'].split('/')[4]
|
||||
end
|
||||
|
||||
#@app_key = request.fullpath.split('/')[1] if(@app_key == "back_end")
|
||||
@app_key.gsub!(/[?].*/,'')
|
||||
@module_app = ModuleApp.first(conditions: {:key => @app_key} )
|
||||
end
|
||||
|
||||
end
|
||||
@@ -61,7 +61,7 @@ class Admin::PagePartsController < ApplicationController
|
||||
|
||||
if @part.update_attributes(params[:page_part])
|
||||
set_children_sub_menu(@part) if @part.public_r_tag && @part.public_r_tag.eql?('sub_menu')
|
||||
flash.now[:notice] = t('admin.update_success_content')
|
||||
flash.now[:notice] = t('update.success.content')
|
||||
|
||||
if @part.page.name == 'home'
|
||||
expire_page '/'
|
||||
|
||||
@@ -72,7 +72,7 @@ class Admin::PagesController < ApplicationController
|
||||
end
|
||||
|
||||
if @item.save
|
||||
flash.now[:notice] = t('admin.create_success_page')
|
||||
flash.now[:notice] = t('create.success.page')
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
redirect_to admin_page_url(@item)
|
||||
@@ -80,7 +80,7 @@ class Admin::PagesController < ApplicationController
|
||||
format.js {}
|
||||
end
|
||||
else
|
||||
flash.now[:error] = t('admin.create_error_page')
|
||||
flash.now[:error] = t('create.error.page')
|
||||
@apps = ModuleApp.all
|
||||
@designs = Design.all.entries
|
||||
@design = Design.first
|
||||
@@ -99,7 +99,7 @@ class Admin::PagesController < ApplicationController
|
||||
params[:page][:frontend_field_type] = nil
|
||||
|
||||
if @item.update_attributes(params[:page])
|
||||
flash[:notice] = t('admin.update_success_page')
|
||||
flash[:notice] = t('update.success.page')
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
redirect_to admin_page_url(@item)
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
class Admin::TranslationsController < ApplicationController
|
||||
|
||||
layout "admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
|
||||
def index
|
||||
set_variables
|
||||
end
|
||||
|
||||
def edit
|
||||
set_variables
|
||||
end
|
||||
|
||||
# Update either the i18n_variables or the languages
|
||||
def update
|
||||
begin
|
||||
case params[:id]
|
||||
# Update the i18n_variables
|
||||
when 'all'
|
||||
params[:i18n_variables].each do |id, var|
|
||||
i18n_variable = I18nVariable.find(id)
|
||||
i18n_variable.update_attributes(var)
|
||||
end
|
||||
# Add a language
|
||||
when 'add'
|
||||
site = Site.find(session[:site])
|
||||
if !site.valid_locales.include?(params[:language])
|
||||
site.valid_locales << params[:language]
|
||||
site.save
|
||||
I18nVariable.create({:key => params[:language], :document_class => 'language'})
|
||||
end
|
||||
# Enable a language
|
||||
when 'enable'
|
||||
site = Site.find(session[:site])
|
||||
if !site.in_use_locales.include?(params[:enable_language])
|
||||
site.in_use_locales << params[:enable_language]
|
||||
site.save
|
||||
end
|
||||
# Disable a language
|
||||
when 'disable'
|
||||
site = Site.find(session[:site])
|
||||
if site.in_use_locales.include?(params[:disable_language])
|
||||
site.in_use_locales.delete(params[:disable_language])
|
||||
site.save
|
||||
end
|
||||
# Delete a language and the corresponding i18n_variables
|
||||
when 'delete'
|
||||
site = Site.find(session[:site])
|
||||
site.in_use_locales.delete(params[:delete_language])
|
||||
site.valid_locales.delete(params[:delete_language])
|
||||
site.save
|
||||
I18nVariable.destroy_all(:conditions => {:document_class => 'language', :key => params[:delete_language]})
|
||||
end
|
||||
redirect_to admin_translations_url
|
||||
rescue
|
||||
set_variables
|
||||
render :action => :edit
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Get the i18n_variables and languages
|
||||
def set_variables
|
||||
@i18n_variables = I18nVariable.all.entries
|
||||
@language_i18n_variables = @i18n_variables.inject([]) do |result, var|
|
||||
result << var if var.document_class.eql?('language')
|
||||
result
|
||||
end
|
||||
@role_i18n_variables = @i18n_variables.inject([]) do |result, var|
|
||||
result << var if var.document_class.eql?('Role')
|
||||
result
|
||||
end
|
||||
@info_i18n_variables = @i18n_variables.inject([]) do |result, var|
|
||||
result << var if var.document_class.eql?('UserInfoModel')
|
||||
result
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -22,7 +22,7 @@ class Admin::UsersController < ApplicationController
|
||||
puts params.to_yaml
|
||||
@user = User.new(params[:user])
|
||||
if @user.save
|
||||
flash[:notice] = t('admin.create_success_user')
|
||||
flash[:notice] = t('create.success.user')
|
||||
redirect_to :action => :index
|
||||
else
|
||||
render :action => :new
|
||||
@@ -42,10 +42,10 @@ class Admin::UsersController < ApplicationController
|
||||
@user.avatar = params[:file] if params[:file]
|
||||
|
||||
if @user.id.to_s.eql?(session['warden.user.user.key'][1].to_s) && @user.admin != params[:user][:admin].to_i.to_b
|
||||
flash.now[:error] = t('admin.cant_revoke_self_admin')
|
||||
flash.now[:error] = t(:cant_revoke_self_admin)
|
||||
end
|
||||
if !flash[:error] && @user.update_attributes(params[:user])
|
||||
flash[:notice] = t('admin.update_success_user')
|
||||
flash[:notice] = t('update.success.user')
|
||||
redirect_to :action => :index
|
||||
else
|
||||
get_info_and_roles
|
||||
@@ -55,7 +55,7 @@ class Admin::UsersController < ApplicationController
|
||||
|
||||
def destroy
|
||||
if params[:id].eql?(session['warden.user.user.key'][1].to_s)
|
||||
flash[:error] = t('admin.cant_delete_self')
|
||||
flash[:error] = t(:cant_delete_self)
|
||||
else
|
||||
@user = User.find(params[:id])
|
||||
@user.destroy
|
||||
|
||||
@@ -80,7 +80,7 @@ class Admin::UsersNewInterfaceController < ApplicationController
|
||||
# @user.rebuild_sub_roles_from_attribute_values!(attribute_values)
|
||||
# binding.pry
|
||||
if @user.save
|
||||
flash[:notice] = t('admin.create_success_user')
|
||||
flash[:notice] = t('create.success.user')
|
||||
redirect_to :action => :index
|
||||
else
|
||||
@form_index = 0
|
||||
@@ -116,10 +116,10 @@ class Admin::UsersNewInterfaceController < ApplicationController
|
||||
# @user.avatar = params[:file] if params[:file]
|
||||
|
||||
# if @user.id.to_s.eql?(session['warden.user.user.key'][1].to_s) && @user.admin != params[:user][:admin].to_i.to_b
|
||||
# flash.now[:error] = t('admin.cant_revoke_self_admin')
|
||||
# flash.now[:error] = t(:cant_revoke_self_admin)
|
||||
# end
|
||||
# if !flash[:error] && @user.update_attributes(params[:user])
|
||||
# flash[:notice] = t('admin.update_success_user')
|
||||
# flash[:notice] = t('update.success.user')
|
||||
# redirect_to :action => :index
|
||||
# else
|
||||
# get_info_and_roles
|
||||
@@ -129,7 +129,7 @@ class Admin::UsersNewInterfaceController < ApplicationController
|
||||
|
||||
def destroy
|
||||
if params[:id].eql?(session['warden.user.user.key'][1].to_s)
|
||||
flash[:error] = t('admin.cant_delete_self')
|
||||
flash[:error] = t(:cant_delete_self)
|
||||
else
|
||||
@user = User.find(params[:id])
|
||||
@user.destroy
|
||||
|
||||
@@ -78,7 +78,7 @@ class ApplicationController < ActionController::Base
|
||||
if is_admin?
|
||||
true
|
||||
else
|
||||
flash[:error] = t("admin.access.denied.not_admin")
|
||||
flash[:error] = t("access.denied.not_admin")
|
||||
auth_failed_in_backend
|
||||
end
|
||||
end
|
||||
@@ -87,7 +87,7 @@ class ApplicationController < ActionController::Base
|
||||
if is_manager?
|
||||
true
|
||||
else
|
||||
flash[:error] = t("admin.access.denied.app.not_manager")
|
||||
flash[:error] = t("access.denied.app.not_manager")
|
||||
auth_failed_in_backend
|
||||
end
|
||||
end
|
||||
@@ -96,7 +96,7 @@ class ApplicationController < ActionController::Base
|
||||
if (@module_app.sub_managing_users.include?(current_or_guest_user) || is_manager?)
|
||||
true
|
||||
else
|
||||
flash[:error] = t("admin.access.denied.app.not_sub_manager")
|
||||
flash[:error] = t("access.denied.app.not_sub_manager")
|
||||
auth_failed_in_backend
|
||||
end
|
||||
end
|
||||
@@ -105,13 +105,13 @@ class ApplicationController < ActionController::Base
|
||||
if (@module_app.app_auth.auth_users.include?(current_or_guest_user) || for_app_sub_manager )
|
||||
true
|
||||
else
|
||||
flash[:error] = t("admin.access.denied.app.not_authed_user")
|
||||
flash[:error] = t("access.denied.app.not_authed_user")
|
||||
auth_failed_in_backend
|
||||
end
|
||||
end
|
||||
|
||||
def check_object_premission(obj,title)
|
||||
flash[:error] = t("admin.access.denied.object")
|
||||
flash[:error] = t("access.denied.object")
|
||||
auth_failed_in_backend unless (obj.get_object_auth_by_title(title).auth_users.include?(current_or_guest_user) || is_manager? || is_admin? )
|
||||
end
|
||||
|
||||
@@ -131,7 +131,9 @@ class ApplicationController < ActionController::Base
|
||||
object_class = params[:model].classify.constantize
|
||||
@object = object_class.find(params[:id])
|
||||
module_app = ModuleApp.first(:conditions => {:key => params[:key]})
|
||||
@item = Item.where(module_app_id: module_app.id).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first
|
||||
@item = @object.share_item
|
||||
#@item = Item.where(module_app_id: module_app.id).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first
|
||||
#binding.pry
|
||||
@orig_url = "http://#{request.host_with_port}/#{@item.path}?id=#{@object.id}"
|
||||
render 'shared/render_share', :layout => false
|
||||
end
|
||||
|
||||
@@ -103,11 +103,41 @@ class DesktopController< ApplicationController
|
||||
def getgroups
|
||||
@section = Section.find(params["sectionid"])
|
||||
@groups = @section.groups
|
||||
a = Array.new
|
||||
|
||||
gr = Array.new
|
||||
@groups.each do |group|
|
||||
a << group.tiles
|
||||
a = Array.new
|
||||
t = group.tiles
|
||||
t.each do |tile|
|
||||
data_content = ""
|
||||
jsfile = []
|
||||
cssfile = ""
|
||||
shape = "w1 h1"
|
||||
if tile.data_category == "widget"
|
||||
widge = DesktopWidget.find(tile.desktop_widget_id.to_s)
|
||||
# data_content = widge.widget_layout.file
|
||||
data_content = "desktop/widget_layout?id="+tile.desktop_widget_id.to_s
|
||||
jsfile = widge.javascripts.collect{|js| js.file}
|
||||
cssfile = widge.css_default.file
|
||||
shape = widge.shape
|
||||
title = widge.name
|
||||
else
|
||||
data_content = tile.data_content
|
||||
title = tile.title
|
||||
end
|
||||
a << {"id"=>tile.id,"data_category"=>tile.data_category,"data_content"=>data_content,"js"=>jsfile,"css"=>cssfile,"shape"=>shape,"position"=>tile.position,"title"=>title}
|
||||
end
|
||||
gr << a
|
||||
end
|
||||
render :json =>a.to_json
|
||||
render :json =>gr.to_json
|
||||
end
|
||||
|
||||
def widget_layout
|
||||
widget = DesktopWidget.find(params[:id])
|
||||
link = '<link href="'+widget.css_default.file.to_s+'" media="screen" rel="stylesheet" type="text/css" />'
|
||||
content = widget.widget_layout.body
|
||||
dhtml = link + content
|
||||
render :text => dhtml.html_safe
|
||||
end
|
||||
|
||||
def getsectionlist
|
||||
|
||||
@@ -8,6 +8,7 @@ class DesktopPublicationsController< ApplicationController
|
||||
end
|
||||
|
||||
def journal_p_add
|
||||
debugger
|
||||
render "desktop/journal_pages/add", :layout => false
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
class DesktopWidgetsController < OrbitBackendController
|
||||
require "net/http"
|
||||
require "uri"
|
||||
require 'zip/zip'
|
||||
|
||||
def index
|
||||
end
|
||||
|
||||
def upload
|
||||
if !params[:desktop_widget].nil?
|
||||
temp_file = Tempfile.new("temp_file")
|
||||
original_file = params[:desktop_widget][:package_file]
|
||||
#if original_file.content_type == 'application/zip'
|
||||
temp_file.write(original_file.read.force_encoding('UTF-8'))
|
||||
temp_file.rewind
|
||||
filename = File.basename(original_file.original_filename,".zip")
|
||||
unzip_widget(temp_file, filename)
|
||||
#else
|
||||
# flash[:error] = "Upload file should be in zip format"
|
||||
#end
|
||||
temp_file.close
|
||||
end
|
||||
end
|
||||
|
||||
def unzip_widget(file, zip_name)
|
||||
Zip::ZipFile.open(file) { |zip_file|
|
||||
dw = DesktopWidget.new.from_json(zip_file.read("#{zip_name}/settings.json"))
|
||||
Dir.mktmpdir('f_path') { |dir|
|
||||
javascripts_entries = []
|
||||
images_entries = []
|
||||
|
||||
zip_file.entries.each do |entry|
|
||||
case (path = entry.to_s)
|
||||
when /\A(#{zip_name})\/(default\.css)\z/
|
||||
#for default css
|
||||
dw.build_css_default(:file => get_temp_file(zip_file, dir, entry))
|
||||
when /\A(#{zip_name})\/(widget\.html)\z/ #for layout html
|
||||
dw.build_widget_layout(:file => get_temp_file(zip_file, dir, entry))
|
||||
when /\A(#{zip_name})\/(javascripts)\/.*(\.js)\z/ #for js
|
||||
javascripts_entries << entry
|
||||
when /\A(#{zip_name})\/(images)\/.*((\.jpg)|(\.png)|(\.gif))\z/ #for img
|
||||
images_entries << entry
|
||||
end
|
||||
end
|
||||
|
||||
['javascripts', 'images'].each do |type|
|
||||
eval("#{type}_entries").each do |entry|
|
||||
eval("dw.#{type}").build(:file => get_temp_file(zip_file, dir, entry))
|
||||
end
|
||||
end
|
||||
}
|
||||
dw.save
|
||||
}
|
||||
end
|
||||
def get_temp_file(zip_file, dir, entry)
|
||||
filename = File.basename(entry.to_s)
|
||||
temp_file = File.new(dir + '/' + filename, 'w+')
|
||||
temp_file.write (zip_file.read entry ).force_encoding('UTF-8')
|
||||
temp_file
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,4 +1,4 @@
|
||||
class OrbitBackendController< ApplicationController
|
||||
class OrbitBackendController < ApplicationController
|
||||
#before_filter :setup_vars
|
||||
#before_filter :set_current_user
|
||||
|
||||
@@ -11,17 +11,15 @@ class OrbitBackendController< ApplicationController
|
||||
layout 'new_admin'
|
||||
|
||||
def setup_vars
|
||||
@app_title = request.fullpath.split('/')[2]
|
||||
@app_title = request.fullpath.split('/')[1] if(@app_title == "back_end")
|
||||
@app_title.gsub!(/[?].*/,'')
|
||||
@module_app = ModuleApp.first(conditions: {:key => @app_title} )
|
||||
@app_title = controller_path.split('/')[1].singularize
|
||||
@module_app ||= ModuleApp.first(conditions: {:key => @app_title} )
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def force_order_for_visitor
|
||||
setup_vars
|
||||
set_current_user
|
||||
setup_vars
|
||||
set_current_user
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class OtheraccountsController< ApplicationController
|
||||
class Desktop::OtheraccountsController< ApplicationController
|
||||
require 'open-uri'
|
||||
require 'rexml/document'
|
||||
require 'net/http'
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
class SessionsController < Devise::SessionsController
|
||||
prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
|
||||
include Devise::Controllers::InternalHelpers
|
||||
|
||||
# POST /resource/sign_in
|
||||
def create
|
||||
# login_password = params[:user][:password]
|
||||
# login_uid = params[:user][:nccu_ldap_uid]
|
||||
login_password = params[:user][:password]
|
||||
login_email = params[:user][:email]
|
||||
result = false
|
||||
resource = User.first(conditions:{ email: login_email })
|
||||
set_flash_message(:notice, :signed_in) if is_navigational_format?
|
||||
if resource.nil?
|
||||
logger.error "Can't find user #{login_email}"
|
||||
flash[:notice] = t('devise.failure.invalid')
|
||||
render :action => "new"
|
||||
else
|
||||
logger.info "=== passed"
|
||||
resource_name = resource.class.to_s.downcase
|
||||
sign_in(resource_name, resource)
|
||||
respond_with resource, :location => redirect_location(resource_name, resource)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Reference in new issue
Block a user