Sha256: a2d3be718136e36ec4f7e8fe8aad8daed8b69a28b2e1251bc2cccd8015ed9db6
Contents?: true
Size: 1.96 KB
Versions: 1
Compression:
Stored size: 1.96 KB
Contents
class UcbRails::Admin::UsersController < UcbRails::Admin::BaseController before_filter :find_user, :only => [:edit, :update, :destroy] def index respond_to do |format| format.html { @users = UcbRails::User.all } # format.json { render json: UsersDatatable.new(view_context) } end end def edit end def create uid = params.fetch(:uid) if user = UcbRails::User.find_by_uid(uid) flash[:warning] = "User already exists" else user = UcbRails::UserLdapService.create_user_from_uid(uid) flash[:notice] = 'Record created'#msg_created(user) end # render :js => %(window.location.href = '#{ucb_rails_admin_user_path}') render :js => %(window.location.href = '#{edit_ucb_rails_admin_user_path(user)}') end def update if @user.update_attributes(params.fetch(:ucb_rails_user), :without_protection => true) redirect_to(ucb_rails_admin_users_path, notice: 'Record updated') else render("edit") end end def destroy if @user.destroy flash[:notice] = 'Record deleted' #msg_destroyed(@user) else flash[:error] = @user.errors[:base].first end redirect_to(ucb_rails_admin_users_path) end def ldap_search @lps_entries = UcbRails::LdapPerson::Finder.find_by_first_last( params.fetch(:first_name), params.fetch(:last_name), :sort => :last_first_downcase ) @lps_existing_uids = UcbRails::User.where(uid: @lps_entries.map(&:uid)).pluck(:uid) render 'ucb_rails/lps/search' end def typeahead_search tokens = params.fetch(:query).to_s.strip.split(/\s+/) wheres = tokens.map { |e| 'first_last_name like ?' }.join(' and ') values = tokens.map { |e| "%#{e}%" } where = ["#{wheres}", *values] results = UcbRails::User.where(*where).limit(10) render json: results.map { |r| {uid: r.uid, first_last_name: r.first_last_name} } end private def find_user @user ||= UcbRails::User.find(params.fetch(:id)) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ucb_rails-0.0.2 | app/controllers/ucb_rails/admin/users_controller.rb |