diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 7b7d107ae..f28c7ed60 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -3,8 +3,6 @@ class PeopleController < CrudController include ExportController - helper_method :picture_path - self.permitted_attrs = %i[birthdate location marital_status updated_by name nationality nationality2 title competence_notes company_id email department_id shortname] @@ -42,12 +40,4 @@ def export type: 'application/vnd.oasis.opendocument.text', disposition: content_disposition('attachment', filename) end - - def picture_path - if @person.picture.file - @person.picture.url - else - "/default_avatar.png" - end - end end diff --git a/app/controllers/picture_controller.rb b/app/controllers/picture_controller.rb new file mode 100644 index 000000000..a523f6b05 --- /dev/null +++ b/app/controllers/picture_controller.rb @@ -0,0 +1,6 @@ +class PictureController < ApplicationController + def show + picture_url = @person.picture.file.nil? ? default_avatar_path : @person.picture.url + send_file(picture_url, disposition: 'inline') + end +end diff --git a/app/helpers/picture_helper.rb b/app/helpers/picture_helper.rb new file mode 100644 index 000000000..42cb833cd --- /dev/null +++ b/app/helpers/picture_helper.rb @@ -0,0 +1,2 @@ +module PictureHelper +end diff --git a/app/views/people/edit.html.haml b/app/views/people/edit.html.haml index a3574b797..d1c75c1a2 100644 --- a/app/views/people/edit.html.haml +++ b/app/views/people/edit.html.haml @@ -2,8 +2,8 @@ = form_with model: @person do |form| %div.d-flex.justify-content-between %div.pe-5 - %img.rounded-circle{src: picture_path, width: '141', height: '141'} - -# = form.file_field :picture + %img.rounded-circle{src: "/api/people/#{@person.id}/picture", width: '141', height: '141'} + = form.file_field :picture %div.pe-5.d-flex %table %tbody diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index 18dba98cc..eb59d9e58 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -6,7 +6,7 @@ %turbo-frame{id: "#{dom_id @person}"} %div.d-flex.justify-content-between %div - -# %img.rounded-circle{src: @person.picture, width: '141', height: '141'} + %img.rounded-circle{src: "/api/people/#{@person.id}/picture", width: '141', height: '141'} %div.mt-3= link_to "Bearbeiten", edit_person_path %div.pe-5 %table @@ -21,12 +21,19 @@ %tr %td= @person.title %th.fw-light Funktion - - @person.person_roles.each do |person_role| + - unless @person.person_roles.empty? + - @person.person_roles.each do |person_role| + %tr + %td= "#{person_role.role.name} #{person_role.person_role_level.level} #{person_role.percent.to_i}%" + - else %tr - %td= "#{person_role.role.name} #{person_role.person_role_level.level} #{person_role.percent.to_i}%" + %td - %th.fw-light Organisationseinheit %tr - %td= @person.department&.name + - unless @person.department.nil? + %td= @person.department.name + - else + %td - %th.fw-light Firma %tr %td= @person.company.name @@ -47,7 +54,10 @@ %td= @person.marital_status %th.fw-light Kürzel %tr - %td= @person.shortname + - unless @person.shortname.nil? + %td= @person.shortname + - else + %td - %div %div.fw-light Sprachen %div.border.border-dark-subtle.mt-1.p-2.rounded diff --git a/public/default_avatar.png b/public/default_avatar.png deleted file mode 100644 index 75749ead5..000000000 Binary files a/public/default_avatar.png and /dev/null differ diff --git a/spec/helpers/picture_helper_spec.rb b/spec/helpers/picture_helper_spec.rb new file mode 100644 index 000000000..1c022316c --- /dev/null +++ b/spec/helpers/picture_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the PictureHelper. For example: +# +# describe PictureHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe PictureHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/requests/picture_request_spec.rb b/spec/requests/picture_request_spec.rb new file mode 100644 index 000000000..a17fc15a5 --- /dev/null +++ b/spec/requests/picture_request_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe "Pictures", type: :request do + +end