2012-05-10 03:51:44 +00:00
|
|
|
class Admin::NewInterfaceModuleAppsController < ApplicationController
|
|
|
|
before_filter :authenticate_user!
|
|
|
|
before_filter :is_admin?
|
|
|
|
include AdminHelper
|
|
|
|
|
|
|
|
layout "new_admin"
|
|
|
|
|
|
|
|
def setting
|
2012-05-10 06:43:05 +00:00
|
|
|
@sys_users = User.all(conditions: {admin: false})
|
2012-05-10 03:51:44 +00:00
|
|
|
@module_app = ModuleApp.find(params[:module_app_id])
|
|
|
|
@options_from_collection_for_select_bulletin_categorys = [@module_app].collect{|ma| [ma.title,ma.id] }
|
|
|
|
# if params.has_key? :category
|
|
|
|
# @bulletin_category = BulletinCategory.find params[:category][:id]
|
|
|
|
# else
|
|
|
|
# @bulletin_category = @bulletin_categorys.first
|
|
|
|
# end
|
|
|
|
@users_array = @module_app.managing_users rescue []
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
format.js
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update_setting
|
|
|
|
module_app = update_setting_by_params
|
|
|
|
if module_app.save!
|
|
|
|
flash[:notice] = "Update Done"
|
|
|
|
else
|
|
|
|
flash[:notice] = "Update Failed"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def user_list
|
|
|
|
@module_app = ModuleApp.find params[:module_app][:id]
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
def update_setting_by_params
|
|
|
|
ma = ModuleApp.find params[:module_app][:id]
|
|
|
|
user_sat = User.find params[:users].keys
|
|
|
|
users_to_new = user_sat - ma.managing_users
|
|
|
|
users_to_remove = ma.managing_users - user_sat
|
|
|
|
|
|
|
|
users_to_new.each do |new_user|
|
|
|
|
ma.assign_manager(new_user,current_user)
|
|
|
|
end
|
|
|
|
|
|
|
|
users_to_remove.each do |remove_user|
|
|
|
|
ma.remove_manager(remove_user)
|
|
|
|
end
|
|
|
|
ma
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_categorys(id = nil)
|
|
|
|
@bulletin_categorys = []
|
|
|
|
if(is_manager? || is_admin?)
|
|
|
|
@bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true))
|
|
|
|
elsif is_sub_manager?
|
|
|
|
@bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end
|