Class: HrLite::Admin::DocumentsController
- Inherits:
-
BaseController
- Object
- HrLite::ApplicationController
- BaseController
- HrLite::Admin::DocumentsController
- Defined in:
- app/controllers/hr_lite/admin/documents_controller.rb
Overview
HR's side: whose documents are missing, and verifying the ones that
arrived. Reaching a person's list is document.view; opening the file
still goes through the row's own visibility.
Instance Method Summary collapse
Instance Method Details
#index ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'app/controllers/hr_lite/admin/documents_controller.rb', line 10 def index @category = params[:category].presence scope = hr_scope(Document.includes(:user).recent_first, "document.view") scope = scope.where(category: @category) if @category @pending = scope.where(verification: "pending").limit(50).to_a @documents = paginate(scope) @categories = Document.distinct.order(:category).pluck(:category) end |
#reject ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/hr_lite/admin/documents_controller.rb', line 33 def reject document = find_manageable note = params[:note].to_s.strip if note.blank? return redirect_back fallback_location: admin_documents_path, alert: "Say what is wrong with it — the employee has to re-upload." end document.reject!(actor: hr_current_user, note: note) redirect_back fallback_location: admin_documents_path, notice: "#{document.title} rejected." end |
#show ⇒ Object
19 20 21 22 23 24 |
# File 'app/controllers/hr_lite/admin/documents_controller.rb', line 19 def show @employee = HrLite.user_klass.find(params[:user_id]) hr_require_reach!("document.view", @employee) @documents = Document.for_user(@employee).recent_first @missing = Document::SENSITIVE_CATEGORIES - @documents.map(&:category) end |
#verify ⇒ Object
26 27 28 29 30 31 |
# File 'app/controllers/hr_lite/admin/documents_controller.rb', line 26 def verify document = find_manageable document.verify!(actor: hr_current_user, note: params[:note]) redirect_back fallback_location: admin_documents_path, notice: "#{document.title} verified." end |