-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathpeople_controller.rb
64 lines (50 loc) · 1.71 KB
/
people_controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# frozen_string_literal: true
class PeopleController < CrudController
include ExportController
include ParamConverters
include PeopleControllerConcerns
self.permitted_attrs = [:birthdate, :location, :marital_status, :updated_by, :name, :nationality,
:nationality2, :title, :competence_notes, :company_id, :email,
:department_id, :shortname, :picture, :picture_cache,
{ person_roles_attributes:
[:role_id, :person_role_level_id, :percent, :id, :_destroy] },
{ language_skills_attributes:
[:language, :level, :certificate, :id, :_destroy] }]
layout 'person', only: [:show]
def index
return flash[:alert] = I18n.t('errors.profile-not-found') if params[:alert].present?
super
end
def show
return export if format_odt?
@person = Person.includes(projects: :project_technologies,
person_roles: [:role, :person_role_level]).find(params.fetch(:id))
super
end
def create
set_nationality2
super
end
def update
set_nationality2
super
end
def export
odt_file = Odt::Cv.new(entry, params).export
filename = if true?(params[:anon])
'CV_Puzzle_ITC_anonymized.odt'
else
filename(entry.name, 'CV_Puzzle_ITC')
end
send_data odt_file.generate,
type: 'application/vnd.oasis.opendocument.text',
disposition: content_disposition('attachment', filename)
end
private
def fetch_entries
Person.includes(:company).list
end
def person
@person ||= Person.find(params[:person_id])
end
end