Class: RequestPresenter
- Inherits:
-
Object
- Object
- RequestPresenter
- Defined in:
- app/presenters/request_presenter.rb
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
- #data_manager ⇒ Object
- #data_sponsor ⇒ Object
- #departments_list ⇒ Object
- #eligible_to_edit?(user) ⇒ Boolean
- #full_name(uid) ⇒ Object
-
#initialize(request) ⇒ RequestPresenter
constructor
A new instance of RequestPresenter.
- #project_directory ⇒ Object
- #project_purpose ⇒ Object
-
#sidebar_progress(controller, step, substep = nil) ⇒ Object
Returns the correct CSS class suffix for the sidebar navigation progress for a given step/substep.
- #user_list ⇒ Object
Constructor Details
#initialize(request) ⇒ RequestPresenter
Returns a new instance of RequestPresenter.
4 5 6 |
# File 'app/presenters/request_presenter.rb', line 4 def initialize(request) @request = request end |
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
3 4 5 |
# File 'app/presenters/request_presenter.rb', line 3 def request @request end |
Instance Method Details
#data_manager ⇒ Object
21 22 23 |
# File 'app/presenters/request_presenter.rb', line 21 def data_manager full_name(request.data_manager) end |
#data_sponsor ⇒ Object
17 18 19 |
# File 'app/presenters/request_presenter.rb', line 17 def data_sponsor full_name(request.data_sponsor) end |
#departments_list ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'app/presenters/request_presenter.rb', line 33 def departments_list return "" if request.departments.blank? dept_list = [] request.departments.each do |dept| dept_list << "#{dept['name']} (#{dept['code']})" end dept_list.join(", ") end |
#eligible_to_edit?(user) ⇒ Boolean
8 9 10 11 12 13 14 15 |
# File 'app/presenters/request_presenter.rb', line 8 def eligible_to_edit?(user) return false if user.nil? if request.submitted? user.eligible_sysadmin? else user.uid == request.requested_by || user.eligible_sysadmin? end end |
#full_name(uid) ⇒ Object
53 54 55 56 57 |
# File 'app/presenters/request_presenter.rb', line 53 def full_name(uid) return "" if uid.blank? user = User.find_by(uid: uid) user.display_name_safe.to_s end |
#project_directory ⇒ Object
25 26 27 |
# File 'app/presenters/request_presenter.rb', line 25 def project_directory request.parent_folder.present? ? File.join(request.parent_folder, request.project_folder) : request.project_folder end |
#project_purpose ⇒ Object
29 30 31 |
# File 'app/presenters/request_presenter.rb', line 29 def project_purpose ProjectPurpose.label_for(request.project_purpose) end |
#sidebar_progress(controller, step, substep = nil) ⇒ Object
Returns the correct CSS class suffix for the sidebar navigation progress for a given step/substep.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/presenters/request_presenter.rb', line 61 def (controller, step, substep = nil) controller_name = controller.controller_name case step when 1 step1_css_suffix(controller_name, substep) when 2 step2_css_suffix(controller_name) when 3 step3_css_suffix(controller_name) when 4 step4_css_suffix(controller_name) else "-incomplete" end end |
#user_list ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'app/presenters/request_presenter.rb', line 42 def user_list return "" if request.user_roles.blank? usr_list = [] request.user_roles.each do |usr| name = full_name(usr["uid"]) name += " read only" if usr["read_only"] usr_list << name end usr_list.join(", ") end |