-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
14 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class ApplicationController < ActionController::API | ||
class ApplicationController < ActionController::Base | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
class PeopleController < CrudController | ||
include ExportController | ||
|
||
self.permitted_attrs = %i[birthdate location | ||
marital_status updated_by name nationality nationality2 title | ||
competence_notes company_id email department_id shortname] | ||
|
||
self.nested_models = %i[advanced_trainings activities projects | ||
educations language_skills person_roles | ||
people_skills categories] | ||
|
||
self.permitted_relationships = %i[person_roles people_skills] | ||
class PeopleController < ApplicationController | ||
|
||
def index | ||
people = fetch_entries | ||
render json: people, each_serializer: PeopleSerializer | ||
@people = Person.all | ||
end | ||
|
||
def show | ||
if format_odt? | ||
export | ||
return | ||
end | ||
@person = Person.includes(projects: :project_technologies, | ||
person_roles: [:role, :person_role_level]).find(params.fetch(:id)) | ||
super | ||
end | ||
|
||
private | ||
|
||
def fetch_entries | ||
Person.includes(:company).list | ||
end | ||
|
||
def person | ||
@person ||= Person.find(params[:person_id]) | ||
end | ||
|
||
def export | ||
anon = params[:anon].presence || 'false' | ||
odt_file = Odt::Cv.new(entry, params).export | ||
filename = if anon == 'true' | ||
'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) | ||
@person = Person.find(params[:id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<% @people.each do |person| %> | ||
<h1> <%= person.name %> </h1> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div> | ||
<h1> <%= @person.name %>'s Profile </h1> | ||
<div> | ||
<h5> That person is from <%= @person.location %> </h5> | ||
</div> | ||
</div> | ||
<%= link_to "Person bearbeiten", edit_person_path %> |