Orbit/app/controllers/admin/module_apps_controller.rb

86 lines
2.6 KiB
Ruby
Raw Normal View History

2011-12-20 08:47:17 +00:00
class Admin::ModuleAppsController < ApplicationController
layout "admin"
2011-12-20 08:47:17 +00:00
def index
@module_apps = ModuleApp.all.entries
end
def reload_frontend_pages
@module_app = ModuleApp.find(params[:id])
respond_to do |format|
format.js {}
end
2011-12-20 08:47:17 +00:00
end
2012-01-12 06:13:41 +00:00
def edit
@module_app = ModuleApp.find(params[:id])
end
2012-01-13 10:20:04 +00:00
2012-01-12 06:13:41 +00:00
def update
@module_app = ModuleApp.find(params[:id])
unless params['module_app']['enable_frontend'].nil?
@module_app.update_attribute('enable_frontend',params['module_app']['enable_frontend'])
@module_app.save!
end
@attribute = @module_app
respond_to do |format|
format.html { redirect_to :action => :index }
format.js { render 'admin/attributes/toggle_enable' }
end
end
2012-01-13 10:20:04 +00:00
def assign_sub_manager
@module_app = ModuleApp.find(params[:id])
@assign_to_user = User.find params[:sub_manager_id] rescue nil
unless @assign_to_user.nil?
if @module_app.assign_sub_manager(@assign_to_user,current_user)
flash[:notice] = t('admin.app_auth.assign_success_sub_manager')
else
flash[:notice] = t('admin.app_auth.assign_fail_sub_manager')
end
else
flash[:notice] = t('admin.app_auth.assign_fail_sub_manager_no_user')
end
redirect_to :action => "edit"
end
def assign_manager
@module_app = ModuleApp.find(params[:id])
@assign_to_user = User.find params[:manager_id] rescue nil
unless @assign_to_user.nil?
if @module_app.assign_manager(@assign_to_user,current_user)
flash[:notice] = t('admin.app_auth.assign_success_manager')
else
flash[:notice] = t('admin.app_auth.assign_fail_manager')
end
else
flash[:notice] = t('admin.app_auth.assign_fail_manager_no_user')
end
redirect_to :action => "edit"
end
def remove_manager
@module_app = ModuleApp.find(params[:id])
@app_manager = AppManager.find(params[:app_manager_id]) rescue nil
if @module_app.remove_manager(@app_manager.user)
flash[:notice] = t('admin.app_auth.delete_success_manager')
else
flash[:notice] = t('admin.app_auth.delete_fail_manager')
end
redirect_to :action => "edit"
end
def remove_sub_manager
@module_app = ModuleApp.find(params[:id])
@app_sub_manager = AppManager.find(params[:app_sub_manager_id]) rescue nil
if @module_app.remove_sub_manager(@app_sub_manager.user)
flash[:notice] = t('admin.app_auth.delete_success_sub_manager')
else
flash[:notice] = t('admin.app_auth.delete_fail_sub_manager')
end
redirect_to :action => "edit"
end
2011-12-20 08:47:17 +00:00
end