Class: UsersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/users_controller.rb

Constant Summary

Constants included from FlashTruncation

FlashTruncation::STRING_OVERHEAD

Instance Method Summary collapse

Methods inherited from ApplicationController

#block_api_access, #evil_parameter_hack!, #extract_header_info, #set_cache_disabled!

Methods included from FlashTruncation

#max_flash_size, #truncate_flash, #truncate_flash_array

Instance Method Details

#editObject



13
14
# File 'app/controllers/users_controller.rb', line 13

def edit
end


36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/users_controller.rb', line 36

def print_swipecard
  swipecard = params[:swipecard]
  printer = params[:printer]
  if swipecard.strip.present?
    print_swipecard_with_pmb(swipecard, printer)
  else
    flash[:error] = 'Cannot print empty swipecard'
  end
  redirect_to action: :show, id: @user.id
end

#projectsObject



28
29
30
# File 'app/controllers/users_controller.rb', line 28

def projects
  @projects = Project.for_user(@user).page(params[:page])
end

#showObject



9
10
11
# File 'app/controllers/users_controller.rb', line 9

def show
  @printer_list = BarcodePrinter.alphabetical.where(barcode_printer_type: BarcodePrinterType96Plate.all).pluck(:name)
end

#study_reportsObject



32
33
34
# File 'app/controllers/users_controller.rb', line 32

def study_reports
  @study_reports = StudyReport.for_user(@user).page(params[:page]).order(id: :desc)
end

#updateObject

rubocop:todo Metrics/AbcSize



16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/users_controller.rb', line 16

def update # rubocop:todo Metrics/AbcSize
  params[:user].delete(:swipecard_code) if params[:user][:swipecard_code].blank?
  @user = User.find(params[:id])
  @user.update(params[:user]) if @user.id == params[:id].to_i
  if @user.save
    flash[:notice] = 'Profile updated'
  else
    flash[:error] = 'Problem updating profile.'
  end
  redirect_to action: :show, id: @user.id
end