86 lines
2.6 KiB
Ruby
86 lines
2.6 KiB
Ruby
class Admin::ModuleAppsController < ApplicationController
|
|
layout "admin"
|
|
|
|
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
|
|
end
|
|
|
|
def edit
|
|
@module_app = ModuleApp.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
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
|
|
|
|
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
|
|
end |