Class: UsersController

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

Overview

rubocop:todo Style/Documentation

Constant Summary

Constants included from FlashTruncation

FlashTruncation::STRING_OVERHEAD

Instance Method Summary collapse

Methods inherited from ApplicationController

#block_api_access, #clean_params_from_check, #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


25
26
# File 'app/controllers/users_controller.rb', line 25

def edit
end

#projectsObject


42
43
44
# File 'app/controllers/users_controller.rb', line 42

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

#showObject


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/users_controller.rb', line 8

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

  begin
    label_template = LabelPrinter::PmbClient.get_label_template_by_name(configatron.swipecard_pmb_template)
                                            .fetch('data')
                                            .first
    @label_template_id ||= label_template['id']
  rescue LabelPrinter::PmbException => e
    @label_template_id = nil
    flash.now[:error] = "Print My Barcode: #{e}"
  rescue NoMethodError
    @label_template_id = nil
    flash.now[:error] = 'Wrong PMB Label Template'
  end
end

#study_reportsObject


46
47
48
# File 'app/controllers/users_controller.rb', line 46

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

#updateObject


28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/users_controller.rb', line 28

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